use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class IOThread method drainFirstDocumentsInQueueIfOld.
private void drainFirstDocumentsInQueueIfOld() {
while (true) {
Optional<Document> document = documentQueue.pollDocumentIfTimedoutInQueue(localQueueTimeOut);
if (!document.isPresent()) {
return;
}
EndpointResult endpointResult = EndPointResultFactory.createTransientError(endpoint, document.get().getOperationId(), new Exception("Not sending document operation, timed out in queue after " + document.get().timeInQueueMillis() + " ms."));
resultQueue.failOperation(endpointResult, clusterId);
}
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class OperationProcessorTest method assertThatDuplicateResultsFromOneClusterWorks.
@Test
public void assertThatDuplicateResultsFromOneClusterWorks() {
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.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"))), 0);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("c"))), 0);
assertThat(queue.size(), is(0));
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class OperationProcessorTest method testBasic.
@Test
public void testBasic() {
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()).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.resultReceived(new EndpointResult("foo", new Result.Detail(null)), 0);
assertThat(queue.size(), is(0));
q.sendDocument(doc1);
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(0));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("d"))), 3);
assertThat(queue.size(), is(1));
q.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("e"))), 0);
assertThat(queue.size(), is(1));
// check a, b, c, d
Result aggregated = queue.poll();
assertThat(aggregated.getDocumentId(), equalTo("doc:a:b"));
assertThat(aggregated.getDetails().size(), is(4));
assertThat(aggregated.getDetails().get(0).getEndpoint().getHostname(), equalTo("a"));
assertThat(aggregated.getDetails().get(1).getEndpoint().getHostname(), equalTo("b"));
assertThat(aggregated.getDetails().get(2).getEndpoint().getHostname(), equalTo("c"));
assertThat(aggregated.getDetails().get(3).getEndpoint().getHostname(), equalTo("d"));
assertThat(aggregated.getDocumentDataAsCharSequence().toString(), is("data doc 1"));
assertThat(queue.size(), is(0));
q.sendDocument(doc2);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("a"))), 0);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("b"))), 1);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("c"))), 2);
assertThat(queue.size(), is(0));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("d"))), 3);
assertThat(queue.size(), is(1));
q.resultReceived(new EndpointResult(doc2.getOperationId(), new Result.Detail(Endpoint.create("e"))), 0);
assertThat(queue.size(), is(1));
// check a, b, c, d
aggregated = queue.poll();
assertThat(aggregated.getDocumentId(), equalTo("doc:a:b2"));
assertThat(aggregated.getDetails().size(), is(4));
assertThat(aggregated.getDetails().get(0).getEndpoint().getHostname(), equalTo("a"));
assertThat(aggregated.getDetails().get(1).getEndpoint().getHostname(), equalTo("b"));
assertThat(aggregated.getDetails().get(2).getEndpoint().getHostname(), equalTo("c"));
assertThat(aggregated.getDetails().get(3).getEndpoint().getHostname(), equalTo("d"));
assertThat(aggregated.getDocumentDataAsCharSequence().toString(), is("data doc 2"));
assertThat(queue.size(), is(0));
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class OperationProcessorTest method testBlockingOfOperationsToSameDocIdMany.
@Test
public void testBlockingOfOperationsToSameDocIdMany() {
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);
Queue<Document> documentQueue = new ArrayDeque<>();
for (int x = 0; x < 100; x++) {
Document document = new Document("doc:a:b", String.valueOf(x), null);
operationProcessor.sendDocument(document);
documentQueue.add(document);
}
for (int x = 0; x < 100; x++) {
assertThat(queue.size(), is(x));
// Only one operations should be in flight.
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
Document document = documentQueue.poll();
operationProcessor.resultReceived(new EndpointResult(document.getOperationId(), new Result.Detail(Endpoint.create("host"))), 0);
assertThat(queue.size(), is(x + 1));
if (x < 99) {
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(1));
} else {
assertThat(operationProcessor.getIncompleteResultQueueSize(), is(0));
}
}
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class OperationProcessorTest method testWaitBlocks.
@Test
public void testWaitBlocks() throws InterruptedException {
SessionParams sessionParams = new SessionParams.Builder().addCluster(new Cluster.Builder().addEndpoint(Endpoint.create("host")).build()).build();
OperationProcessor operationProcessor = new OperationProcessor(new IncompleteResultsThrottler(1, 1, null, null), (docId, documentResult) -> {
}, sessionParams, null);
operationProcessor.sendDocument(doc1);
final CountDownLatch started = new CountDownLatch(1);
final CountDownLatch done = new CountDownLatch(1);
Thread shouldWait = new Thread(() -> {
started.countDown();
operationProcessor.sendDocument(doc2);
done.countDown();
});
shouldWait.start();
started.await();
// We want the test to pass fast so we only wait 40mS to see that it is blocking. This might lead to
// some false positives, but that is ok.
assertThat(done.await(40, TimeUnit.MILLISECONDS), is(false));
operationProcessor.resultReceived(new EndpointResult(doc1.getOperationId(), new Result.Detail(Endpoint.create("d"))), 0);
assertThat(done.await(120, TimeUnit.SECONDS), is(true));
}
Aggregations