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