* @throws InterruptedException
*/
public void testMulitpleChanges() throws OrbZKFailure, InterruptedException {
CountDownLatch cdlatch = new CountDownLatch(1);
TServer server = new TServer(cdlatch);
OrbTrackerMember otm = new OrbTrackerMember();
otm.setAvailablePartitions(1);
otm.setHostname("TEST");
otm.setInUsePartitions(1);
otm.setLeader(true);
otm.setPartitionCapacity(1);
otm.setPort(1);
otm.setReservedPartitions(1);
String path = ZookeeperUtils.tryToCreateNode(zk, leaderGroupPath + "/member", otm,
CreateMode.EPHEMERAL_SEQUENTIAL);
new LeaderGroupMemberMonitor(path, zk, path.split("/")[3], server);
cdlatch.await();
Map<String,OrbTrackerMemberData> map = server.getMemberData();
assertTrue(map.size() == 1);
Set<String> keys = map.keySet();
assertTrue(keys.size() == 1);
String nodeName = "";
for (String key : keys) {
nodeName = key;
}
assertTrue(nodeName.equals(path.split("/")[3]));
assertTrue(map.get(nodeName).getAvailablePartitions() == otm.getAvailablePartitions());
assertTrue(map.get(nodeName).getPort() == otm.getPort());
otm.setAvailablePartitions(9);
cdlatch = new CountDownLatch(1);
server.setLatcher(cdlatch);
ZookeeperUtils.setNodeData(zk, path, otm);
cdlatch.await();
map = server.getMemberData();
assertTrue(map.size() == 1);
keys = map.keySet();
assertTrue(keys.size() == 1);
nodeName = "";
for (String key : keys) {
nodeName = key;
}
assertTrue(nodeName.equals(path.split("/")[3]));
assertTrue(map.get(nodeName).getAvailablePartitions() == otm.getAvailablePartitions());
cdlatch = new CountDownLatch(1);
server.setLatcher(cdlatch);
otm.setHostname("Hostname");
ZookeeperUtils.setNodeData(zk, path, otm);
cdlatch.await();
map = server.getMemberData();
assertTrue(map.size() == 1);
keys = map.keySet();
assertTrue(keys.size() == 1);
nodeName = "";
for (String key : keys) {
nodeName = key;
}
assertTrue(nodeName.equals(path.split("/")[3]));
assertTrue(map.get(nodeName).getHostname() == otm.getHostname());
cdlatch = new CountDownLatch(1);
server.setLatcher(cdlatch);
otm.setHostname("Host");
ZookeeperUtils.setNodeData(zk, path, otm);
cdlatch.await();
map = server.getMemberData();
assertTrue(map.size() == 1);
keys = map.keySet();
assertTrue(keys.size() == 1);
nodeName = "";
for (String key : keys) {
nodeName = key;
}
assertTrue(nodeName.equals(path.split("/")[3]));
assertTrue(map.get(nodeName).getHostname() == otm.getHostname());
}