Search in sources :

Example 31 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class SharedSourceSessionTestCase method requireThatMbusIsReleasedOnDestroy.

@Test
public void requireThatMbusIsReleasedOnDestroy() {
    Slobrok slobrok = null;
    try {
        slobrok = new Slobrok();
    } catch (ListenFailedException e) {
        fail();
    }
    RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(slobrok.configId());
    SharedMessageBus mbus = SharedMessageBus.newInstance(new MessageBusParams(), netParams);
    SharedSourceSession session = mbus.newSourceSession(new SourceSessionParams());
    mbus.release();
    session.release();
    assertFalse("MessageBus not destroyed by release().", mbus.messageBus().destroy());
}
Also used : RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) MessageBusParams(com.yahoo.messagebus.MessageBusParams) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) ListenFailedException(com.yahoo.jrt.ListenFailedException) Test(org.junit.Test)

Example 32 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class SendAdapterTestCase method setUp.

@Before
public void setUp() throws ListenFailedException, UnknownHostException {
    slobrok = new Slobrok();
    dstServer = new TestServer(new MessageBusParams().addProtocol(dstProtocol = new TestProtocol()), new RPCNetworkParams().setIdentity(new Identity("dst")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    dstSession = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
    itrServer = new TestServer(new MessageBusParams().addProtocol(itrProtocol = new TestProtocol()), new RPCNetworkParams().setIdentity(new Identity("itr")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    itrSession = itrServer.mb.createIntermediateSession(new IntermediateSessionParams().setName("session").setMessageHandler(new Receptor()).setReplyHandler(new Receptor()));
    srcServer = new TestServer(new MessageBusParams().addProtocol(srcProtocol = new TestProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(new Receptor()));
    assertTrue(srcServer.waitSlobrok("*/session", 2));
}
Also used : Receptor(com.yahoo.messagebus.test.Receptor) 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 33 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class ServicePoolTestCase method testMaxSize.

public void testMaxSize() throws ListenFailedException {
    Slobrok slobrok = new Slobrok();
    RPCNetwork net = new RPCNetwork(new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    RPCServicePool pool = new RPCServicePool(net, 2);
    pool.resolve("foo");
    assertEquals(1, pool.getSize());
    assertTrue(pool.hasService("foo"));
    assertTrue(!pool.hasService("bar"));
    assertTrue(!pool.hasService("baz"));
    pool.resolve("foo");
    assertEquals(1, pool.getSize());
    assertTrue(pool.hasService("foo"));
    assertTrue(!pool.hasService("bar"));
    assertTrue(!pool.hasService("baz"));
    pool.resolve("bar");
    assertEquals(2, pool.getSize());
    assertTrue(pool.hasService("foo"));
    assertTrue(pool.hasService("bar"));
    assertTrue(!pool.hasService("baz"));
    pool.resolve("baz");
    assertEquals(2, pool.getSize());
    assertTrue(!pool.hasService("foo"));
    assertTrue(pool.hasService("bar"));
    assertTrue(pool.hasService("baz"));
    pool.resolve("bar");
    assertEquals(2, pool.getSize());
    assertTrue(!pool.hasService("foo"));
    assertTrue(pool.hasService("bar"));
    assertTrue(pool.hasService("baz"));
    pool.resolve("foo");
    assertEquals(2, pool.getSize());
    assertTrue(pool.hasService("foo"));
    assertTrue(pool.hasService("bar"));
    assertTrue(!pool.hasService("baz"));
    slobrok.stop();
}
Also used : Slobrok(com.yahoo.jrt.slobrok.server.Slobrok)

Example 34 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok 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 35 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok 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)

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