コード例 #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);
    }
  }