Search in sources :

Example 11 with Slobrok

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);
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) RPCNetwork(com.yahoo.messagebus.network.rpc.RPCNetwork) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) RoutingPolicy(com.yahoo.messagebus.routing.RoutingPolicy) Spec(com.yahoo.jrt.Spec) CustomPolicyFactory(com.yahoo.messagebus.routing.test.CustomPolicyFactory) Test(org.junit.Test)

Example 12 with Slobrok

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();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) SimpleReply(com.yahoo.messagebus.test.SimpleReply) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 13 with Slobrok

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);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 14 with Slobrok

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);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 15 with Slobrok

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()));
}
Also used : Utf8String(com.yahoo.text.Utf8String) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) StringWriter(java.io.StringWriter) Receptor(com.yahoo.messagebus.test.Receptor) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)43 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)23 Test (org.junit.Test)20 Receptor (com.yahoo.messagebus.test.Receptor)17 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)15 Identity (com.yahoo.messagebus.network.Identity)12 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)11 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)6 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)4 Before (org.junit.Before)4 ListenFailedException (com.yahoo.jrt.ListenFailedException)3 Spec (com.yahoo.jrt.Spec)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 MessageBusParams (com.yahoo.messagebus.MessageBusParams)2 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)2 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2 MessageBusDocumentAccess (com.yahoo.documentapi.messagebus.MessageBusDocumentAccess)1 MessageBusParams (com.yahoo.documentapi.messagebus.MessageBusParams)1 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)1