try {
for (int i = 0; i < 5; i++) {
Properties props = SgsTestNode.getDefaultProperties(
"TestWatchdogServiceImpl", serverNode, null);
DataService dataService = createDataService(props);
WatchdogServiceImpl watchdog =
new WatchdogServiceImpl(props, systemRegistry, txnProxy,
dummyShutdownCtrl);
DummyNodeListener listener = new DummyNodeListener();
watchdog.addNodeListener(listener);
watchdogMap.put(
watchdog, new WatchdogInfo(listener, dataService));
}
// shutdown watchdog server
watchdogService.shutdown();
Thread.sleep(renewTime * 4);
for (WatchdogServiceImpl watchdog : watchdogMap.keySet()) {
WatchdogInfo info = watchdogMap.get(watchdog);
DummyNodeListener listener = info.listener;
DataService dataService = info.dataService;
Set<Node> nodes = listener.getFailedNodes();
System.err.println(
"failedNodes for " + dataService.getLocalNodeId() +
": " + nodes);
if (nodes.size() != 6) {
fail("Expected 6 failed nodes, got " + nodes.size());
}
for (Node node : nodes) {
System.err.println(node);
if (node.isAlive()) {
fail("Node " + node.getId() + " is alive!");
}
}
}
} finally {
for (WatchdogServiceImpl watchdog : watchdogMap.keySet()) {
watchdog.shutdown();
watchdogMap.get(watchdog).dataService.shutdown();
}
}
}