Package org.elasticsearch.client.transport

Examples of org.elasticsearch.client.transport.TransportClient


    // Connect as TransportClient (proxy of the cluster)
    Settings settings = ImmutableSettings.settingsBuilder()
        .put("cluster.name", clusterName)
        .put("client.transport.sniff", true)
        .build();
    TransportClient transportClient = new TransportClient(settings);
    // Add specified TransportAddresses
    for (String host : hosts.split(",")) {
      String[] params = host.split(":");
      String hostname = params[0];
      int port = (params.length == 2) ? Integer.valueOf(params[1]) : 9300;
      transportClient.addTransportAddress(new InetSocketTransportAddress(hostname, port));
    }
    return transportClient;
  }
View Full Code Here


            Settings settings = ImmutableSettings.settingsBuilder()
                    .put("cluster.name", clusterName)
                    .build();

            TransportClient transportClient = new TransportClient(settings);
            for (String esHostName : hostNames) {
                LOG.info("Adding TransportClient: {}", esHostName);
                transportClient = transportClient.addTransportAddress(new InetSocketTransportAddress(esHostName,
                        DEFAULT_ELASTICSEARCH_PORT));
            }
            client = transportClient;
        }
View Full Code Here

    @Override
    public void open() {
        Monitors.registerObject(clusterName, this);

        if (client == null) {
            client = new TransportClient(settings);
            if (discoveryClient != null) {
                getServerListFromDiscovery(addressList, discoveryClient, client);
            } else {
                for (String address : addressList) {
                    String[] host_port = address.split(":");
View Full Code Here

      searchClient = searchNode.client();
      if (!existsIndex(Config.APP_NAME_NS)) {
        createIndex(Config.APP_NAME_NS);
      }
    } else {
      searchClient = new TransportClient();
        ((TransportClient) searchClient).addTransportAddress(
            new InetSocketTransportAddress("localhost", 9300));
    }

    Para.addDestroyListener(new Para.DestroyListener() {
View Full Code Here

      throw new NullPointerException("transportClientSettings");
    }
    if (index == null) {
      throw new NullPointerException("index");
    }
    _client = new TransportClient(transportClientSettings);
    _index = index;
  }
View Full Code Here

            } else {
                settings.put("client.transport.ignore_cluster_name", true);
            }
            log.debug("Transport sniffing enabled: {}", config.getBoolean(CLIENT_SNIFF_KEY, CLIENT_SNIFF_DEFAULT));
            settings.put("client.transport.sniff", config.getBoolean(CLIENT_SNIFF_KEY, CLIENT_SNIFF_DEFAULT));
            TransportClient tc = new TransportClient(settings.build());
            for (String host : config.getStringArray(GraphDatabaseConfiguration.HOSTNAME_KEY)) {
                String[] hostparts = host.split(":");
                String hostname = hostparts[0];
                int hostport = HOST_PORT_DEFAULT;
                if (hostparts.length == 2) hostport = Integer.parseInt(hostparts[1]);
                log.info("Configured remote host: {} : {}", hostname, hostport);
                tc.addTransportAddress(new InetSocketTransportAddress(hostname, hostport));
            }
            client = tc;
            node = null;
        }
View Full Code Here

            }
            else
            {
                if (client == null)
                {
                    client = new TransportClient();
                }
                for (Node node : nodes)
                {
                    Properties properties = node.getProperties();
                    if (properties != null)
View Full Code Here

       
        builder.put("client.transport.sniff", true);
       
        Settings settings = builder.build();
      
        org.elasticsearch.client.Client client = new TransportClient(settings);

        for (String h : hosts)
        {
            ((TransportClient) client).addTransportAddress(new InetSocketTransportAddress(h, new Integer(port)));
        }
View Full Code Here

  @Test
  public void test_transport_client() {
    Client client = checkClient();
        assertThat(client, instanceOf(org.elasticsearch.client.transport.TransportClient.class));

        TransportClient tClient = (TransportClient) client;
        ImmutableList<TransportAddress> adresses = tClient.transportAddresses();
        assertThat(adresses, not(emptyCollectionOf(TransportAddress.class)));
        assertThat(adresses.size(), is(2));
  }
View Full Code Here

        if (null != this.properties) {
            builder.put(this.properties);
        }

    TransportClient client = new TransportClient(builder.build());

    for (int i = 0; i < esNodes.length; i++) {
      client.addTransportAddress(toAddress(esNodes[i]));
    }

    return client;
  }
View Full Code Here

TOP

Related Classes of org.elasticsearch.client.transport.TransportClient

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.