use of com.yahoo.vespa.http.client.config.SessionParams in project vespa by vespa-engine.
the class OperationProcessorTest method testBlockingOfOperationsToSameDocIdWithTwoOperations.
@Test
public void testBlockingOfOperationsToSameDocIdWithTwoOperations() {
SessionParams sessionParams = new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("host")).build()).setConnectionParams(new ConnectionParams.Builder().setEnableV3Protocol(true).build()).build();
OperationProcessor operationProcessor = new OperationProcessor(new IncompleteResultsThrottler(1000, 1000, null, null), (docId, documentResult) -> queue.add(documentResult), sessionParams, null);
operationProcessor.sendDocument(doc1);
operationProcessor.sendDocument(doc1b);
assertThat(queue.size(), is(0));
// Only one operations should be in flight.
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
assertThat(queue.size(), is(1));
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
assertThat(queue.size(), is(2));
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(0));
// This should have no effect.
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
assertThat(queue.size(), is(2));
}
use of com.yahoo.vespa.http.client.config.SessionParams in project vespa by vespa-engine.
the class OperationProcessorTest method testMixOfBlockingAndNonBlocking.
@Test
public void testMixOfBlockingAndNonBlocking() {
Endpoint endpoint = Endpoint.create("host");
SessionParams sessionParams = new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(endpoint).build()).setConnectionParams(new ConnectionParams.Builder().setEnableV3Protocol(true).build()).build();
OperationProcessor operationProcessor = new OperationProcessor(new IncompleteResultsThrottler(1000, 1000, null, null), (docId, documentResult) -> queue.add(documentResult), sessionParams, null);
operationProcessor.sendDocument(doc1);
// Blocked
operationProcessor.sendDocument(doc1b);
operationProcessor.sendDocument(doc2);
operationProcessor.sendDocument(doc3);
assertThat(queue.size(), is(0));
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(3));
// This should have no effect since it should not be sent.
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(endpoint)), 0);
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(3));
operationProcessor.resultReceived(new EndpointResult(doc3.getOperationId(), new Result.Detail(endpoint)), 0);
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(2));
operationProcessor.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(endpoint)), 0);
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(endpoint)), 0);
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(endpoint)), 0);
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(0));
}
use of com.yahoo.vespa.http.client.config.SessionParams in project vespa by vespa-engine.
the class OperationProcessorTest method testBlockingOfOperationsTwoEndpoints.
@Test
public void testBlockingOfOperationsTwoEndpoints() {
SessionParams sessionParams = new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("host")).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("host")).build()).setConnectionParams(new ConnectionParams.Builder().setEnableV3Protocol(true).build()).build();
OperationProcessor operationProcessor = new OperationProcessor(new IncompleteResultsThrottler(1000, 1000, null, null), (docId, documentResult) -> queue.add(documentResult), sessionParams, null);
operationProcessor.sendDocument(doc1);
operationProcessor.sendDocument(doc1b);
assertThat(queue.size(), is(0));
// Only one operations should be in flight.
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
assertThat(queue.size(), is(0));
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 1);
assertThat(queue.size(), is(1));
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
assertThat(queue.size(), is(1));
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 1);
assertThat(queue.size(), is(2));
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(0));
// This should have no effect.
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("host"))), 1);
operationProcessor.resultReceived(new EndpointResult(doc1b.getOperationId(), new Result.Detail(Endpoint.create("host"))), 1);
assertThat(queue.size(), is(2));
}
use of com.yahoo.vespa.http.client.config.SessionParams in project vespa by vespa-engine.
the class OperationProcessorTest method testMultipleDuplicateDocIds.
@Test
public void testMultipleDuplicateDocIds() {
SessionParams sessionParams = new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("host")).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("host")).build()).addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("host")).build()).build();
OperationProcessor q = new OperationProcessor(new IncompleteResultsThrottler(1000, 1000, null, null), (docId, documentResult) -> queue.add(documentResult), sessionParams, null);
q.sendDocument(doc1);
assertThat(queue.size(), is(0));
q.sendDocument(doc2);
assertThat(queue.size(), is(0));
q.sendDocument(doc3);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("a"))), 0);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("a"))), 0);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("b"))), 1);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("c"))), 2);
assertThat(queue.size(), is(1));
q.resultReceived(new EndpointResult(doc3.getOperationId(), new Result.Detail(Endpoint.create("a"))), 0);
assertThat(queue.size(), is(1));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("a"))), 0);
assertThat(queue.size(), is(1));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("b"))), 1);
assertThat(queue.size(), is(1));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("c"))), 2);
assertThat(queue.size(), is(2));
q.resultReceived(new EndpointResult(doc3.getOperationId(), new Result.Detail(Endpoint.create("c"))), 2);
assertThat(queue.size(), is(2));
q.resultReceived(new EndpointResult(doc3.getOperationId(), new Result.Detail(Endpoint.create("c"))), 2);
assertThat(queue.size(), is(2));
q.resultReceived(new EndpointResult(doc3.getOperationId(), new Result.Detail(Endpoint.create("b"))), 1);
assertThat(queue.size(), is(3));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("b"))), 1);
assertThat(queue.size(), is(3));
assertThat(queue.remove().getDocumentDataAsCharSequence().toString(), is("data doc 1"));
assertThat(queue.remove().getDocumentDataAsCharSequence().toString(), is("data doc 2"));
assertThat(queue.remove().getDocumentDataAsCharSequence().toString(), is("data doc 3"));
}
use of com.yahoo.vespa.http.client.config.SessionParams in project vespa by vespa-engine.
the class CommandLineArgumentsTest method testAllImplementedFlags.
@Test
public void testAllImplementedFlags() {
add("file", "fileValue.json");
add("route", "routeValue");
add("host", "hostValue");
add("port", "1234");
add("timeout", "2345");
args.add("--useCompression");
args.add("--useDynamicThrottling");
add("maxpending", "3456");
add("debugport", "7890");
args.add("--verbose");
args.add("--useTls");
CommandLineArguments arguments = CommandLineArguments.build(asArray());
SessionParams params = arguments.createSessionParams(true);
assertThat(params.getClientQueueSize(), is(3456));
assertThat(params.getThrottlerMinSize(), is(10));
assertThat(params.getClusters().get(0).getEndpoints().get(0).getPort(), is(1234));
assertThat(params.getClusters().get(0).getEndpoints().get(0).isUseSsl(), is(true));
assertThat(params.getConnectionParams().getUseCompression(), is(true));
assertThat(params.getFeedParams().getRoute(), is("routeValue"));
assertThat(params.getFeedParams().getDataFormat(), is(FeedParams.DataFormat.JSON_UTF8));
assertThat(params.getFeedParams().getLocalQueueTimeOut(), is(2345000L));
assertThat(params.getFeedParams().getMaxInFlightRequests(), is(3456));
assertThat(params.getFeedParams().getClientTimeout(TimeUnit.MILLISECONDS), is(2345000L));
}
Aggregations