Ejemplo n.º 1
0
 private void handleTransportDisconnect(DiscoveryNode node) {
   synchronized (masterNodeMutex) {
     if (!node.equals(this.masterNode)) {
       return;
     }
     if (connectOnNetworkDisconnect) {
       try {
         transportService.connectToNode(node);
       } catch (Exception e) {
         logger.trace("[master] [{}] transport disconnected (with verified connect)", masterNode);
         notifyMasterFailure(masterNode, "transport disconnected (with verified connect)");
       }
     } else {
       logger.trace("[master] [{}] transport disconnected", node);
       notifyMasterFailure(node, "transport disconnected");
     }
   }
 }
 private void handleTransportDisconnect(DiscoveryNode node) {
   synchronized (masterNodeMutex) {
     if (!node.equals(this.masterNode)) {
       return;
     }
     if (connectOnNetworkDisconnect) {
       try {
         transportService.connectToNode(node);
         // if all is well, make sure we restart the pinger
         if (masterPinger != null) {
           masterPinger.stop();
         }
         this.masterPinger = new MasterPinger();
         threadPool.schedule(pingInterval, ThreadPool.Names.SAME, masterPinger);
       } catch (Exception e) {
         logger.trace("[master] [{}] transport disconnected (with verified connect)", masterNode);
         notifyMasterFailure(masterNode, "transport disconnected (with verified connect)");
       }
     } else {
       logger.trace("[master] [{}] transport disconnected", node);
       notifyMasterFailure(node, "transport disconnected");
     }
   }
 }
  private void innerStart(final DiscoveryNode masterNode) {
    this.masterNode = masterNode;
    this.retryCount = 0;
    this.notifiedMasterFailure.set(false);

    // try and connect to make sure we are connected
    try {
      transportService.connectToNode(masterNode);
    } catch (final Exception e) {
      // notify master failure (which stops also) and bail..
      notifyMasterFailure(masterNode, "failed to perform initial connect [" + e.getMessage() + "]");
      return;
    }
    if (masterPinger != null) {
      masterPinger.stop();
    }
    this.masterPinger = new MasterPinger();
    // start the ping process
    threadPool.schedule(pingInterval, ThreadPool.Names.SAME, masterPinger);
  }