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));
}
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);
}
};
}
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);
}
}
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);
}
}
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;
}
Aggregations