use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class OperationProcessor method process.
private Result process(EndpointResult endpointResult, int clusterId) {
synchronized (monitor) {
if (!docSendInfoByOperationId.containsKey(endpointResult.getOperationId())) {
log.finer("Received out-of-order or too late result, discarding: " + endpointResult);
return null;
}
DocumentSendInfo documentSendInfo = docSendInfoByOperationId.get(endpointResult.getOperationId());
if (retriedThis(endpointResult, documentSendInfo, clusterId)) {
return null;
}
if (!documentSendInfo.addIfNotAlreadyThere(endpointResult.getDetail(), clusterId)) {
// Duplicate message, we have seen this operation before.
return null;
}
// Is this the last operation we are waiting for?
if (documentSendInfo.detailCount() != numDestinations) {
return null;
}
Result result = documentSendInfo.createResult();
docSendInfoByOperationId.remove(endpointResult.getOperationId());
String documentId = documentSendInfo.getDocument().getDocumentId();
/**
* If we got a pending operation against this document
* dont't remove it from inflightDocuments and send blocked document operation
*/
List<Document> blockedDocuments = blockedDocumentsByDocumentId.get(documentId);
if (blockedDocuments.isEmpty()) {
inflightDocumentIds.remove(documentId);
} else {
sendToClusters(blockedDocuments.remove(0));
}
return result;
}
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class OperationProcessor method resultReceived.
public void resultReceived(EndpointResult endpointResult, int clusterId) {
final Result result = process(endpointResult, clusterId);
if (result != null) {
incompleteResultsThrottler.resultReady(result.isSuccess());
resultCallback.onCompletion(result.getDocumentId(), result);
if (traceToStderr && result.hasLocalTrace()) {
System.err.println(result.toString());
}
}
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class IOThreadTest method setupEndpointResultQueueMock.
/**
* Set up mock so that it can handle both failDocument() and resultReceived().
* @param expectedDocIdFail on failure, this has to be the doc id, or the mock will fail.
* @param expectedDocIdOk on ok, this has to be the doc id, or the mock will fail.
* @param isTransient checked on failure, if different, the mock will fail.
* @param expectedException checked on failure, if exception toString is different, the mock will fail.
*/
void setupEndpointResultQueueMock(String expectedDocIdFail, String expectedDocIdOk, boolean isTransient, String expectedException) {
doAnswer(invocation -> {
EndpointResult endpointResult = (EndpointResult) invocation.getArguments()[0];
assertThat(endpointResult.getOperationId(), is(expectedDocIdFail));
assertThat(endpointResult.getDetail().getException().toString(), containsString(expectedException));
assertThat(endpointResult.getDetail().getResultType(), is(isTransient ? Result.ResultType.TRANSITIVE_ERROR : Result.ResultType.FATAL_ERROR));
latch.countDown();
return null;
}).when(endpointResultQueue).failOperation(anyObject(), eq(0));
doAnswer(invocation -> {
EndpointResult endpointResult = (EndpointResult) invocation.getArguments()[0];
assertThat(endpointResult.getOperationId(), is(expectedDocIdOk));
assertThat(endpointResult.getDetail().getResultType(), is(Result.ResultType.OPERATION_EXECUTED));
latch.countDown();
return null;
}).when(endpointResultQueue).resultReceived(anyObject(), eq(0));
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class IOThread method processResponse.
private ProcessResponse processResponse(InputStream serverResponse) throws IOException {
final Collection<EndpointResult> endpointResults = EndPointResultFactory.createResult(endpoint, serverResponse);
statusReceivedCounter.addAndGet(endpointResults.size());
int transientErrors = 0;
for (EndpointResult endpointResult : endpointResults) {
if (endpointResult.getDetail().getResultType() == Result.ResultType.TRANSITIVE_ERROR) {
transientErrors++;
}
resultQueue.resultReceived(endpointResult, clusterId);
}
return new ProcessResponse(transientErrors, endpointResults.size());
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class IOThread method drainDocumentQueueWhenFailingPermanently.
private void drainDocumentQueueWhenFailingPermanently(Exception exception) {
// first, clear sentOperations:
resultQueue.failPending(exception);
for (Document document : documentQueue.removeAllDocuments()) {
EndpointResult endpointResult = EndPointResultFactory.createError(endpoint, document.getOperationId(), exception);
resultQueue.failOperation(endpointResult, clusterId);
}
}
Aggregations