public void testPickingUpChangesInDiscoveryNode() {
    String nodeName =
        internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false));

    TransportClient client = (TransportClient) internalCluster().client(nodeName);
    assertThat(client.connectedNodes().get(0).dataNode(), equalTo(false));
  }
  public void testWithSniffing() throws Exception {
    try (TransportClient client =
        TransportClient.builder()
            .settings(
                Settings.builder()
                    .put("client.transport.sniff", true)
                    .put("cluster.name", "cluster1")
                    .put("node.name", "transport_client_" + this.getTestName() + "_1")
                    .put("client.transport.nodes_sampler_interval", "1s")
                    .put(HEADER_SETTINGS)
                    .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
                    .build())
            .addPlugin(InternalTransportService.TestPlugin.class)
            .build()) {
      client.addTransportAddress(address);

      InternalTransportService service =
          (InternalTransportService) client.injector.getInstance(TransportService.class);

      if (!service.clusterStateLatch.await(5, TimeUnit.SECONDS)) {
        fail("takes way too long to get the cluster state");
      }

      assertThat(client.connectedNodes().size(), is(1));
      assertThat(client.connectedNodes().get(0).getAddress(), is((TransportAddress) address));
    }
  }
 /*
  * (non-Javadoc)
  *
  * @see com.datatorrent.lib.db.Connectable#isConnected()
  */
 @Override
 public boolean isConnected() {
   if (client != null) {
     return client.connectedNodes().size() != 0;
   }
   return false;
 }
  @Test
  public void testWithSniffing() throws Exception {
    TransportClient client =
        new TransportClient(
            ImmutableSettings.builder()
                .put("client.transport.sniff", true)
                .put("cluster.name", "cluster1")
                .put("node.name", "transport_client_" + this.getTestName() + "_1")
                .put("client.transport.nodes_sampler_interval", "1s")
                .put(
                    TransportModule.TRANSPORT_SERVICE_TYPE_KEY,
                    InternalTransportService.class.getName())
                .put(HEADER_SETTINGS)
                .build());
    try {
      client.addTransportAddress(address);

      InternalTransportService service =
          (InternalTransportService) client.injector.getInstance(TransportService.class);

      if (!service.clusterStateLatch.await(5, TimeUnit.SECONDS)) {
        fail("takes way too long to get the cluster state");
      }

      assertThat(client.connectedNodes().size(), is(1));
      assertThat(client.connectedNodes().get(0).getAddress(), is((TransportAddress) address));
    } finally {
      client.close();
    }
  }
 protected void buildClient() throws Exception {
   client = TransportClient.builder().settings(settings()).build();
   Assert.hasText(clusterNodes, "[Assertion failed] clusterNodes settings missing.");
   for (String clusterNode : split(clusterNodes, COMMA)) {
     String hostName = substringBeforeLast(clusterNode, COLON);
     String port = substringAfterLast(clusterNode, COLON);
     Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
     Assert.hasText(port, "[Assertion failed] missing port in 'clusterNodes'");
     logger.info("adding transport node : " + clusterNode);
     client.addTransportAddress(
         new InetSocketTransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
   }
   client.connectedNodes();
 }
 private LogController() {
   checkpoint = new Checkpoint();
   rec_map = new HashMap<Long, LogLine>();
   idx_map = new HashMap<Long, String>();
   client =
       new TransportClient()
           .addTransportAddress(new InetSocketTransportAddress(HOST, CLINET_PORT));
   gson = new Gson();
   if (0 == client.connectedNodes().size()) {
     System.out.println(PROMPT + "Connect to elasticsearch server failed!");
     System.out.printf(
         PROMPT + "Please check whether elastic is running at %s:%d\n", HOST, CLINET_PORT);
     System.exit(0);
   }
   // For test
   try {
     log_writer = new PrintWriter(WRITEPAHT, "UTF-8");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }