Search in sources :

Example 16 with TransportClient

use of org.elasticsearch.client.transport.TransportClient in project flink by apache.

the class Elasticsearch2ApiCallBridge method createClient.

@Override
public Client createClient(Map<String, String> clientConfig) {
    Settings settings = Settings.settingsBuilder().put(clientConfig).build();
    TransportClient transportClient = TransportClient.builder().settings(settings).build();
    for (TransportAddress address : ElasticsearchUtils.convertInetSocketAddresses(transportAddresses)) {
        transportClient.addTransportAddress(address);
    }
    // verify that we actually are connected to a cluster
    if (transportClient.connectedNodes().isEmpty()) {
        throw new RuntimeException("Elasticsearch client is not connected to any Elasticsearch nodes!");
    }
    if (LOG.isInfoEnabled()) {
        LOG.info("Created Elasticsearch TransportClient with connected nodes {}", transportClient.connectedNodes());
    }
    return transportClient;
}
Also used : TransportClient(org.elasticsearch.client.transport.TransportClient) TransportAddress(org.elasticsearch.common.transport.TransportAddress) Settings(org.elasticsearch.common.settings.Settings)

Example 17 with TransportClient

use of org.elasticsearch.client.transport.TransportClient in project storm by apache.

the class StormElasticSearchClient method construct.

public Client construct() {
    Settings settings = esConfig.toBasicSettings();
    TransportClient transportClient = new TransportClient(settings);
    addTransportAddresses(transportClient);
    return transportClient;
}
Also used : TransportClient(org.elasticsearch.client.transport.TransportClient) Settings(org.elasticsearch.common.settings.Settings)

Example 18 with TransportClient

use of org.elasticsearch.client.transport.TransportClient in project elasticsearch by elastic.

the class TransportClientBenchmark method client.

@Override
protected TransportClient client(String benchmarkTargetHost) throws Exception {
    TransportClient client = new PreBuiltTransportClient(Settings.EMPTY, NoopPlugin.class);
    client.addTransportAddress(new TransportAddress(InetAddress.getByName(benchmarkTargetHost), 9300));
    return client;
}
Also used : TransportClient(org.elasticsearch.client.transport.TransportClient) PreBuiltTransportClient(org.elasticsearch.transport.client.PreBuiltTransportClient) PreBuiltTransportClient(org.elasticsearch.transport.client.PreBuiltTransportClient) TransportAddress(org.elasticsearch.common.transport.TransportAddress)

Example 19 with TransportClient

use of org.elasticsearch.client.transport.TransportClient in project wonderdog by infochimps-labs.

the class ElasticSearchStreamingInputFormat method startTransportClient.

//
// == Connecting to Elasticsearch and Querying ==
// 
private void startTransportClient(JobConf conf) {
    this.client = new TransportClient();
    Map<String, String> settings = parsedSettings(conf);
    String host = hostname(settings);
    if (host.toString().length() == 0) {
        System.exit(1);
    }
    LOG.info("Attempting to connect to Elasticsearch node at " + host + ":9300");
    this.client = new TransportClient().addTransportAddress(new InetSocketTransportAddress(host, 9300));
    LOG.info("Connected to Elasticsearch cluster");
}
Also used : TransportClient(org.elasticsearch.client.transport.TransportClient) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress)

Example 20 with TransportClient

use of org.elasticsearch.client.transport.TransportClient in project wonderdog by infochimps-labs.

the class ElasticSearchStreamingRecordWriter method buildTransportClient.

/**
       Build a transport client that will connect to some
       Elasticsearch node.
       
     */
private Client buildTransportClient() {
    LOG.info("Connecting transport client to " + transportHost + ":" + Integer.toString(transportPort));
    Settings settings = ImmutableSettings.settingsBuilder().put("client.transport.ignore_cluster_name", "true").build();
    return new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress(transportHost, transportPort));
}
Also used : TransportClient(org.elasticsearch.client.transport.TransportClient) InetSocketTransportAddress(org.elasticsearch.common.transport.InetSocketTransportAddress) ImmutableSettings(org.elasticsearch.common.settings.ImmutableSettings) Settings(org.elasticsearch.common.settings.Settings)

Aggregations

TransportClient (org.elasticsearch.client.transport.TransportClient)31 Settings (org.elasticsearch.common.settings.Settings)17 InetSocketTransportAddress (org.elasticsearch.common.transport.InetSocketTransportAddress)15 TransportAddress (org.elasticsearch.common.transport.TransportAddress)8 ImmutableSettings (org.elasticsearch.common.settings.ImmutableSettings)7 PreBuiltTransportClient (org.elasticsearch.transport.client.PreBuiltTransportClient)7 Client (org.elasticsearch.client.Client)5 IOException (java.io.IOException)3 UnknownHostException (java.net.UnknownHostException)3 Test (org.junit.Test)3 Settings (org.sonar.api.config.Settings)3 File (java.io.File)2 String.format (java.lang.String.format)2 InetAddress (java.net.InetAddress)2 Logger (org.apache.log4j.Logger)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Condition (org.assertj.core.api.Condition)2 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)2 BulkRequestBuilder (org.elasticsearch.action.bulk.BulkRequestBuilder)2 Node (org.elasticsearch.node.Node)2