Search in sources :

Example 16 with Error

use of com.yahoo.messagebus.Error in project vespa by vespa-engine.

the class MessageBusVisitorSession method handleMessageProcessingException.

private void handleMessageProcessingException(Reply reply, Exception e, String what) {
    final String errorDesc = formatProcessingException(e, what);
    final String fullMsg = formatIdentifyingVisitorErrorString(errorDesc);
    log.log(LogLevel.ERROR, fullMsg, e);
    int errorCode;
    synchronized (progress.getToken()) {
        if (!params.skipBucketsOnFatalErrors()) {
            errorCode = ErrorCode.APP_FATAL_ERROR;
            transitionTo(new StateDescription(State.FAILED, errorDesc));
        } else {
            errorCode = DocumentProtocol.ERROR_UNPARSEABLE;
        }
    }
    reply.addError(new Error(errorCode, errorDesc));
}
Also used : Error(com.yahoo.messagebus.Error)

Example 17 with Error

use of com.yahoo.messagebus.Error in project vespa by vespa-engine.

the class MessageBusVisitorSession method createMessageHandler.

private MessageHandler createMessageHandler() {
    return (message) -> {
        try {
            taskExecutor.submitTask(new HandleMessageTask(message));
        } catch (RejectedExecutionException e) {
            Reply reply = ((DocumentMessage) message).createReply();
            message.swapState(reply);
            reply.addError(new Error(DocumentProtocol.ERROR_ABORTED, "Visitor session has been aborted"));
            receiver.reply(reply);
        }
    };
}
Also used : Arrays(java.util.Arrays) com.yahoo.documentapi(com.yahoo.documentapi) com.yahoo.messagebus(com.yahoo.messagebus) ParseException(com.yahoo.document.select.parser.ParseException) com.yahoo.documentapi.messagebus.protocol(com.yahoo.documentapi.messagebus.protocol) Logger(java.util.logging.Logger) BucketIdFactory(com.yahoo.document.BucketIdFactory) Result(com.yahoo.messagebus.Result) Error(com.yahoo.messagebus.Error) RoutingTable(com.yahoo.messagebus.routing.RoutingTable) TimeUnit(java.util.concurrent.TimeUnit) AtomicLong(java.util.concurrent.atomic.AtomicLong) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) VisitorStatistics(com.yahoo.vdslib.VisitorStatistics) ClusterState(com.yahoo.vdslib.state.ClusterState) LogLevel(com.yahoo.log.LogLevel) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BucketId(com.yahoo.document.BucketId) Error(com.yahoo.messagebus.Error) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 18 with Error

use of com.yahoo.messagebus.Error in project vespa by vespa-engine.

the class MessageBusVisitorSession method handleDocumentMessage.

private void handleDocumentMessage(DocumentMessage msg) {
    Reply reply = msg.createReply();
    msg.swapState(reply);
    if (params.getLocalDataHandler() == null) {
        log.log(LogLevel.ERROR, sessionName + ": Got visitor data back to client with no local data destination.");
        reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "Visitor data with no local data destination"));
        receiver.reply(reply);
        return;
    }
    try {
        params.getLocalDataHandler().onMessage(msg, new AckToken(reply));
    } catch (Exception e) {
        handleMessageProcessingException(reply, e, "DocumentMessage");
        // Immediately reply since we cannot count on AckToken being registered
        receiver.reply(reply);
    }
}
Also used : Error(com.yahoo.messagebus.Error) ParseException(com.yahoo.document.select.parser.ParseException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 19 with Error

use of com.yahoo.messagebus.Error in project vespa by vespa-engine.

the class MessageBusVisitorSession method handleVisitorInfoMessage.

/**
 * NOTE: not called from within lock, function must take lock itself
 */
private void handleVisitorInfoMessage(VisitorInfoMessage msg) {
    Reply reply = msg.createReply();
    msg.swapState(reply);
    if (log.isLoggable(LogLevel.DEBUG)) {
        log.log(LogLevel.DEBUG, "Visitor session " + sessionName + ": Received VisitorInfo with " + msg.getFinishedBuckets().size() + " finished buckets");
    }
    try {
        if (msg.getErrorMessage().length() > 0) {
            params.getControlHandler().onVisitorError(msg.getErrorMessage());
        }
        synchronized (progress.getToken()) {
            // always locking we make screwing it up harder.
            if (!isDone()) {
                params.getControlHandler().onProgress(progress.getToken());
            } else {
                reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "Visitor has been shut down"));
            }
        }
    } catch (Exception e) {
        handleMessageProcessingException(reply, e, "VisitorInfoMessage");
    } finally {
        receiver.reply(reply);
    }
}
Also used : Error(com.yahoo.messagebus.Error) ParseException(com.yahoo.document.select.parser.ParseException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 20 with Error

use of com.yahoo.messagebus.Error in project vespa by vespa-engine.

the class ServerTestDriver method awaitErrors.

public Reply awaitErrors(Integer... errCodes) {
    Reply reply = awaitReply();
    if (reply == null) {
        return null;
    }
    List<Integer> lst = new LinkedList<>(Arrays.asList(errCodes));
    for (int i = 0, len = reply.getNumErrors(); i < len; ++i) {
        Error err = reply.getError(i);
        System.out.println(err);
        int idx = lst.indexOf(err.getCode());
        if (idx < 0) {
            return null;
        }
        lst.remove(idx);
    }
    if (!lst.isEmpty()) {
        return null;
    }
    return reply;
}
Also used : Error(com.yahoo.messagebus.Error) LinkedList(java.util.LinkedList)

Aggregations

Error (com.yahoo.messagebus.Error)51 Test (org.junit.Test)22 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)10 EmptyReply (com.yahoo.messagebus.EmptyReply)9 Reply (com.yahoo.messagebus.Reply)9 Receptor (com.yahoo.messagebus.test.Receptor)9 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)5 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)5 ParseException (com.yahoo.document.select.parser.ParseException)4 CustomPolicyFactory (com.yahoo.messagebus.routing.test.CustomPolicyFactory)4 BucketId (com.yahoo.document.BucketId)3 Message (com.yahoo.messagebus.Message)3 Version (com.yahoo.component.Version)2 DataValue (com.yahoo.jrt.DataValue)2 Protocol (com.yahoo.messagebus.Protocol)2 Hop (com.yahoo.messagebus.routing.Hop)2 Slime (com.yahoo.slime.Slime)2 Utf8Array (com.yahoo.text.Utf8Array)2 Utf8String (com.yahoo.text.Utf8String)2 IOException (java.io.IOException)2