Search in sources :

Example 1 with Route

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

the class RPCNetwork method getRoute.

final Route getRoute(String routeString) {
    Route route = lruRouteMap.get(routeString);
    if (route == null) {
        route = Route.parse(routeString);
        lruRouteMap.put(routeString, route);
    }
    return new Route(route);
}
Also used : Route(com.yahoo.messagebus.routing.Route)

Example 2 with Route

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

the class RoutableTestCase method testMessageSwapState.

public void testMessageSwapState() {
    Message foo = new SimpleMessage("foo");
    Route fooRoute = Route.parse("foo");
    foo.setRoute(fooRoute);
    foo.setRetry(1);
    foo.setTimeReceivedNow();
    foo.setTimeRemaining(2);
    Message bar = new SimpleMessage("bar");
    Route barRoute = Route.parse("bar");
    bar.setRoute(barRoute);
    bar.setRetry(3);
    bar.setTimeReceivedNow();
    bar.setTimeRemaining(4);
    foo.swapState(bar);
    assertEquals(barRoute, foo.getRoute());
    assertEquals(fooRoute, bar.getRoute());
    assertEquals(3, foo.getRetry());
    assertEquals(1, bar.getRetry());
    assertTrue(foo.getTimeReceived() >= bar.getTimeReceived());
    assertEquals(4, foo.getTimeRemaining());
    assertEquals(2, bar.getTimeRemaining());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Route(com.yahoo.messagebus.routing.Route)

Example 3 with Route

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

the class FeederParamsTest method requireThatAccessorsWork.

@Test
public void requireThatAccessorsWork() {
    FeederParams params = new FeederParams();
    InputStream stdIn = Mockito.mock(InputStream.class);
    params.setStdIn(stdIn);
    assertSame(stdIn, params.getStdIn());
    PrintStream stdErr = Mockito.mock(PrintStream.class);
    params.setStdErr(stdErr);
    assertSame(stdErr, params.getStdErr());
    PrintStream stdOut = Mockito.mock(PrintStream.class);
    params.setStdOut(stdOut);
    assertSame(stdOut, params.getStdOut());
    Route route = Route.parse("my_route");
    params.setRoute(route);
    assertEquals(route, params.getRoute());
    assertNotSame(route, params.getRoute());
    params.setConfigId("my_config_id");
    assertEquals("my_config_id", params.getConfigId());
    params.setSerialTransfer(false);
    assertFalse(params.isSerialTransferEnabled());
    params.setSerialTransfer(true);
    assertTrue(params.isSerialTransferEnabled());
}
Also used : PrintStream(java.io.PrintStream) InputStream(java.io.InputStream) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Example 4 with Route

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

the class SharedDestinationSessionTestCase method requireThatSessionCanSendReply.

@Test
public void requireThatSessionCanSendReply() throws InterruptedException {
    RemoteClient client = RemoteClient.newInstanceWithInternSlobrok();
    MessageQueue queue = new MessageQueue();
    DestinationSessionParams params = new DestinationSessionParams().setMessageHandler(queue);
    SharedDestinationSession session = newDestinationSession(client.slobrokId(), params);
    Route route = Route.parse(session.connectionSpec());
    assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted());
    Message msg = queue.awaitMessage(60, TimeUnit.SECONDS);
    assertNotNull(msg);
    Reply reply = new SimpleReply("bar");
    reply.swapState(msg);
    session.sendReply(reply);
    assertNotNull(client.awaitReply(60, TimeUnit.SECONDS));
    session.release();
    client.close();
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) RemoteClient(com.yahoo.messagebus.jdisc.test.RemoteClient) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Example 5 with Route

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

the class MessageTypePolicy method select.

@Override
public void select(RoutingContext context) {
    int messageType = context.getMessage().getType();
    Route route = configRef.get().get(messageType);
    if (route == null) {
        route = defaultRoute;
    }
    context.addChild(route);
}
Also used : Route(com.yahoo.messagebus.routing.Route)

Aggregations

Route (com.yahoo.messagebus.routing.Route)27 Test (org.junit.Test)11 Hop (com.yahoo.messagebus.routing.Hop)5 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)5 RoutingTable (com.yahoo.messagebus.routing.RoutingTable)4 SimpleReply (com.yahoo.messagebus.test.SimpleReply)4 Message (com.yahoo.messagebus.Message)3 Utf8String (com.yahoo.text.Utf8String)3 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)2 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)2 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)2 EmptyReply (com.yahoo.messagebus.EmptyReply)2 Reply (com.yahoo.messagebus.Reply)2 MessageQueue (com.yahoo.messagebus.jdisc.test.MessageQueue)2 RemoteClient (com.yahoo.messagebus.jdisc.test.RemoteClient)2 ErrorDirective (com.yahoo.messagebus.routing.ErrorDirective)2 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)2 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)2