コード例 #1
0
  public NodesFaultDetection(
      Settings settings, ThreadPool threadPool, TransportService transportService) {
    super(settings);
    this.threadPool = threadPool;
    this.transportService = transportService;

    this.connectOnNetworkDisconnect =
        componentSettings.getAsBoolean("connect_on_network_disconnect", true);
    this.pingInterval = componentSettings.getAsTime("ping_interval", timeValueSeconds(1));
    this.pingRetryTimeout = componentSettings.getAsTime("ping_timeout", timeValueSeconds(30));
    this.pingRetryCount = componentSettings.getAsInt("ping_retries", 3);
    this.registerConnectionListener =
        componentSettings.getAsBoolean("register_connection_listener", true);

    logger.debug(
        "[node  ] uses ping_interval [{}], ping_timeout [{}], ping_retries [{}]",
        pingInterval,
        pingRetryTimeout,
        pingRetryCount);

    transportService.registerHandler(PingRequestHandler.ACTION, new PingRequestHandler());

    this.connectionListener = new FDConnectionListener();
    if (registerConnectionListener) {
      transportService.addConnectionListener(connectionListener);
    }
  }
コード例 #2
0
 private void handleTransportDisconnect(DiscoveryNode node) {
   if (!latestNodes.nodeExists(node.id())) {
     return;
   }
   NodeFD nodeFD = nodesFD.remove(node);
   if (nodeFD == null) {
     return;
   }
   if (!running) {
     return;
   }
   nodeFD.running = false;
   if (connectOnNetworkDisconnect) {
     try {
       transportService.connectToNode(node);
       nodesFD.put(node, new NodeFD());
       threadPool.schedule(pingInterval, ThreadPool.Names.SAME, new SendPingRequest(node));
     } catch (Exception e) {
       logger.trace("[node  ] [{}] transport disconnected (with verified connect)", node);
       notifyNodeFailure(node, "transport disconnected (with verified connect)");
     }
   } else {
     logger.trace("[node  ] [{}] transport disconnected", node);
     notifyNodeFailure(node, "transport disconnected");
   }
 }
コード例 #3
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");
     }
   }
 }
コード例 #4
0
  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(masterPinger, pingInterval);
  }
コード例 #5
0
 public void close() {
   stop();
   transportService.removeHandler(PingRequestHandler.ACTION);
   transportService.removeConnectionListener(connectionListener);
 }
コード例 #6
0
 public void close() {
   stop("closing");
   this.listeners.clear();
   transportService.removeConnectionListener(connectionListener);
   transportService.removeHandler(MasterPingRequestHandler.ACTION);
 }