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 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(); }
public Guid Add(string host, int port) { serverInstances.Add(new ServerInst(host, port)); return(GetByHostAndPort(host, port)); }