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