Search in sources :

Example 1 with Cluster

use of com.yahoo.vespa.http.client.config.Cluster in project vespa by vespa-engine.

the class CommandLineArgumentsTest method testMultiHost.

@Test
public void testMultiHost() {
    add("file", "fileValue.json");
    add("port", "1234");
    add("host", "hostValue1,hostValue2,      hostValue3");
    CommandLineArguments arguments = CommandLineArguments.build(asArray());
    SessionParams params = arguments.createSessionParams(true);
    assertThat(params.getClusters().size(), is(3));
    final Set<String> hosts = new HashSet<>();
    for (Cluster cluster : params.getClusters()) {
        assertThat(cluster.getEndpoints().size(), is(1));
        hosts.add(cluster.getEndpoints().get(0).getHostname());
        assertThat(cluster.getEndpoints().get(0).getPort(), is(1234));
    }
    assertThat(hosts, hasItem("hostValue1"));
    assertThat(hosts, hasItem("hostValue2"));
    assertThat(hosts, hasItem("hostValue3"));
}
Also used : SessionParams(com.yahoo.vespa.http.client.config.SessionParams) Cluster(com.yahoo.vespa.http.client.config.Cluster) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with Cluster

use of com.yahoo.vespa.http.client.config.Cluster in project vespa by vespa-engine.

the class QueueBoundsTest method requireThatFullIntermediateQueueBlocksAndUnblocks.

@Test
public void requireThatFullIntermediateQueueBlocksAndUnblocks() throws Exception {
    V3MockParsingRequestHandler slowHandler = new V3MockParsingRequestHandler("B", HttpServletResponse.SC_OK, V3MockParsingRequestHandler.Scenario.DELAYED_RESPONSE);
    try (Server serverA = new Server(new V3MockParsingRequestHandler("A"), 0);
        Server serverB = new Server(slowHandler, 0);
        SessionImpl session = new SessionImpl(new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverA.getPort(), false)).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("localhost", serverB.getPort(), false)).build()).setFeedParams(new FeedParams.Builder().setMaxChunkSizeBytes(1).build()).setConnectionParams(new ConnectionParams.Builder().setNumPersistentConnectionsPerEndpoint(1).build()).setClientQueueSize(// 3  per cluster
        6).build(), SessionFactory.createTimeoutExecutor())) {
        FeederThread feeder = new FeederThread(session);
        try {
            feeder.start();
            assertFeedNotBlocking(feeder, 0);
            assertFeedNotBlocking(feeder, 1);
            assertFeedNotBlocking(feeder, 2);
            // A input queue size now: 3
            // B input queue size now: 3
            // feeder thread not blocked
            // intermediate result queue size now: 3
            // result queue size now: 0
            assertResultQueueSize(session, 0, 60, TimeUnit.SECONDS);
            assertIncompleteResultQueueSize(session, 3, 60, TimeUnit.SECONDS);
            assertResultQueueSize(session, 0, 60, TimeUnit.SECONDS);
            assertIncompleteResultQueueSize(session, 3, 60, TimeUnit.SECONDS);
            // server B is slow, server A is fast
            // A input queue size now: 0
            // B input queue size now: 2, IOThread writing 1 and blocked because of no response yet
            // feeder thread still not blocked
            // intermediate result queue size now: 3
            // result queue size now: 0
            assertResultQueueSize(session, 0, 60, TimeUnit.SECONDS);
            assertIncompleteResultQueueSize(session, 3, 60, TimeUnit.SECONDS);
            CountDownLatch lastPostFeed = assertFeedBlocking(feeder, 3);
            // A input queue size now: 0
            // B input queue size now: 2, IOThread writing 1 and blocked because of no response yet
            // feeder thread blocking with 1 op
            // intermediate result queue size now: 3
            // result queue size now: 0
            slowHandler.poke();
            // A input queue size now: 0
            // B input queue size now: 2, IOThread writing 1 and blocked because of no response again
            // feeder thread unblocked
            // intermediate result queue size now: 3
            // result queue size now: 1
            lastPostFeed.await(60, TimeUnit.SECONDS);
            assertThat(lastPostFeed.getCount(), equalTo(0L));
            slowHandler.pokeAllAndUnblockFromNowOn();
            // A input queue size now: 0
            // B input queue size now: 0, IOThread not blocked
            // feeder thread unblocked
            // intermediate result queue size now: 0
            // result queue size now: 4
            assertResultQueueSize(session, 4, 60, TimeUnit.SECONDS);
        } finally {
            slowHandler.pokeAllAndUnblockFromNowOn();
            feeder.stop();
        }
    }
}
Also used : SessionParams(com.yahoo.vespa.http.client.config.SessionParams) V3MockParsingRequestHandler(com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler) Cluster(com.yahoo.vespa.http.client.config.Cluster) SessionImpl(com.yahoo.vespa.http.client.core.api.SessionImpl) CountDownLatch(java.util.concurrent.CountDownLatch) FeedParams(com.yahoo.vespa.http.client.config.FeedParams) Test(org.junit.Test)

Aggregations

Cluster (com.yahoo.vespa.http.client.config.Cluster)2 SessionParams (com.yahoo.vespa.http.client.config.SessionParams)2 Test (org.junit.Test)2 FeedParams (com.yahoo.vespa.http.client.config.FeedParams)1 SessionImpl (com.yahoo.vespa.http.client.core.api.SessionImpl)1 V3MockParsingRequestHandler (com.yahoo.vespa.http.client.handlers.V3MockParsingRequestHandler)1 HashSet (java.util.HashSet)1 CountDownLatch (java.util.concurrent.CountDownLatch)1