Package com.hazelcast.client.config

Examples of com.hazelcast.client.config.ClientNetworkConfig


    private volatile boolean live = false;

    public ClientConnectionManagerImpl(HazelcastClient client, LoadBalancer loadBalancer) {
        this.client = client;
        final ClientConfig config = client.getClientConfig();
        final ClientNetworkConfig networkConfig = config.getNetworkConfig();
        final GroupConfig groupConfig = config.getGroupConfig();
        final ClientSecurityConfig securityConfig = config.getSecurityConfig();
        Credentials c = securityConfig.getCredentials();
        if (c == null) {
            final String credentialsClassname = securityConfig.getCredentialsClassname();
            //todo: Should be moved to a reflection utility.
            if (credentialsClassname != null) {
                try {
                    c = ClassLoaderUtil.newInstance(config.getClassLoader(), credentialsClassname);
                } catch (Exception e) {
                    throw ExceptionUtil.rethrow(e);
                }
            }
        }
        if (c == null) {
            c = new UsernamePasswordCredentials(groupConfig.getName(), groupConfig.getPassword());
        }

        this.smartRouting = networkConfig.isSmartRouting();
        this.executionService = (ClientExecutionServiceImpl) client.getClientExecutionService();
        this.credentials = c;
        router = new Router(loadBalancer);
        inSelector = new ClientInSelectorImpl(client.getThreadGroup());
        outSelector = new ClientOutSelectorImpl(client.getThreadGroup());
        //init socketInterceptor
        SocketInterceptorConfig sic = networkConfig.getSocketInterceptorConfig();
        SocketInterceptor implementation = null;
        if (sic != null && sic.isEnabled()) {
            implementation = (SocketInterceptor) sic.getImplementation();
            if (implementation == null && sic.getClassName() != null) {
                try {
                    implementation = (SocketInterceptor) Class.forName(sic.getClassName()).newInstance();
                } catch (Throwable e) {
                    logger.severe("SocketInterceptor class cannot be instantiated!" + sic.getClassName(), e);
                }
            }
        }

        socketInterceptor = implementation;
        if (socketInterceptor != null) {
            logger.info("SocketInterceptor is enabled");
            socketInterceptor.init(sic.getProperties());
        }

        socketOptions = networkConfig.getSocketOptions();

        SSLConfig sslConfig = networkConfig.getSSLConfig(); //ioService.getSSLConfig(); TODO
        if (sslConfig != null && sslConfig.isEnabled()) {
            socketChannelWrapperFactory = new SSLSocketChannelWrapperFactory(sslConfig);
            logger.info("SSL is enabled");
        } else {
            socketChannelWrapperFactory = new DefaultSocketChannelWrapperFactory();
View Full Code Here


        if (ownerConnection != null) {
            return ownerConnection.getRemoteEndpoint();
        }

        synchronized (ownerConnectionLock) {
            ClientNetworkConfig networkConfig = client.getClientConfig().getNetworkConfig();
            int connectionAttemptLimit = networkConfig.getConnectionAttemptLimit();
            int connectionAttemptPeriod = networkConfig.getConnectionAttemptPeriod();
            int waitTime = connectionAttemptLimit * connectionAttemptPeriod * 2;

            while (ownerConnection == null) {
                try {
                    ownerConnectionLock.wait(waitTime);
View Full Code Here

                logger.warning("Could not load client configuration: " + configResourcePath, e);
            }
        }
        if (clientConfig == null) {
            clientConfig = new ClientConfig();
            final ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
            networkConfig.setSmartRouting(true);
            networkConfig.setRedoOperation(true);
            networkConfig.setConnectionAttemptLimit(10);
        }
        if (group != null) {
            clientConfig.getGroupConfig().setName(group);
        }
        if (pass != null) {
View Full Code Here

                c.close();
            }
        }

        private ClientConnection connectToOne() throws Exception {
            final ClientNetworkConfig networkConfig = getClientConfig().getNetworkConfig();
            final int connectionAttemptLimit = networkConfig.getConnectionAttemptLimit();
            final int connectionAttemptPeriod = networkConfig.getConnectionAttemptPeriod();
            int attempt = 0;
            Throwable lastError = null;
            while (true) {
                final long nextTry = Clock.currentTimeMillis() + connectionAttemptPeriod;
                final Collection<InetSocketAddress> socketAddresses = getSocketAddresses();
View Full Code Here

            c.close();
        }
    }

    private ClientConnection connectToOne() throws Exception {
        final ClientNetworkConfig networkConfig = client.getClientConfig().getNetworkConfig();
        final int connectionAttemptLimit = networkConfig.getConnectionAttemptLimit();
        final int connectionAttemptPeriod = networkConfig.getConnectionAttemptPeriod();
        int attempt = 0;
        Throwable lastError = null;
        while (true) {
            final long nextTry = Clock.currentTimeMillis() + connectionAttemptPeriod;
            final Collection<InetSocketAddress> socketAddresses = getSocketAddresses();
View Full Code Here

                                       LoadBalancer loadBalancer,
                                       AddressTranslator addressTranslator) {
        this.client = client;
        this.addressTranslator = addressTranslator;
        final ClientConfig config = client.getClientConfig();
        final ClientNetworkConfig networkConfig = config.getNetworkConfig();

        connectionTimeout = networkConfig.getConnectionTimeout();

        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);

        int failedHeartbeat = clientProperties.getMaxFailedHeartbeatCount().getInteger();
        maxFailedHeartbeatCount = failedHeartbeat > 0 ? failedHeartbeat
                : Integer.parseInt(PROP_MAX_FAILED_HEARTBEAT_COUNT_DEFAULT);

        smartRouting = networkConfig.isSmartRouting();
        executionService = (ClientExecutionServiceImpl) client.getClientExecutionService();
        credentials = initCredentials(config);
        router = new Router(loadBalancer);
        inSelector = new ClientInSelectorImpl(client.getThreadGroup());
        outSelector = new ClientOutSelectorImpl(client.getThreadGroup());

        SocketInterceptorConfig sic = networkConfig.getSocketInterceptorConfig();
        socketInterceptor = initSocketInterceptor(sic);

        socketOptions = networkConfig.getSocketOptions();


        socketChannelWrapperFactory = initSocketChannel(networkConfig);
    }
View Full Code Here

        if (ownerConnection != null) {
            return ownerConnection.getRemoteEndpoint();
        }

        synchronized (ownerConnectionLock) {
            ClientNetworkConfig networkConfig = client.getClientConfig().getNetworkConfig();
            int connectionAttemptLimit = networkConfig.getConnectionAttemptLimit();
            int connectionAttemptPeriod = networkConfig.getConnectionAttemptPeriod();
            int waitTime = connectionAttemptLimit * connectionAttemptPeriod * 2;

            while (ownerConnection == null) {
                try {
                    ownerConnectionLock.wait(waitTime);
View Full Code Here

    @Test
    public void testAwsClientConfig() {
        assertNotNull(client4);
        ClientConfig config = client4.getClientConfig();
        final ClientNetworkConfig networkConfig = config.getNetworkConfig();

        final ClientAwsConfig awsConfig = networkConfig.getAwsConfig();
        assertFalse(awsConfig.isEnabled());
        assertTrue(awsConfig.isInsideAws());
        assertEquals("sample-access-key", awsConfig.getAccessKey());
        assertEquals("sample-secret-key", awsConfig.getSecretKey());
        assertEquals("sample-region", awsConfig.getRegion());
View Full Code Here

                LOGGER.warning("Could not load client configuration: " + configResourcePath, e);
            }
        }
        if (clientConfig == null) {
            clientConfig = new ClientConfig();
            final ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
            networkConfig.setSmartRouting(true);
            networkConfig.setRedoOperation(true);
            networkConfig.setConnectionAttemptLimit(CONNECTION_ATTEMPT_LIMIT);
        }
        return clientConfig;
    }
View Full Code Here

                LOGGER.warning("Could not load client configuration: " + configResourcePath, e);
            }
        }
        if (clientConfig == null) {
            clientConfig = new ClientConfig();
            final ClientNetworkConfig networkConfig = clientConfig.getNetworkConfig();
            networkConfig.setSmartRouting(true);
            networkConfig.setRedoOperation(true);
            networkConfig.setConnectionAttemptLimit(CONNECTION_ATTEMPT_LIMIT);
        }
        return clientConfig;
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.client.config.ClientNetworkConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.