Search in sources :

Example 1 with EndpointResult

use of com.yahoo.vespa.http.client.core.EndpointResult 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 EndpointResult

use of com.yahoo.vespa.http.client.core.EndpointResult 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 EndpointResult

use of com.yahoo.vespa.http.client.core.EndpointResult 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 EndpointResult

use of com.yahoo.vespa.http.client.core.EndpointResult 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 EndpointResult

use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.

the class EndpointResultQueue method timeout.

// Called only from ScheduledThreadPoolExecutor thread in DocumentTimerTask.run(), see below
private synchronized void timeout(String operationId) {
    TimerFuture timerFuture = futureByOperation.remove(operationId);
    if (timerFuture == null) {
        log.finer("Timeout of operation '" + operationId + "', but operation " + "not found in map. Result was probably received just-in-time from server, while timeout " + "task could not be cancelled.");
        return;
    }
    EndpointResult endpointResult = EndPointResultFactory.createTransientError(endpoint, operationId, new RuntimeException("Timed out waiting for reply from server."));
    operationProcessor.resultReceived(endpointResult, clusterId);
}
Also used : EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult)

Aggregations

EndpointResult (com.yahoo.vespa.http.client.core.EndpointResult)18 Test (org.junit.Test)9 SessionParams (com.yahoo.vespa.http.client.config.SessionParams)8 Cluster (com.yahoo.vespa.http.client.config.Cluster)7 Result (com.yahoo.vespa.http.client.Result)4 Endpoint (com.yahoo.vespa.http.client.config.Endpoint)4 Document (com.yahoo.vespa.http.client.core.Document)4 IOException (java.io.IOException)2 OperationStatus (com.yahoo.vespa.http.client.core.OperationStatus)1 ServerResponseException (com.yahoo.vespa.http.client.core.ServerResponseException)1 OperationProcessor (com.yahoo.vespa.http.client.core.operationProcessor.OperationProcessor)1 ArrayDeque (java.util.ArrayDeque)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1