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"));
}
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();
}
}
}
Aggregations