use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.
the class MessageBusTestCase method testRoutingPolicyCache.
@Test
public void testRoutingPolicyCache() throws ListenFailedException, UnknownHostException {
Slobrok slobrok = new Slobrok();
String config = "slobrok[1]\nslobrok[0].connectionspec \"" + new Spec("localhost", slobrok.port()).toString() + "\"\n";
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
MessageBus bus = new MessageBus(new RPCNetwork(new RPCNetworkParams().setSlobrokConfigId("raw:" + config)), new MessageBusParams().addProtocol(protocol));
RoutingPolicy all = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null);
assertNotNull(all);
RoutingPolicy ref = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", null);
assertNotNull(ref);
assertSame(all, ref);
RoutingPolicy allArg = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", "Arg");
assertNotNull(allArg);
assertNotSame(all, allArg);
RoutingPolicy refArg = bus.getRoutingPolicy(SimpleProtocol.NAME, "Custom", "Arg");
assertNotNull(refArg);
assertSame(allArg, refArg);
}
use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.
the class RoutableTestCase method testMessageContext.
public void testMessageContext() throws ListenFailedException, UnknownHostException {
Slobrok slobrok = new Slobrok();
TestServer srcServer = new TestServer("src", null, slobrok, null);
TestServer dstServer = new TestServer("dst", null, slobrok, null);
SourceSession srcSession = srcServer.mb.createSourceSession(new Receptor(), new SourceSessionParams().setTimeout(600.0));
DestinationSession dstSession = dstServer.mb.createDestinationSession("session", true, new Receptor());
assertTrue(srcServer.waitSlobrok("dst/session", 1));
Object context = new Object();
Message msg = new SimpleMessage("msg");
msg.setContext(context);
assertTrue(srcSession.send(msg, "dst/session", true).isAccepted());
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertSame(reply.getContext(), context);
srcSession.destroy();
srcServer.destroy();
dstSession.destroy();
dstServer.destroy();
slobrok.stop();
}
use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.
the class ThrottlerTestCase method setUp.
public void setUp() throws ListenFailedException, UnknownHostException {
RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME);
table.addHop("dst", "test/dst/session", Arrays.asList("test/dst/session"));
table.addRoute("test", Arrays.asList("dst"));
slobrok = new Slobrok();
src = new TestServer("test/src", table, slobrok, null);
dst = new TestServer("test/dst", table, slobrok, null);
}
use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.
the class BasicNetworkTestCase method setUp.
public void setUp() throws ListenFailedException, UnknownHostException {
RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME);
table.addHop("pxy", "test/pxy/session", Arrays.asList("test/pxy/session"));
table.addHop("dst", "test/dst/session", Arrays.asList("test/dst/session"));
table.addRoute("test", Arrays.asList("pxy", "dst"));
slobrok = new Slobrok();
src = new TestServer("test/src", table, slobrok, null);
pxy = new TestServer("test/pxy", table, slobrok, null);
dst = new TestServer("test/dst", table, slobrok, null);
}
use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.
the class RPCNetworkTestCase method requireThatProtocolEncodeExceptionIsCaught.
@Test
public void requireThatProtocolEncodeExceptionIsCaught() throws Exception {
RuntimeException e = new RuntimeException();
Slobrok slobrok = new Slobrok();
TestServer server = new TestServer(new MessageBusParams().addProtocol(MyProtocol.newEncodeException(e)), new RPCNetworkParams().setSlobrokConfigId(slobrok.configId()));
Receptor receptor = new Receptor();
SourceSession src = server.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(receptor));
DestinationSession dst = server.mb.createDestinationSession(new DestinationSessionParams());
assertTrue(src.send(new MyMessage().setRoute(Route.parse(dst.getConnectionSpec()))).isAccepted());
Reply reply = receptor.getReply(60);
assertNotNull(reply);
assertEquals(1, reply.getNumErrors());
StringWriter expected = new StringWriter();
e.printStackTrace(new PrintWriter(expected));
String actual = reply.getError(0).toString();
assertTrue(actual, actual.contains(expected.toString()));
}
Aggregations