예제 #1
0
 /** Restarts a random node in the cluster and calls the callback during restart. */
 public void restartRandomNode(RestartCallback callback) throws Exception {
   ensureOpen();
   NodeAndClient nodeAndClient = getRandomNodeAndClient();
   if (nodeAndClient != null) {
     logger.info("Restarting random node [{}] ", nodeAndClient.name);
     nodeAndClient.restart(callback);
   }
 }
예제 #2
0
 private void restartAllNodes(boolean rollingRestart, RestartCallback callback) throws Exception {
   ensureOpen();
   List<NodeAndClient> toRemove = new ArrayList<TestCluster.NodeAndClient>();
   try {
     for (NodeAndClient nodeAndClient : nodes.values()) {
       if (!callback.doRestart(nodeAndClient.name)) {
         logger.info("Closing node [{}] during restart", nodeAndClient.name);
         toRemove.add(nodeAndClient);
         nodeAndClient.close();
       }
     }
   } finally {
     for (NodeAndClient nodeAndClient : toRemove) {
       nodes.remove(nodeAndClient.name);
     }
   }
   logger.info("Restarting remaining nodes rollingRestart [{}]", rollingRestart);
   if (rollingRestart) {
     int numNodesRestarted = 0;
     for (NodeAndClient nodeAndClient : nodes.values()) {
       callback.doAfterNodes(numNodesRestarted++, nodeAndClient.nodeClient());
       logger.info("Restarting node [{}] ", nodeAndClient.name);
       nodeAndClient.restart(callback);
     }
   } else {
     int numNodesRestarted = 0;
     for (NodeAndClient nodeAndClient : nodes.values()) {
       callback.doAfterNodes(numNodesRestarted++, nodeAndClient.nodeClient());
       logger.info("Stopping node [{}] ", nodeAndClient.name);
       nodeAndClient.node.close();
     }
     for (NodeAndClient nodeAndClient : nodes.values()) {
       logger.info("Starting node [{}] ", nodeAndClient.name);
       nodeAndClient.restart(callback);
     }
   }
 }