Search in sources :

Example 16 with EndpointResult

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);
}
Also used : EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult)

Example 17 with EndpointResult

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);
    }
}
Also used : EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus) IOException(java.io.IOException) Result(com.yahoo.vespa.http.client.Result) EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult)

Example 18 with EndpointResult

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));
}
Also used : Endpoint(com.yahoo.vespa.http.client.config.Endpoint) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) OperationProcessor(com.yahoo.vespa.http.client.core.operationProcessor.OperationProcessor) Test(org.junit.Test)

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