Package com.tinkerpop.gremlin.driver

Examples of com.tinkerpop.gremlin.driver.Client


            final List<Thread> threads = IntStream.range(0, clients).mapToObj(t -> new Thread(() -> {
                try {
                    final CountDownLatch latch = new CountDownLatch(requests);

                    final Client client = cluster.connect();
                    client.init();

                    barrier.await();
                    final long start = System.nanoTime();

                    System.out.println("Executing at [" + t + "]:" + start);

                    IntStream.range(0, requests).forEach(i -> {
                        client.submitAsync("1+1").thenAccept(r -> r.all()).thenRun(latch::countDown);
                    });

                    latch.await();

                    final long end = System.nanoTime();
View Full Code Here


        final Serializers mimeType = mimes[rand.nextInt(3)];
        System.out.println(mimeType);
        final Cluster cluster = Cluster.build("localhost")
                .serializer(mimeType)
                .create();
        final Client client = cluster.connect();
        assertEquals("2", client.submit("1+1").stream().map(Result::getString).findAny().orElse("invalid"));
    }
View Full Code Here

    public static void after() {
        cluster.close();
    }

    private void tryWebSocketGremlin() throws Exception {
        final Client client = cluster.connect();
        assertEquals("2", client.submit("1+1").stream().map(Result::getString).findAny().orElse("invalid"));
    }
View Full Code Here

    }

    @Test
    public void shouldProcessRequestsOutOfOrder() throws Exception {
        final Cluster cluster = Cluster.open();
        final Client client = cluster.connect();

        final ResultSet rsFive = client.submit("Thread.sleep(5000);'five'");
        final ResultSet rsZero = client.submit("'zero'");

        final CompletableFuture<List<Result>> futureFive = rsFive.all();
        final CompletableFuture<List<Result>> futureZero = rsZero.all();

        final long start = System.nanoTime();
View Full Code Here

    }

    @Test
    public void shouldWaitForAllResultsToArrive() throws Exception {
        final Cluster cluster = Cluster.open();
        final Client client = cluster.connect();

        final AtomicInteger checked = new AtomicInteger(0);
        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
        while (!results.allItemsAvailable()) {
            assertTrue(results.getAvailableItemCount() < 10);
            checked.incrementAndGet();
            Thread.sleep(100);
        }
View Full Code Here

    }

    @Test
    public void shouldStream() throws Exception {
        final Cluster cluster = Cluster.open();
        final Client client = cluster.connect();

        final ResultSet results = client.submit("[1,2,3,4,5,6,7,8,9]");
        final AtomicInteger counter = new AtomicInteger(0);
        results.stream().map(i -> i.get(Integer.class) * 2).forEach(i -> assertEquals(counter.incrementAndGet() * 2, Integer.parseInt(i.toString())));

        cluster.close();
    }
View Full Code Here

    }

    @Test
    public void shouldHandleRequestSentThatNeverReturns() throws Exception {
        final Cluster cluster = Cluster.open();
        final Client client = cluster.connect();

        final ResultSet results = client.submit("'should-not-ever-get-back-coz-we-killed-the-server'");

        stopServer();

        assertEquals(0, results.getAvailableItemCount());
View Full Code Here

    }

    @Test
    public void shouldFailWithBadServerSideSerialization() throws Exception {
        final Cluster cluster = Cluster.open();
        final Client client = cluster.connect();

        final ResultSet results = client.submit("TinkerFactory.createClassic()");

        try {
            final CompletableFuture<List<Result>> all = results.all();
            all.join();
            fail();
View Full Code Here

        m.put("serializeResultToString", true);
        final KryoMessageSerializerV1d0 serializer = new KryoMessageSerializerV1d0();
        serializer.configure(m);

        final Cluster cluster = Cluster.build().serializer(serializer).create();
        final Client client = cluster.connect();

        final ResultSet resultSet = client.submit("TinkerFactory.createClassic()");
        final List<Result> results = resultSet.all().join();
        assertEquals(1, results.size());
        assertEquals("tinkergraph[vertices:6 edges:6]", results.get(0).getString());

        cluster.close();
View Full Code Here

        m.put("custom", Arrays.asList(String.format("%s;%s", JsonBuilder.class.getCanonicalName(), JsonBuilderKryoSerializer.class.getCanonicalName())));
        final KryoMessageSerializerV1d0 serializer = new KryoMessageSerializerV1d0();
        serializer.configure(m);

        final Cluster cluster = Cluster.build().serializer(serializer).create();
        final Client client = cluster.connect();

        final List<Result> json = client.submit("b = new JsonBuilder();b.people{person {fname 'stephen'\nlname 'mallette'}};b").all().join();
        assertEquals("{\"people\":{\"person\":{\"fname\":\"stephen\",\"lname\":\"mallette\"}}}", json.get(0).getString());
        cluster.close();
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.driver.Client

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.