Exemplo n.º 1
0
 void restart(RestartCallback callback) throws Exception {
   assert callback != null;
   if (!node.isClosed()) {
     node.close();
   }
   Settings newSettings = callback.onNodeStopped(name);
   if (newSettings == null) {
     newSettings = ImmutableSettings.EMPTY;
   }
   if (callback.clearData(name)) {
     NodeEnvironment nodeEnv = getInstanceFromNode(NodeEnvironment.class, node);
     if (nodeEnv.hasNodeFile()) {
       FileSystemUtils.deleteRecursively(nodeEnv.nodeDataLocations());
     }
   }
   node = (InternalNode) nodeBuilder().settings(node.settings()).settings(newSettings).node();
   resetClient();
 }
Exemplo n.º 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);
     }
   }
 }