Search in sources :

Example 6 with Error

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

the class LocalNetwork method allocServiceAddress.

@Override
public boolean allocServiceAddress(RoutingNode recipient) {
    String service = recipient.getRoute().getHop(0).getServiceName();
    ServiceAddress address = wire.resolveServiceAddress(service);
    if (address == null) {
        recipient.setError(new Error(NO_ADDRESS_FOR_SERVICE, "No address for service '" + service + "'."));
        return false;
    }
    recipient.setServiceAddress(address);
    return true;
}
Also used : ServiceAddress(com.yahoo.messagebus.network.ServiceAddress) Error(com.yahoo.messagebus.Error) Utf8String(com.yahoo.text.Utf8String)

Example 7 with Error

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

the class RoutingTestCase method requireThatRetryCallsSelect.

@Test
public void requireThatRetryCallsSelect() {
    SimpleProtocol protocol = new SimpleProtocol();
    protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
    srcServer.mb.putProtocol(protocol);
    assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session]")).isAccepted());
    Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
    assertNotNull(msg);
    Reply reply = new EmptyReply();
    reply.swapState(msg);
    reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "err"));
    dstSession.reply(reply);
    assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
    dstSession.acknowledge(msg);
    assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
    System.out.println(reply.getTrace());
    assertFalse(reply.hasErrors());
    assertTrace(Arrays.asList("Selecting [dst/session].", "[APP_TRANSIENT_ERROR @ localhost]", "-[APP_TRANSIENT_ERROR @ localhost]", "Merged [dst/session].", "Selecting [dst/session].", "Sending reply", "Merged [dst/session]."), reply.getTrace());
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor) Error(com.yahoo.messagebus.Error) CustomPolicyFactory(com.yahoo.messagebus.routing.test.CustomPolicyFactory) Test(org.junit.Test)

Example 8 with Error

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

the class RoutingTestCase method requireThatIgnoreResultCanBeSetInHopBlueprint.

@Test
public void requireThatIgnoreResultCanBeSetInHopBlueprint() {
    srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addHop(new HopSpec("foo", "dst/session").setIgnoreResult(true)));
    assertTrue(srcSession.send(createMessage("msg"), Route.parse("foo")).isAccepted());
    Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
    assertNotNull(msg);
    Reply reply = new EmptyReply();
    reply.swapState(msg);
    reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "dst"));
    dstSession.reply(reply);
    assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
    System.out.println(reply.getTrace());
    assertFalse(reply.hasErrors());
    assertTrace(Arrays.asList("Not waiting for a reply from 'dst/session'."), reply.getTrace());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor) Error(com.yahoo.messagebus.Error) Test(org.junit.Test)

Example 9 with Error

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

the class RoutingTestCase method requireThatTransientErrorsAreRetriedWithPolicy.

@Test
public void requireThatTransientErrorsAreRetriedWithPolicy() {
    SimpleProtocol protocol = new SimpleProtocol();
    protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
    srcServer.mb.putProtocol(protocol);
    assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session]")).isAccepted());
    Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
    assertNotNull(msg);
    Reply reply = new EmptyReply();
    reply.swapState(msg);
    reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "err1"));
    dstSession.reply(reply);
    assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
    reply = new EmptyReply();
    reply.swapState(msg);
    reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "err2"));
    dstSession.reply(reply);
    assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
    dstSession.acknowledge(msg);
    assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
    System.out.println(reply.getTrace());
    assertFalse(reply.hasErrors());
    assertTrace(Arrays.asList("Source session accepted a 3 byte message. 1 message(s) now pending.", "Running routing policy 'Custom'.", "Selecting [dst/session].", "Component 'dst/session' selected by policy 'Custom'.", "Resolving 'dst/session'.", "Sending message (version ${VERSION}) from client to 'dst/session'", "Message (type 1) received at 'dst' for session 'session'.", "[APP_TRANSIENT_ERROR @ localhost]: err1", "Sending reply (version ${VERSION}) from 'dst'.", "Reply (type 0) received at client.", "Routing policy 'Custom' merging replies.", "Merged [dst/session].", "Message scheduled for retry 1 in 0.0 seconds.", "Resender resending message.", "Running routing policy 'Custom'.", "Selecting [dst/session].", "Component 'dst/session' selected by policy 'Custom'.", "Resolving 'dst/session'.", "Sending message (version ${VERSION}) from client to 'dst/session'", "Message (type 1) received at 'dst' for session 'session'.", "[APP_TRANSIENT_ERROR @ localhost]: err2", "Sending reply (version ${VERSION}) from 'dst'.", "Reply (type 0) received at client.", "Routing policy 'Custom' merging replies.", "Merged [dst/session].", "Message scheduled for retry 2 in 0.0 seconds.", "Resender resending message.", "Running routing policy 'Custom'.", "Selecting [dst/session].", "Component 'dst/session' selected by policy 'Custom'.", "Resolving 'dst/session'.", "Sending message (version ${VERSION}) from client to 'dst/session'", "Message (type 1) received at 'dst' for session 'session'.", "Sending reply (version ${VERSION}) from 'dst'.", "Reply (type 0) received at client.", "Routing policy 'Custom' merging replies.", "Merged [dst/session].", "Source session received reply. 0 message(s) now pending."), reply.getTrace());
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor) Error(com.yahoo.messagebus.Error) CustomPolicyFactory(com.yahoo.messagebus.routing.test.CustomPolicyFactory) Test(org.junit.Test)

Example 10 with Error

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

the class RoutingTestCase method requireThatIgnoreResultWorks.

@Test
public void requireThatIgnoreResultWorks() {
    assertTrue(srcSession.send(createMessage("msg"), Route.parse("?dst/session")).isAccepted());
    Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
    assertNotNull(msg);
    Reply reply = new EmptyReply();
    reply.swapState(msg);
    reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "dst"));
    dstSession.reply(reply);
    assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
    System.out.println(reply.getTrace());
    assertFalse(reply.hasErrors());
    assertTrace(Arrays.asList("Not waiting for a reply from 'dst/session'."), reply.getTrace());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor) Error(com.yahoo.messagebus.Error) Test(org.junit.Test)

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