Search in sources :

Example 1 with TestServer

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

the class RoutingContextTestCase method setUp.

@Override
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(new RetryTransientErrorsPolicy().setBaseDelay(0)).addProtocol(new SimpleProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).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 2 with TestServer

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

the class RoutingTestCase 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()));
    retryPolicy = new RetryTransientErrorsPolicy();
    retryPolicy.setBaseDelay(0);
    srcServer = new TestServer(new MessageBusParams().setRetryPolicy(retryPolicy).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 3 with TestServer

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

the class TraceTripTestCase method setUp.

public void setUp() throws ListenFailedException, UnknownHostException {
    RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME).addHop("pxy", "test/pxy/session", Arrays.asList("test/pxy/session")).addHop("dst", "test/dst/session", Arrays.asList("test/dst/session")).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 4 with TestServer

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

the class LoadBalanceTestCase method testLoadBalance.

public void testLoadBalance() throws ListenFailedException, UnknownHostException {
    Slobrok slobrok = new Slobrok();
    TestServer src = new TestServer("src", null, slobrok, null);
    TestServer dst1 = new TestServer("dst/1", null, slobrok, null);
    TestServer dst2 = new TestServer("dst/2", null, slobrok, null);
    TestServer dst3 = new TestServer("dst/3", null, slobrok, null);
    // set up handlers
    final QueueAdapter sq = new QueueAdapter();
    SourceSession ss = src.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setThrottlePolicy(null).setReplyHandler(new ReplyHandler() {

        @Override
        public void handleReply(Reply reply) {
            System.out.println(Thread.currentThread().getName() + ": Reply '" + ((SimpleMessage) reply.getMessage()).getValue() + "' received at source.");
            sq.handleReply(reply);
        }
    }));
    SimpleDestination h1 = new SimpleDestination(dst1.mb, dst1.net.getIdentity());
    SimpleDestination h2 = new SimpleDestination(dst2.mb, dst2.net.getIdentity());
    SimpleDestination h3 = new SimpleDestination(dst3.mb, dst3.net.getIdentity());
    assertTrue(src.waitSlobrok("dst/*/session", 3));
    // send messages
    // should be divisible by 3
    int msgCnt = 30;
    for (int i = 0; i < msgCnt; ++i) {
        ss.send(new SimpleMessage("msg" + i), Route.parse("dst/*/session"));
    }
    // wait for replies
    assertTrue(sq.waitSize(msgCnt, 60));
    // check handler message distribution
    assertEquals(msgCnt / 3, h1.getCount());
    assertEquals(msgCnt / 3, h2.getCount());
    assertEquals(msgCnt / 3, h3.getCount());
    ss.destroy();
    h1.session.destroy();
    h2.session.destroy();
    h3.session.destroy();
    dst3.destroy();
    dst2.destroy();
    dst1.destroy();
    src.destroy();
    slobrok.stop();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) QueueAdapter(com.yahoo.messagebus.test.QueueAdapter) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 5 with TestServer

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

the class ResenderTestCase method setUp.

@Override
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()));
    retryPolicy = new RetryTransientErrorsPolicy();
    retryPolicy.setBaseDelay(0);
    srcServer = new TestServer(new MessageBusParams().setRetryPolicy(retryPolicy).addProtocol(new SimpleProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).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)

Aggregations

TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)24 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)23 Receptor (com.yahoo.messagebus.test.Receptor)17 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)10 Identity (com.yahoo.messagebus.network.Identity)9 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)8 Test (org.junit.Test)8 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)6 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)4 Before (org.junit.Before)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2 RetryTransientErrorsPolicy (com.yahoo.messagebus.routing.RetryTransientErrorsPolicy)1 QueueAdapter (com.yahoo.messagebus.test.QueueAdapter)1 Utf8String (com.yahoo.text.Utf8String)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1