Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache zookeeper Zookeeper,数据版本控制_Apache Zookeeper - Fatal编程技术网

Apache zookeeper Zookeeper,数据版本控制

Apache zookeeper Zookeeper,数据版本控制,apache-zookeeper,Apache Zookeeper,以下是场景: Znode created:create/config 12345(例如在 12/12/12) 已对此配置进行更新,设置/配置34567 (例如,2013年12月12日修改) 一个月后,再次修改配置,set/config 567889(例如,在2013年1月1日修改) 问题: “获取”(或维护)版本历史记录的最佳方式是什么 与“/config”关联,即是否有方法获取 节点中存储的数据的整个历史记录 将当前配置值(即567889)恢复为原始值12345的最佳方法是什么?(通过爬网节点

以下是场景:

  • Znode created:create/config 12345(例如在 12/12/12)
  • 已对此配置进行更新,设置/配置34567 (例如,2013年12月12日修改)
  • 一个月后,再次修改配置,set/config 567889(例如,在2013年1月1日修改)
  • 问题:

  • “获取”(或维护)版本历史记录的最佳方式是什么 与“/config”关联,即是否有方法获取 节点中存储的数据的整个历史记录
  • 将当前配置值(即567889)恢复为原始值12345的最佳方法是什么?(通过爬网节点的数据历史记录)

  • 我需要一些帮助来解决这个问题。谢谢你

    我认为没有一个简单的方法可以做到这一点。以下是我将如何实现这一目标:

     1. divide the configurations in two znodes [say, /Config and /Config/data-*]
      - /config/data-* are the data nodes which will store the configuration
      - /config will store the history of all the configs so far
     2. /Config/data-* is sequential node
           So, every znode will have a strictly increasing number appended to it.
           For example, /config/data-1, /config/data-2, and so on. Your configuration object
           will be stored in data nodes.
             /config/data-1 -> 12345
             /config/data-2 -> 34567
             /config/data-3 -> 56789
     3. /config will look like this: 
        ["/config/data-1","/config/data-2","/config/data-3"] or just 
        ["1", "2", "3"]
    
    以下是写入算法:

     1. create a data node with new config. Which will return the the actual path.
        say /config/data-4
     2. now try to do conditional update on /config with "/config/data-4" or just "4" appended to
        the existing data i.e. 
        ["/config/data-1","/config/data-2","/config/data-3","/config/data-4"] or just
        ["1", "2", "3","4"]
        - if update succeeds, end.
        - else, someone else was simultaneously trying to update the config and won the race.
         So, either quit or try again starting with step1.
    
    注意:如果更新失败,您将在树中有有效的孤立节点,可以自动定期清理这些节点

    阅读内容如下:

    1. call sync [if consistency is important]
    2. read /config
    3. pick the path which is at the last index in the array retrieved from /config
    4. read the config from that path
    
    要回滚,请从/config中存储的列表中删除最后一个条目,或将列表的最后一个但第二个条目追加到末尾

    您可以在znode中添加一个“watch”并以这种方式跟踪历史?