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