use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class RPCSendV2 method createReply.
@Override
protected Reply createReply(Values ret, String serviceName, Trace trace) {
CompressionType compression = CompressionType.valueOf(ret.get(3).asInt8());
byte[] slimeBytes = compressor.decompress(ret.get(5).asData(), compression, ret.get(4).asInt32());
Slime slime = BinaryFormat.decode(slimeBytes);
Inspector root = slime.get();
Version version = new Version(root.field(VERSION_F).asString());
byte[] payload = root.field(BLOB_F).asData();
// Make sure that the owner understands the protocol.
Reply reply = null;
Error error = null;
if (payload.length > 0) {
Object retval = decode(new Utf8Array(root.field(PROTOCOL_F).asUtf8()), version, payload);
if (retval instanceof Reply) {
reply = (Reply) retval;
} else {
error = (Error) retval;
}
}
if (reply == null) {
reply = new EmptyReply();
}
if (error != null) {
reply.addError(error);
}
reply.setRetryDelay(root.field(RETRYDELAY_F).asDouble());
Inspector errors = root.field(ERRORS_F);
for (int i = 0; i < errors.entries(); i++) {
Inspector e = errors.entry(i);
String service = e.field(SERVICE_F).asString();
reply.addError(new Error((int) e.field(CODE_F).asLong(), e.field(MSG_F).asString(), (service != null && service.length() > 0) ? service : serviceName));
}
if (trace.getLevel() > 0) {
trace.getRoot().addChild(TraceNode.decode(root.field(TRACE_F).asString()));
}
return reply;
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class RoutingNode method getUnconsumedErrors.
/**
* Return any errors preventing transmitting along this routing tree to possibly succeed. This might happen if
* either a) there are no leaf nodes to send to, or b) some leaf node contains a fatal error that is not masked by a
* routing policy above it in the tree. If only transient errors would reach this, the resend flag is set to true.
*
* @return The errors concatenated or null.
*/
private String getUnconsumedErrors() {
StringBuilder errors = null;
Deque<RoutingNode> stack = new ArrayDeque<>();
stack.push(this);
while (!stack.isEmpty()) {
RoutingNode node = stack.pop();
if (node.reply != null) {
for (int i = 0; i < node.reply.getNumErrors(); ++i) {
Error error = node.reply.getError(i);
int errorCode = error.getCode();
RoutingNode it = node;
while (it != null) {
if (it.routingContext != null && it.routingContext.isConsumableError(errorCode)) {
errorCode = ErrorCode.NONE;
break;
}
it = it.parent;
}
if (errorCode != ErrorCode.NONE) {
if (errors == null) {
errors = new StringBuilder();
} else {
errors.append("\n");
}
errors.append(error.toString());
shouldRetry = resender != null && resender.canRetry(errorCode);
if (!shouldRetry) {
// no need to continue
return errors.toString();
}
}
}
} else {
for (RoutingNode child : node.children) {
stack.push(child);
}
}
}
return errors != null ? errors.toString() : null;
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class ReplyMergerTestCase method mergingSingleReplyWithOneErrorReturnsEmptyReplyWithError.
@Test
public void mergingSingleReplyWithOneErrorReturnsEmptyReplyWithError() {
Reply r1 = new EmptyReply();
Error error = new Error(1234, "oh no!");
r1.addError(error);
merger.merge(0, r1);
Tuple2<Integer, Reply> ret = merger.mergedReply();
assertThat(ret.first, nullValue());
assertThat(ret.second, not(sameInstance(r1)));
assertThatErrorsMatch(new Error[] { error }, ret);
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class StoragePolicy method merge.
@Override
public void merge(RoutingContext context) {
RoutingNodeIterator it = context.getChildIterator();
Reply reply = (it.hasReply()) ? it.removeReply() : context.getReply();
if (reply == null) {
reply = new EmptyReply();
reply.addError(new Error(ErrorCode.NO_ADDRESS_FOR_SERVICE, "No reply in any children, nor in the routing context: " + context));
}
if (reply instanceof WrongDistributionReply) {
distributorSelectionLogic.handleWrongDistribution((WrongDistributionReply) reply, context);
} else if (reply.hasErrors()) {
distributorSelectionLogic.handleErrorReply(reply, context.getContext());
} else if (reply instanceof WriteDocumentReply) {
if (context.shouldTrace(9)) {
context.trace(9, "Modification timestamp: " + ((WriteDocumentReply) reply).getHighestModificationTimestamp());
}
}
context.setReply(reply);
}
use of com.yahoo.messagebus.Error in project vespa by vespa-engine.
the class MessageBusVisitorSessionTestCase method testVisitorTimeoutsNotConsideredFatal.
@Test
public void testVisitorTimeoutsNotConsideredFatal() {
VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
MockComponents mc = createDefaultMock(visitorParameters);
mc.controlHandler.resetMock();
mc.visitorSession.start();
// create visitors
mc.executor.expectAndProcessTasks(1);
assertEquals(1, mc.sender.getMessageCount());
replyErrorToCreateVisitor(mc.sender, new Error(ErrorCode.TIMEOUT, "out of time!"));
// reply
mc.executor.expectAndProcessTasks(1);
// delayed create visitors
mc.executor.expectAndProcessTasks(1, new long[] { 100 });
assertEquals("CreateVisitorMessage(buckets=[\n" + "BucketId(0x80000000000004d2)\n" + "BucketId(0x0000000000000000)\n" + "]\n" + "selection='id.user==1234'\n)", replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET));
// reply
mc.executor.expectAndProcessTasks(1);
}
Aggregations