use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class EndpointResultQueue method failedOperationId.
private synchronized void failedOperationId(String operationId, Exception exception) {
EndpointResult endpointResult = EndPointResultFactory.createError(endpoint, operationId, exception);
operationProcessor.resultReceived(endpointResult, clusterId);
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class EndPointResultFactory method parseResult.
private static EndpointResult parseResult(String line, Endpoint endpoint) {
try {
OperationStatus reply = OperationStatus.parse(line);
String message;
if (EMPTY_MESSAGE.equals(reply.message)) {
message = null;
} else {
message = reply.message;
}
Exception exception = null;
if (!reply.errorCode.isSuccess() && message != null) {
exception = new RuntimeException(message);
}
if (reply.traceMessage != null && !reply.traceMessage.isEmpty()) {
log.fine("Got trace message: " + reply.traceMessage);
}
return new EndpointResult(reply.operationId, new Result.Detail(endpoint, replyToResultType(reply), reply.traceMessage, exception));
} catch (Throwable t) {
throw new IllegalArgumentException("Bad result line from server: '" + line + "'", t);
}
}
use of com.yahoo.vespa.http.client.core.EndpointResult in project vespa by vespa-engine.
the class EndpointResultQueueTest method testBasics.
@Test
public void testBasics() {
Endpoint endpoint = Endpoint.create("a");
OperationProcessor mockAggregator = mock(OperationProcessor.class);
final AtomicInteger resultCount = new AtomicInteger(0);
doAnswer(invocationOnMock -> {
resultCount.getAndIncrement();
return null;
}).when(mockAggregator).resultReceived(anyObject(), eq(0));
EndpointResultQueue q = new EndpointResultQueue(mockAggregator, endpoint, 0, new ScheduledThreadPoolExecutor(1), 100L * 1000L);
q.operationSent("op1");
assertThat(q.getPendingSize(), is(1));
q.operationSent("op2");
assertThat(q.getPendingSize(), is(2));
q.operationSent("op3");
assertThat(q.getPendingSize(), is(3));
q.resultReceived(new EndpointResult("op1", new Result.Detail(endpoint)), 0);
assertThat(q.getPendingSize(), is(2));
q.resultReceived(new EndpointResult("op2", new Result.Detail(endpoint)), 0);
assertThat(q.getPendingSize(), is(1));
q.resultReceived(new EndpointResult("op3", new Result.Detail(endpoint)), 0);
assertThat(q.getPendingSize(), is(0));
q.resultReceived(new EndpointResult("op1", new Result.Detail(endpoint)), 0);
assertThat(q.getPendingSize(), is(0));
q.resultReceived(new EndpointResult("abc", new Result.Detail(endpoint)), 0);
assertThat(q.getPendingSize(), is(0));
assertThat(resultCount.get(), is(5));
q.operationSent("op4");
assertThat(q.getPendingSize(), is(1));
q.operationSent("op5");
assertThat(q.getPendingSize(), is(2));
q.failPending(new RuntimeException());
assertThat(resultCount.get(), is(7));
}
Aggregations