Search in sources :

Example 1 with SessionParams

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));
}
Also used : SessionParams(com.yahoo.vespa.http.client.config.SessionParams) EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) Cluster(com.yahoo.vespa.http.client.config.Cluster) Test(org.junit.Test)

Example 2 with SessionParams

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));
}
Also used : SessionParams(com.yahoo.vespa.http.client.config.SessionParams) Endpoint(com.yahoo.vespa.http.client.config.Endpoint) EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) Cluster(com.yahoo.vespa.http.client.config.Cluster) Test(org.junit.Test)

Example 3 with SessionParams

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));
}
Also used : SessionParams(com.yahoo.vespa.http.client.config.SessionParams) EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) Cluster(com.yahoo.vespa.http.client.config.Cluster) Test(org.junit.Test)

Example 4 with SessionParams

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"));
}
Also used : SessionParams(com.yahoo.vespa.http.client.config.SessionParams) EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) Cluster(com.yahoo.vespa.http.client.config.Cluster) Test(org.junit.Test)

Example 5 with SessionParams

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));
}
Also used : SessionParams(com.yahoo.vespa.http.client.config.SessionParams) Test(org.junit.Test)

Aggregations

SessionParams (com.yahoo.vespa.http.client.config.SessionParams)15 Test (org.junit.Test)12 Cluster (com.yahoo.vespa.http.client.config.Cluster)11 EndpointResult (com.yahoo.vespa.http.client.core.EndpointResult)8 Endpoint (com.yahoo.vespa.http.client.config.Endpoint)5 Result (com.yahoo.vespa.http.client.Result)2 FeedParams (com.yahoo.vespa.http.client.config.FeedParams)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 FeedClient (com.yahoo.vespa.http.client.FeedClient)1 ConnectionParams (com.yahoo.vespa.http.client.config.ConnectionParams)1 Document (com.yahoo.vespa.http.client.core.Document)1 IOException (java.io.IOException)1 ArrayDeque (java.util.ArrayDeque)1 HashSet (java.util.HashSet)1 Random (java.util.Random)1 StringTokenizer (java.util.StringTokenizer)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 XMLStreamException (javax.xml.stream.XMLStreamException)1