Search in sources :

Example 11 with OperationStatus

use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.

the class V3MockParsingRequestHandler method respondFailedWithTransitiveErrorSeenFromClient.

private void respondFailedWithTransitiveErrorSeenFromClient(PrintWriter responseWriter, String docId) {
    final OperationStatus operationStatus = new OperationStatus("NETWORK_ERROR", docId, ErrorCode.ERROR, false, "trace");
    writeResponse(responseWriter, operationStatus);
}
Also used : OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus)

Example 12 with OperationStatus

use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.

the class V3MockParsingRequestHandler method respondFailed.

private void respondFailed(PrintWriter responseWriter, String docId) {
    final OperationStatus operationStatus = new OperationStatus("mbus returned boom", docId, ErrorCode.ERROR, false, "trace");
    writeResponse(responseWriter, operationStatus);
}
Also used : OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus)

Example 13 with OperationStatus

use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.

the class ClientFeederV3 method handleRequest.

public HttpResponse handleRequest(HttpRequest request) throws IOException {
    threadsAvailableForFeeding.decrementAndGet();
    ongoingRequests.incrementAndGet();
    try {
        FeederSettings feederSettings = new FeederSettings(request);
        /**
         * The gateway handle overload from clients in different ways.
         *
         * If the backend is overloaded, but not the gateway, it will fill the backend, messagebus throttler
         * will start to block new documents and finally all threadsAvailableForFeeding will be blocking.
         * However, as more threads are added, the gateway will not block on messagebus but return
         * transitive errors on the documents that can not be processed. These errors will cause the client(s) to
         * back off a bit.
         *
         * However, we can also have the case that the gateway becomes the bottleneck (e.g. CPU). In this case
         * we need to stop processing of new messages as early as possible and reject the request. This
         * will cause the client(s) to back off for a while. We want some slack before we enter this mode.
         * If we can simply transitively fail each document, it is nicer. Therefor we allow some threads to be
         * busy processing requests with transitive errors before entering this mode. Since we already
         * have flooded the backend, have several threads hanging and waiting for capacity, the number should
         * not be very large. Too much slack can lead to too many threads handling feed and impacting query traffic.
         * We try 10 for now. This should only kick in with very massive feeding to few gateway nodes.
         */
        if (feederSettings.denyIfBusy && threadsAvailableForFeeding.get() < -10) {
            return new ErrorHttpResponse(getOverloadReturnCode(request), "Gateway overloaded");
        }
        InputStream inputStream = StreamReaderV3.unzipStreamIfNeeded(request);
        final BlockingQueue<OperationStatus> replies = new LinkedBlockingQueue<>();
        try {
            feed(feederSettings, inputStream, replies, threadsAvailableForFeeding);
            synchronized (monitor) {
                // handshakes as it won't be processed by the client.
                if (request.getJDiscRequest().headers().get(Headers.DATA_FORMAT) != null) {
                    transferPreviousRepliesToResponse(replies);
                }
            }
        } catch (InterruptedException e) {
        // NOP, just terminate
        } catch (Throwable e) {
            log.log(LogLevel.WARNING, "Unhandled exception while feeding: " + Exceptions.toMessageString(e), e);
        } finally {
            try {
                replies.add(createOperationStatus("-", "-", ErrorCode.END_OF_FEED, false, null));
            } catch (InterruptedException e) {
            // NOP, we are already exiting the thread
            }
        }
        return new FeedResponse(200, replies, 3, /* protocol version */
        clientId, outstandingOperations.get(), hostName);
    } finally {
        ongoingRequests.decrementAndGet();
        threadsAvailableForFeeding.incrementAndGet();
    }
}
Also used : InputStream(java.io.InputStream) OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Example 14 with OperationStatus

use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.

the class FeedReplyReader method enqueue.

private void enqueue(ReplyContext context, String message, ErrorCode status, boolean isConditionNotMet, Trace trace) {
    try {
        String traceMessage = (trace != null && trace.getLevel() > 0) ? trace.toString() : "";
        context.feedReplies.put(new OperationStatus(message, context.docId, status, isConditionNotMet, traceMessage));
    } catch (InterruptedException e) {
        log.log(LogLevel.WARNING, "Interrupted while enqueueing result from putting document with id: " + context.docId);
        Thread.currentThread().interrupt();
    }
}
Also used : OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus) DocumentOperationStatus(com.yahoo.documentapi.metrics.DocumentOperationStatus)

Example 15 with OperationStatus

use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.

the class Feeder method drain.

void drain() throws InterruptedException {
    if (settings.drain) {
        while (numPending > 0) {
            OperationStatus o = feedReplies.take();
            decreasePending(o);
        }
    }
}
Also used : OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus)

Aggregations

OperationStatus (com.yahoo.vespa.http.client.core.OperationStatus)15 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 Splitter (com.google.common.base.Splitter)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 SessionCache (com.yahoo.container.jdisc.messagebus.SessionCache)1 AccessLog (com.yahoo.container.logging.AccessLog)1 DataType (com.yahoo.document.DataType)1 DocumentType (com.yahoo.document.DocumentType)1 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)1 DocumentmanagerConfig (com.yahoo.document.config.DocumentmanagerConfig)1 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)1 DocumentApiMetrics (com.yahoo.documentapi.metrics.DocumentApiMetrics)1 DocumentOperationStatus (com.yahoo.documentapi.metrics.DocumentOperationStatus)1 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)1 ReferencedResource (com.yahoo.jdisc.ReferencedResource)1 Result (com.yahoo.messagebus.Result)1 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)1 SharedSourceSession (com.yahoo.messagebus.shared.SharedSourceSession)1