Exemplo n.º 1
0
 public ZooKeeperConfigProvider(string configurationName, string path)
 {
     //load data from zk
     using (var client = new ZooKeeperClient(configurationName))
     {
         var json = client.Get <string>(path);
         //parse json and assign data
     }
 }
Exemplo n.º 2
0
        public ZooKeeperDistributedLock(string key, string configName)
        {
            var config = ZooKeeperConfigSection.FromSection(configName);

            _client = new ZooKeeperClient(config);
            _path   = config.DistributedLockPath + "/" + key.ToMD5();

            //抢锁
            new Action(() =>
            {
                _client.CreatePersistentPath(_path);
                _no = _client.CreateSequential(_path + "/", false);
            }).InvokeWithRetry(5);
        }