Search in sources :

Example 16 with RPCNetworkParams

use of com.yahoo.messagebus.network.rpc.RPCNetworkParams 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 17 with RPCNetworkParams

use of com.yahoo.messagebus.network.rpc.RPCNetworkParams in project vespa by vespa-engine.

the class SendProxyTestCase method setUp.

@Override
public void setUp() throws UnknownHostException, ListenFailedException {
    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().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)

Example 18 with RPCNetworkParams

use of com.yahoo.messagebus.network.rpc.RPCNetworkParams in project vespa by vespa-engine.

the class SimpleTripTestCase method testSimpleTrip.

public void testSimpleTrip() throws ListenFailedException, UnknownHostException {
    Slobrok slobrok = new Slobrok();
    TestServer server = new TestServer(new MessageBusParams().addProtocol(new SimpleProtocol()), new RPCNetworkParams().setIdentity(new Identity("srv")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    DestinationSession dst = server.mb.createDestinationSession(new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
    SourceSession src = server.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(new Receptor()));
    assertTrue(server.waitSlobrok("srv/session", 1));
    assertTrue(src.send(new SimpleMessage("msg"), Route.parse("srv/session")).isAccepted());
    Message msg = ((Receptor) dst.getMessageHandler()).getMessage(60);
    assertNotNull(msg);
    assertEquals(SimpleProtocol.NAME, msg.getProtocol());
    assertEquals(SimpleProtocol.MESSAGE, msg.getType());
    assertEquals("msg", ((SimpleMessage) msg).getValue());
    Reply reply = new SimpleReply("reply");
    reply.swapState(msg);
    dst.reply(reply);
    assertNotNull(reply = ((Receptor) src.getReplyHandler()).getReply(60));
    assertEquals(SimpleProtocol.NAME, reply.getProtocol());
    assertEquals(SimpleProtocol.REPLY, reply.getType());
    assertEquals("reply", ((SimpleReply) reply).getValue());
    src.destroy();
    dst.destroy();
    server.destroy();
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) 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) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Identity(com.yahoo.messagebus.network.Identity)

Example 19 with RPCNetworkParams

use of com.yahoo.messagebus.network.rpc.RPCNetworkParams in project vespa by vespa-engine.

the class PolicyFactoryTestCase method setUp.

@Override
public void setUp() throws ListenFailedException {
    slobrok = new Slobrok();
    srv = new TestServer(new MessageBusParams().addProtocol(new DocumentProtocol(new DocumentTypeManager())), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    src = srv.mb.createSourceSession(new SourceSessionParams().setReplyHandler(new Receptor()));
}
Also used : Receptor(com.yahoo.messagebus.test.Receptor) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)

Example 20 with RPCNetworkParams

use of com.yahoo.messagebus.network.rpc.RPCNetworkParams in project vespa by vespa-engine.

the class RoutableFactoryTestCase method setUp.

@Override
public void setUp() throws ListenFailedException {
    slobrok = new Slobrok();
    DocumentTypeManager docMan = new DocumentTypeManager();
    dstProtocol = new DocumentProtocol(docMan);
    dstServer = new TestServer(new MessageBusParams().addProtocol(dstProtocol), new RPCNetworkParams().setIdentity(new Identity("dst")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    dstSession = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
    srcProtocol = new DocumentProtocol(docMan);
    srcServer = new TestServer(new MessageBusParams().addProtocol(srcProtocol), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setReplyHandler(new Receptor()));
    assertTrue(srcServer.waitSlobrok("dst/session", 1));
}
Also used : Receptor(com.yahoo.messagebus.test.Receptor) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Identity(com.yahoo.messagebus.network.Identity) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Aggregations

RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)20 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)15 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)12 Identity (com.yahoo.messagebus.network.Identity)10 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)10 Receptor (com.yahoo.messagebus.test.Receptor)10 Test (org.junit.Test)6 ListenFailedException (com.yahoo.jrt.ListenFailedException)3 MessageBusParams (com.yahoo.messagebus.MessageBusParams)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)2 Before (org.junit.Before)2 DaemonThreadFactory (com.yahoo.concurrent.DaemonThreadFactory)1 ThroughputLimitQueue (com.yahoo.documentapi.ThroughputLimitQueue)1 MessageBusDocumentAccess (com.yahoo.documentapi.messagebus.MessageBusDocumentAccess)1 MessageBusParams (com.yahoo.documentapi.messagebus.MessageBusParams)1 LoadTypeSet (com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)1 Spec (com.yahoo.jrt.Spec)1 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)1