Search in sources :

Example 1 with SocketOptions

use of com.hazelcast.client.config.SocketOptions in project hazelcast by hazelcast.

the class ClientDomConfigProcessor method handleSocketOptions.

private void handleSocketOptions(Node node, ClientNetworkConfig clientNetworkConfig) {
    SocketOptions socketOptions = clientConfig.getNetworkConfig().getSocketOptions();
    for (Node child : childElements(node)) {
        String nodeName = cleanNodeName(child);
        if (matches("tcp-no-delay", nodeName)) {
            socketOptions.setTcpNoDelay(Boolean.parseBoolean(getTextContent(child)));
        } else if (matches("keep-alive", nodeName)) {
            socketOptions.setKeepAlive(Boolean.parseBoolean(getTextContent(child)));
        } else if (matches("reuse-address", nodeName)) {
            socketOptions.setReuseAddress(Boolean.parseBoolean(getTextContent(child)));
        } else if (matches("linger-seconds", nodeName)) {
            socketOptions.setLingerSeconds(Integer.parseInt(getTextContent(child)));
        } else if (matches("buffer-size", nodeName)) {
            socketOptions.setBufferSize(Integer.parseInt(getTextContent(child)));
        }
    }
    clientNetworkConfig.setSocketOptions(socketOptions);
}
Also used : SocketOptions(com.hazelcast.client.config.SocketOptions) Node(org.w3c.dom.Node)

Example 2 with SocketOptions

use of com.hazelcast.client.config.SocketOptions in project hazelcast by hazelcast.

the class ClusterDiscoveryServiceBuilder method build.

public ClusterDiscoveryService build() {
    ArrayList<CandidateClusterContext> contexts = new ArrayList<>();
    for (ClientConfig config : configs) {
        ClientNetworkConfig networkConfig = config.getNetworkConfig();
        SocketInterceptor interceptor = initSocketInterceptor(networkConfig.getSocketInterceptorConfig());
        ICredentialsFactory credentialsFactory = initCredentialsFactory(config);
        if (credentialsFactory == null) {
            credentialsFactory = new StaticCredentialsFactory(new UsernamePasswordCredentials(null, null));
        }
        credentialsFactory.configure(new ClientCallbackHandler(config));
        DiscoveryService discoveryService = initDiscoveryService(config);
        AddressProvider provider;
        if (externalAddressProvider != null) {
            provider = externalAddressProvider;
        } else {
            provider = createAddressProvider(config, discoveryService);
        }
        final SSLConfig sslConfig = networkConfig.getSSLConfig();
        final SocketOptions socketOptions = networkConfig.getSocketOptions();
        contexts.add(new CandidateClusterContext(config.getClusterName(), provider, discoveryService, credentialsFactory, interceptor, clientExtension.createChannelInitializer(sslConfig, socketOptions)));
    }
    return new ClusterDiscoveryService(unmodifiableList(contexts), configsTryCount, lifecycleService);
}
Also used : SSLConfig(com.hazelcast.config.SSLConfig) SocketOptions(com.hazelcast.client.config.SocketOptions) ArrayList(java.util.ArrayList) UsernamePasswordCredentials(com.hazelcast.security.UsernamePasswordCredentials) DefaultAddressProvider(com.hazelcast.client.impl.spi.impl.DefaultAddressProvider) AddressProvider(com.hazelcast.client.impl.connection.AddressProvider) RemoteAddressProvider(com.hazelcast.client.impl.spi.impl.discovery.RemoteAddressProvider) ICredentialsFactory(com.hazelcast.security.ICredentialsFactory) SocketInterceptor(com.hazelcast.nio.SocketInterceptor) StaticCredentialsFactory(com.hazelcast.config.security.StaticCredentialsFactory) ClientConfig(com.hazelcast.client.config.ClientConfig) DefaultDiscoveryService(com.hazelcast.spi.discovery.impl.DefaultDiscoveryService) DiscoveryService(com.hazelcast.spi.discovery.integration.DiscoveryService) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig)

Example 3 with SocketOptions

use of com.hazelcast.client.config.SocketOptions in project hazelcast by hazelcast.

the class DefaultClientExtension method createChannelInitializer.

@Override
public ChannelInitializer createChannelInitializer() {
    ClientNetworkConfig networkConfig = client.getClientConfig().getNetworkConfig();
    SSLConfig sslConfig = networkConfig.getSSLConfig();
    SocketOptions socketOptions = networkConfig.getSocketOptions();
    return createChannelInitializer(sslConfig, socketOptions);
}
Also used : SSLConfig(com.hazelcast.config.SSLConfig) SocketOptions(com.hazelcast.client.config.SocketOptions) ClientNetworkConfig(com.hazelcast.client.config.ClientNetworkConfig)

Aggregations

SocketOptions (com.hazelcast.client.config.SocketOptions)3 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)2 SSLConfig (com.hazelcast.config.SSLConfig)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 AddressProvider (com.hazelcast.client.impl.connection.AddressProvider)1 DefaultAddressProvider (com.hazelcast.client.impl.spi.impl.DefaultAddressProvider)1 RemoteAddressProvider (com.hazelcast.client.impl.spi.impl.discovery.RemoteAddressProvider)1 StaticCredentialsFactory (com.hazelcast.config.security.StaticCredentialsFactory)1 SocketInterceptor (com.hazelcast.nio.SocketInterceptor)1 ICredentialsFactory (com.hazelcast.security.ICredentialsFactory)1 UsernamePasswordCredentials (com.hazelcast.security.UsernamePasswordCredentials)1 DefaultDiscoveryService (com.hazelcast.spi.discovery.impl.DefaultDiscoveryService)1 DiscoveryService (com.hazelcast.spi.discovery.integration.DiscoveryService)1 ArrayList (java.util.ArrayList)1 Node (org.w3c.dom.Node)1