private ClientInvocation(
      HazelcastClientInstanceImpl client,
      EventHandler handler,
      ClientMessage clientMessage,
      int partitionId,
      Address address,
      Connection connection) {
    this.lifecycleService = client.getLifecycleService();
    this.invocationService = client.getInvocationService();
    this.executionService = client.getClientExecutionService();
    this.listenerService = (ClientListenerServiceImpl) client.getListenerService();
    this.handler = handler;
    this.clientMessage = clientMessage;
    this.partitionId = partitionId;
    this.address = address;
    this.connection = connection;
    final ClientProperties clientProperties = client.getClientProperties();

    int waitTime = clientProperties.getInvocationTimeoutSeconds().getInteger();
    long retryTimeoutInSeconds =
        waitTime > 0
            ? waitTime
            : Integer.parseInt(ClientProperties.PROP_INVOCATION_TIMEOUT_SECONDS_DEFAULT);

    clientInvocationFuture = new ClientInvocationFuture(this, client, clientMessage, handler);
    this.retryCountLimit = retryTimeoutInSeconds / RETRY_WAIT_TIME_IN_SECONDS;

    int interval = clientProperties.getHeartbeatInterval().getInteger();
    this.heartBeatInterval =
        interval > 0 ? interval : Integer.parseInt(PROP_HEARTBEAT_INTERVAL_DEFAULT);
  }
  public ClientConnectionManagerImpl(
      HazelcastClient client, LoadBalancer loadBalancer, AddressTranslator addressTranslator) {
    this.client = client;
    this.addressTranslator = addressTranslator;
    final ClientConfig config = client.getClientConfig();
    final ClientNetworkConfig networkConfig = config.getNetworkConfig();

    final int connTimeout = networkConfig.getConnectionTimeout();
    connectionTimeout = connTimeout == 0 ? Integer.MAX_VALUE : connTimeout;

    final ClientProperties clientProperties = client.getClientProperties();
    int timeout = clientProperties.getHeartbeatTimeout().getInteger();
    this.heartBeatTimeout =
        timeout > 0 ? timeout : Integer.parseInt(PROP_HEARTBEAT_TIMEOUT_DEFAULT);

    int interval = clientProperties.getHeartbeatInterval().getInteger();
    heartBeatInterval = interval > 0 ? interval : Integer.parseInt(PROP_HEARTBEAT_INTERVAL_DEFAULT);

    smartRouting = networkConfig.isSmartRouting();
    executionService = (ClientExecutionServiceImpl) client.getClientExecutionService();
    credentials = initCredentials(config);
    router = new Router(loadBalancer);

    inSelector =
        new InSelectorImpl(
            client.getThreadGroup(),
            "InSelector",
            Logger.getLogger(InSelectorImpl.class),
            OUT_OF_MEMORY_HANDLER);
    outSelector =
        new OutSelectorImpl(
            client.getThreadGroup(),
            "OutSelector",
            Logger.getLogger(OutSelectorImpl.class),
            OUT_OF_MEMORY_HANDLER);

    socketInterceptor = initSocketInterceptor(networkConfig.getSocketInterceptorConfig());
    socketOptions = networkConfig.getSocketOptions();
    socketChannelWrapperFactory = initSocketChannel(networkConfig);
  }