Search in sources :

Example 21 with SimpleProtocol

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

the class SharedSourceSessionTestCase method newSourceSession.

private static SharedSourceSession newSourceSession(String slobrokId, SourceSessionParams params) {
    RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(slobrokId);
    MessageBusParams mbusParams = new MessageBusParams().addProtocol(new SimpleProtocol());
    SharedMessageBus mbus = SharedMessageBus.newInstance(mbusParams, netParams);
    SharedSourceSession session = mbus.newSourceSession(params);
    mbus.release();
    return session;
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) MessageBusParams(com.yahoo.messagebus.MessageBusParams)

Example 22 with SimpleProtocol

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

the class ChokeTestCase method setUp.

@Before
public void setUp() throws ListenFailedException, UnknownHostException {
    slobrok = new Slobrok();
    dstServer = new TestServer(new MessageBusParams().addProtocol(new SimpleProtocol()), new RPCNetworkParams().setIdentity(new Identity("dst")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    dstSession = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
    srcServer = new TestServer(new MessageBusParams().setRetryPolicy(null).addProtocol(new SimpleProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setThrottlePolicy(null).setReplyHandler(new Receptor()));
    assertTrue(srcServer.waitSlobrok("dst/session", 1));
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Receptor(com.yahoo.messagebus.test.Receptor) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Identity(com.yahoo.messagebus.network.Identity) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Before(org.junit.Before)

Example 23 with SimpleProtocol

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

the class MessageBusTestCase method requireThatBucketSequencingWithResenderEnabledCausesError.

@Test
public void requireThatBucketSequencingWithResenderEnabledCausesError() throws ListenFailedException {
    Slobrok slobrok = new Slobrok();
    TestServer server = new TestServer(new MessageBusParams().addProtocol(new SimpleProtocol()).setRetryPolicy(new RetryTransientErrorsPolicy()), new RPCNetworkParams().setSlobrokConfigId(slobrok.configId()));
    Receptor receptor = new Receptor();
    SourceSession session = server.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(receptor));
    assertTrue(session.send(new SimpleMessage("foo") {

        @Override
        public boolean hasBucketSequence() {
            return true;
        }
    }.setRoute(Route.parse("bar"))).isAccepted());
    Reply reply = receptor.getReply(60);
    assertNotNull(reply);
    assertEquals(1, reply.getNumErrors());
    assertEquals(ErrorCode.SEQUENCE_ERROR, reply.getError(0).getCode());
    session.destroy();
    server.destroy();
    slobrok.stop();
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Receptor(com.yahoo.messagebus.test.Receptor) RetryTransientErrorsPolicy(com.yahoo.messagebus.routing.RetryTransientErrorsPolicy) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Test(org.junit.Test)

Example 24 with SimpleProtocol

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

the class RoutingContextTestCase method testMoreDirectives.

public void testMoreDirectives() {
    SimpleProtocol protocol = new SimpleProtocol();
    protocol.addPolicyFactory("Custom", new CustomPolicyFactory(false, Arrays.asList("foo", "foo/bar", "foo/bar0/baz", "foo/bar1/baz", "foo/bar/baz/cox"), Arrays.asList("foo/bar0/baz", "foo/bar1/baz")));
    srcServer.mb.putProtocol(protocol);
    srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("myroute").addHop("myhop")).addHop(new HopSpec("myhop", "foo/[Custom]/baz").addRecipient("foo").addRecipient("foo/bar").addRecipient("foo/bar0/baz").addRecipient("foo/bar1/baz").addRecipient("foo/bar/baz/cox")));
    for (int i = 0; i < 2; ++i) {
        assertTrue(srcSession.send(createMessage("msg"), "myroute").isAccepted());
        Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT_SECS);
        assertNotNull(reply);
        System.out.println(reply.getTrace());
        assertFalse(reply.hasErrors());
    }
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Receptor(com.yahoo.messagebus.test.Receptor)

Example 25 with SimpleProtocol

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

the class RoutingContextTestCase method testConstRoute.

public void testConstRoute() {
    SimpleProtocol protocol = new SimpleProtocol();
    protocol.addPolicyFactory("DocumentRouteSelector", new CustomPolicyFactory(true, Arrays.asList("dst"), Arrays.asList("dst")));
    srcServer.mb.putProtocol(protocol);
    srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("default").addHop("indexing")).addHop(new HopSpec("indexing", "[DocumentRouteSelector]").addRecipient("dst")).addHop(new HopSpec("dst", "dst/session")));
    for (int i = 0; i < 2; ++i) {
        assertTrue(srcSession.send(createMessage("msg"), Route.parse("route:default")).isAccepted());
        Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(TIMEOUT_SECS);
        assertNotNull(msg);
        dstSession.acknowledge(msg);
        Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT_SECS);
        assertNotNull(reply);
        System.out.println(reply.getTrace());
        assertFalse(reply.hasErrors());
    }
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor)

Aggregations

SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)44 Receptor (com.yahoo.messagebus.test.Receptor)30 Test (org.junit.Test)26 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)15 CustomPolicyFactory (com.yahoo.messagebus.routing.test.CustomPolicyFactory)13 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)12 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)11 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)8 Identity (com.yahoo.messagebus.network.Identity)7 Error (com.yahoo.messagebus.Error)5 RoutingPolicy (com.yahoo.messagebus.routing.RoutingPolicy)4 MessageBusParams (com.yahoo.messagebus.MessageBusParams)3 MessageBus (com.yahoo.messagebus.MessageBus)2 LocalNetwork (com.yahoo.messagebus.network.local.LocalNetwork)2 SharedMessageBus (com.yahoo.messagebus.shared.SharedMessageBus)2 Before (org.junit.Before)2 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)1 Spec (com.yahoo.jrt.Spec)1 DestinationSessionParams (com.yahoo.messagebus.DestinationSessionParams)1 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)1