public void Can_JoinElectionByUseTheSameZKConnection() { IZooKeeper zookeeper = new ZooKeeper("127.0.0.1:2181", new TimeSpan(0, 60, 0), null); Server server1 = new Server() { ShardName = "shard1", Host = "127.0.0.1", Port = 6369, paramStr = "allowAdmin=true", Path = ZkPath.ShardsPath(ZkPath.CollectionName) }; Server server2 = new Server() { ShardName = "shard1", Host = "127.0.0.1", Port = 6379, paramStr = "allowAdmin=true", Path = ZkPath.ShardsPath(ZkPath.CollectionName) }; ServerInstances si = new ServerInstances(); si.Add(new ServerInst(server1.Host, server1.Port, "allowAdmin=true")); si.Add(new ServerInst(server2.Host, server2.Port, "allowAdmin=true")); LeaderContext context1 = new LeaderContext(zookeeper, server1); context1.JoinElection(); LeaderContext context2 = new LeaderContext(zookeeper, server2); context2.JoinElection(); }
public void Init() { Server server1 = new Server() { ShardName = "shard1", Host = "127.0.0.1", Port = 6369, paramStr = "allowAdmin=true", Path = ZkPath.ShardsPath(ZkPath.CollectionName) }; Server server2 = new Server() { ShardName = "shard2", Host = "127.0.0.1", Port = 6379, paramStr = "allowAdmin=true", Path = ZkPath.ShardsPath(ZkPath.CollectionName) }; ShardBuilder builder1 = new ShardBuilder(); Shard shard1 = builder1.Name("shard1").AddServer(server1).State(LiveState.ACTIVE).Build(); ShardBuilder builder2 = new ShardBuilder(); Shard shard2 = builder2.Name("shard2").AddServer(server2).State(LiveState.ACTIVE).Build(); ShardBuilder builder3 = new ShardBuilder(); Shard shard3 = builder3.Name("shard3").State(LiveState.ACTIVE).Build(); Dictionary <String, Shard> shards = new Dictionary <String, Shard>(); shards.Add("shard1", shard1); shards.Add("shard2", shard2); shards.Add("shard3", shard3); ccl = new CacheCollection("testCol", shards, Router.DEFAULT); }
public void Can_JoinElectionTwiceSep() { IZooKeeper zookeeper1 = new ZooKeeper("127.0.0.1:2181", new TimeSpan(0, 60, 0), null); IZooKeeper zookeeper2 = new ZooKeeper("127.0.0.1:2181", new TimeSpan(0, 60, 0), null); Server server = new Server() { ShardName = "shard1", Host = "127.0.0.1", Port = 6369, paramStr = "allowAdmin=true", Path = ZkPath.ShardsPath(ZkPath.CollectionName) }; ServerInstances si = new ServerInstances(); si.Add(new ServerInst(server.Host, server.Port, "allowAdmin=true")); //LeaderContext context = new LeaderContext(zookeeper, server); //context.JoinElection(); }