protected JestClient createJestClient(Map<String, String> config, String indexName, String defaultIndexName) {
        String host = config.get("client.host"); //$NON-NLS-1$
        String port = config.get("client.port"); //$NON-NLS-1$
        String protocol = config.get("client.protocol"); //$NON-NLS-1$
        String initialize = config.get("client.initialize"); //$NON-NLS-1$

        if (initialize == null) {
            initialize = "true"; //$NON-NLS-1$
        }

        if (StringUtils.isBlank(host)) {
            throw new RuntimeException("Missing client.host configuration for ESRegistry."); //$NON-NLS-1$
        }
        if (StringUtils.isBlank(port)) {
            throw new RuntimeException("Missing client.port configuration for ESRegistry."); //$NON-NLS-1$
        }
        if (StringUtils.isBlank(protocol)) {
            protocol = "http"; //$NON-NLS-1$
        }
        
        String clientKey = "jest:" + host + ':' + port + '/' + indexName; //$NON-NLS-1$
        synchronized (clients) {
            if (clients.containsKey(clientKey)) {
                return clients.get(clientKey);
            } else {
                StringBuilder builder = new StringBuilder();
                builder.append(protocol);
                builder.append("://"); //$NON-NLS-1$
                builder.append(host);
                builder.append(":"); //$NON-NLS-1$
                builder.append(String.valueOf(port));
                String connectionUrl = builder.toString();

                JestClientFactory factory = new JestClientFactory();
                Builder httpClientConfig = new HttpClientConfig.Builder(connectionUrl);
                updateHttpConfig(httpClientConfig, config);
                factory.setHttpClientConfig(httpClientConfig.build());
                updateJestClientFactory(factory, config);
                
                JestClient client = factory.getObject();
                clients.put(clientKey, client);
                if ("true".equals(initialize)) { //$NON-NLS-1$
                    initializeClient(client, indexName, defaultIndexName);
                }
                return client;
            }
        }
    }
protected JestClient createJestClient ( Map < String , String > config , String indexName , String defaultIndexName ) { String host = config . get ( "client.host" ) ; String port = config . get ( "client.port" ) ; String protocol = config . get ( "client.protocol" ) ; String initialize = config . get ( "client.initialize" ) ; if ( initialize == null ) { initialize = "true" ; } if ( StringUtils . isBlank ( host ) ) { throw new RuntimeException ( "Missing client.host configuration for ESRegistry." ) ; } if ( StringUtils . isBlank ( port ) ) { throw new RuntimeException ( "Missing client.port configuration for ESRegistry." ) ; } if ( StringUtils . isBlank ( protocol ) ) { protocol = "http" ; } String clientKey = "jest:" + host + ':' + port + '/' + indexName ; synchronized ( clients ) { if ( clients . containsKey ( clientKey ) ) { return clients . get ( clientKey ) ; } else { StringBuilder builder = new StringBuilder ( ) ; builder . append ( protocol ) ; builder . append ( "://" ) ; builder . append ( host ) ; builder . append ( ":" ) ; builder . append ( String . valueOf ( port ) ) ; String connectionUrl = builder . toString ( ) ; JestClientFactory factory = new JestClientFactory ( ) ; Builder httpClientConfig = new HttpClientConfig . Builder ( connectionUrl ) ; updateHttpConfig ( httpClientConfig , config ) ; factory . setHttpClientConfig ( httpClientConfig . build ( ) ) ; updateJestClientFactory ( factory , config ) ; JestClient client = factory . getObject ( ) ; clients . put ( clientKey , client ) ; if ( "true" . equals ( initialize ) ) { initializeClient ( client , indexName , defaultIndexName ) ; } return client ; } } }
Creates a transport client from a configuration map.
@param config the configuration
@param indexName the name of the index
@param defaultIndexName the default index name
@return the ES client