Examples of TransportClient


Examples of org.elasticsearch.client.transport.TransportClient

        Node[] nodes = new Node[3];
        for (int i = 0; i < nodes.length; i++) {
            nodes[i] = NodeBuilder.nodeBuilder().node();
        }

        final TransportClient client = new TransportClient()
                .addTransportAddress(new InetSocketTransportAddress("localhost", 9300))
                .addTransportAddress(new InetSocketTransportAddress("localhost", 9301))
                .addTransportAddress(new InetSocketTransportAddress("localhost", 9302));

        final AtomicBoolean done = new AtomicBoolean();
        final AtomicLong indexed = new AtomicLong();
        final CountDownLatch latch = new CountDownLatch(1);
        Thread indexer = new Thread(new Runnable() {
            @Override public void run() {
                while (!done.get()) {
                    try {
                        client.prepareIndex("test", "type").setSource("field", "value").execute().actionGet();
                        indexed.incrementAndGet();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                latch.countDown();
            }
        });
        indexer.start();

        for (int i = 0; i < 100; i++) {
            int index = i % nodes.length;
            nodes[index].close();

            ClusterHealthResponse health = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
            if (health.timedOut()) {
                System.err.println("timed out on health");
            }

            nodes[index] = NodeBuilder.nodeBuilder().node();

            health = client.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
            if (health.timedOut()) {
                System.err.println("timed out on health");
            }
        }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

        int numberOfDocs = 1;

        Client client;
        Node node = null;
        if (true) {
            client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
        } else {
            node = NodeBuilder.nodeBuilder().client(true).node();
            client = node.client();
        }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

*/
public class TransportClientMoreLikeThisActionTests extends MoreLikeThisActionTests {

    @Override protected Client getClient1() {
        TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
        TransportClient client = new TransportClient(settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .put("discovery.enabled", false).build());
        client.addTransportAddress(server1Address);
        return client;
    }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

        return client;
    }

    @Override protected Client getClient2() {
        TransportAddress server1Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
        TransportClient client = new TransportClient(settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .put("discovery.enabled", false).build());
        client.addTransportAddress(server1Address);
        return client;
    }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

*/
public class TransportClientSniffDocumentActionsTests extends DocumentActionsTests {

    @Override protected Client getClient1() {
        TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
        TransportClient client = new TransportClient(settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .put("client.transport.sniff", true).build());
        client.addTransportAddress(server1Address);
        return client;
    }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

        return client;
    }

    @Override protected Client getClient2() {
        TransportAddress server2Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
        TransportClient client = new TransportClient(settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .put("client.transport.sniff", true).build());
        client.addTransportAddress(server2Address);
        return client;
    }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

    /*@Test*/

    public void testWithDiscovery() throws Exception {
        startNode("server1");
        client = new TransportClient(ImmutableSettings.settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .put("discovery.enabled", true)
                .build());
        // wait a bit so nodes will be discovered
        Thread.sleep(1000);
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

*/
public class ClientTransportTwoNodesSearchTests extends TransportTwoNodesSearchTests {

    @Override protected Client getClient() {
        TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
        TransportClient client = new TransportClient(ImmutableSettings
                .settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .build());
        client.addTransportAddress(server1Address);
        return client;
    }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

*/
public class TransportClientDocumentActionsTests extends DocumentActionsTests {

    @Override protected Client getClient1() {
        TransportAddress server1Address = ((InternalNode) node("server1")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
        TransportClient client = new TransportClient(settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .put("client.transport.sniff", false).build());
        client.addTransportAddress(server1Address);
        return client;
    }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient

        return client;
    }

    @Override protected Client getClient2() {
        TransportAddress server2Address = ((InternalNode) node("server2")).injector().getInstance(TransportService.class).boundAddress().publishAddress();
        TransportClient client = new TransportClient(settingsBuilder()
                .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
                .put("client.transport.sniff", false).build());
        client.addTransportAddress(server2Address);
        return client;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.