Package org.elasticsearch.client.transport

Examples of org.elasticsearch.client.transport.TransportClient


  public void afterPropertiesSet() throws Exception {
    internalCreateTransportClient();
  }

  private void internalCreateTransportClient() {
    final TransportClient client = new TransportClient();

    if (null != transportAddresses) {
      for (final Entry<String, Integer> address : transportAddresses.entrySet()) {
        if (logger.isInfoEnabled()) {
          logger.info("Adding transport address: " + address.getKey() + " port: "
              + address.getValue());
        }
        client.addTransportAddress(new InetSocketTransportAddress(address.getKey(),
            address.getValue()));
      }
    }

  }
View Full Code Here


        client = createClient(ElasticNode.CLUSTER, url, port);
    }

    public static Client createClient(String cluster, String url, int port) {
        Settings s = ImmutableSettings.settingsBuilder().put("cluster.name", cluster).build();
        TransportClient tmp = new TransportClient(s);
        tmp.addTransportAddress(new InetSocketTransportAddress(url, port));
        return tmp;
    }
View Full Code Here

    Builder globalSettings = ImmutableSettings.settingsBuilder();
    Settings snode = globalSettings.put("cluster.name", _clusterName).build();
   
    Client client = null;
    TransportClient tmp = null;
    try {
      tmp = new TransportClient(snode);
      client = tmp.addTransportAddress(new InetSocketTransportAddress(sHostname, Integer.parseInt(sPort)));
   
      if (!IndexExistsUtils.exists(client.admin().indices(), indexName)) {
        return false;
      }
      client.admin().cluster().health(new ClusterHealthRequest(indexName).waitForYellowStatus()).actionGet();
    }
    catch (Exception e) { // Index not alive...
      return false;
    }
    finally {
      if (null != client) {
        client.close(); // (will also close tmp)
      }
      else if (null != tmp) {
        tmp.close();
      }
    }
    return true;
  }
View Full Code Here

        sHostname = hostPort[0];
        sPort = hostPort[1];

        Builder globalSettings = ImmutableSettings.settingsBuilder();
        Settings snode = globalSettings.put("cluster.name", _clusterName).build();
        TransportClient tmp = new TransportClient(snode);
        _elasticClient = new CrossVersionClient(tmp.addTransportAddress(new InetSocketTransportAddress(sHostname, Integer.parseInt(sPort))));
      }
     
    } //TESTED
    else { // Create a "no data" cluster
     
View Full Code Here

        sHostname = hostPort[0];
        sPort = hostPort[1];
 
        Builder globalSettings = ImmutableSettings.settingsBuilder();
        Settings snode = globalSettings.put("cluster.name", _clusterName).build();
        TransportClient tmp = new TransportClient(snode);
        _elasticClient = new CrossVersionClient(tmp.addTransportAddress(new InetSocketTransportAddress(sHostname, Integer.parseInt(sPort))));
      }
     
    } //TESTED
    else { // Create a "no data" cluster
     
View Full Code Here

        client = createClient(ElasticNode.CLUSTER, url, ElasticNode.PORT);
    }

    public static Client createClient(String cluster, String url, int port) {
        Settings s = ImmutableSettings.settingsBuilder().put("cluster.name", cluster).build();
        TransportClient tmp = new TransportClient(s);
        tmp.addTransportAddress(new InetSocketTransportAddress(url, port));
        return tmp;
    }
View Full Code Here

        List<String> hosts = config.getListProperty(ElasticIOConfig.ELASTICSEARCH_HOSTS);
        String clusterName = config.getStringProperty(ElasticIOConfig.ELASTICSEARCH_CLUSTERNAME);
        Settings settings = ImmutableSettings.settingsBuilder()
                .put("cluster.name", clusterName)
                .build();
        TransportClient tc = new TransportClient(settings);
        for (String host : hosts) {
            String[] parts = host.split(":");
            String address = parts[0];
            Integer port = Integer.parseInt(parts[1]);
            tc.addTransportAddress(new InetSocketTransportAddress(address, port));
        }
        client = tc;
    }
View Full Code Here

            public void run() {
                nodeBuilder().client(true).node().close();
            }
        });

        final Client client = new TransportClient()
                .addTransportAddress(new InetSocketTransportAddress(
                        config.getString("restopengov.elasticsearch-host"),
                        config.getInt("restopengov.elasticsearch-port")));

View Full Code Here

      final Node node = nb.node();
      client = node.client();

    } else {
      Logger.info("Connecting Play! to Elastic Search in Client Mode");
      final TransportClient c = new TransportClient(settings);
      if (Play.configuration.getProperty("elasticsearch.client") == null) {
        throw new RuntimeException("Configuration required - elasticsearch.client when local model is disabled!");
      }
      final String[] hosts = getHosts().trim().split(",");
      boolean done = false;
      for (final String host : hosts) {
        final String[] parts = host.split(":");
        if (parts.length != 2) {
          throw new RuntimeException("Invalid Host: " + host);
        }
        Logger.info("Transport Client - Host: %s Port: %s", parts[0], parts[1]);
        if (Integer.valueOf(parts[1]) == 9200)
          Logger.info("Note: Port 9200 is usually used by the HTTP Transport. You might want to use 9300 instead.");
        c.addTransportAddress(new InetSocketTransportAddress(parts[0], Integer.valueOf(parts[1])));
        done = true;
      }
      if (done == false) {
        throw new RuntimeException("No Hosts Provided for Elastic Search!");
      }
View Full Code Here

     * @param settings the settings used to create the client
     * @return transport client
     */
    @Override
    public TransportClient create(Settings settings) {
        return new TransportClient(settings);
    }
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.