Search in sources :

Example 26 with Slobrok

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

the class PolicyTestCase method requireThatExternPolicyWithUnknownPatternSelectsNone.

@Test
public void requireThatExternPolicyWithUnknownPatternSelectsNone() throws Exception {
    PolicyTestFrame frame = newPutDocumentFrame("doc:scheme:");
    setupExternPolicy(frame, new Slobrok(), "foo/bar");
    frame.assertSelect(null);
}
Also used : Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Test(org.junit.Test)

Example 27 with Slobrok

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

the class PolicyTestCase method testExternMultipleSlobroks.

@Test
public void testExternMultipleSlobroks() throws ListenFailedException {
    Slobrok local = new Slobrok();
    TestServer srcServer = new TestServer("src", null, local, new DocumentProtocol(manager));
    SourceSession srcSession = srcServer.mb.createSourceSession(new Receptor(), new SourceSessionParams().setTimeout(TIMEOUT));
    Slobrok extern = new Slobrok();
    String spec = "tcp/localhost:" + extern.port();
    TestServer dstServer = new TestServer("dst", null, extern, new DocumentProtocol(manager));
    Receptor dstHandler = new Receptor();
    DestinationSession dstSession = dstServer.mb.createDestinationSession("session", true, dstHandler);
    Message msg = new RemoveDocumentMessage(new DocumentId("doc:scheme:"));
    msg.setRoute(Route.parse("[Extern:" + spec + ";dst/session]"));
    assertTrue(srcSession.send(msg).isAccepted());
    assertNotNull(msg = dstHandler.getMessage(TIMEOUT));
    dstSession.acknowledge(msg);
    Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT);
    assertNotNull(reply);
    extern.stop();
    dstSession.destroy();
    dstServer.destroy();
    dstHandler.reset();
    assertNull(dstHandler.getMessage(0));
    extern = new Slobrok();
    spec += ",tcp/localhost:" + extern.port();
    dstServer = new TestServer("dst", null, extern, new DocumentProtocol(manager));
    dstHandler = new Receptor();
    dstSession = dstServer.mb.createDestinationSession("session", true, dstHandler);
    msg = new RemoveDocumentMessage(new DocumentId("doc:scheme:"));
    msg.setRoute(Route.parse("[Extern:" + spec + ";dst/session]"));
    assertTrue(srcSession.send(msg).isAccepted());
    assertNotNull(msg = dstHandler.getMessage(TIMEOUT));
    dstSession.acknowledge(msg);
    reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT);
    assertNotNull(reply);
    extern.stop();
    dstSession.destroy();
    dstServer.destroy();
    local.stop();
    srcSession.destroy();
    srcServer.destroy();
}
Also used : Receptor(com.yahoo.messagebus.test.Receptor) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Test(org.junit.Test)

Example 28 with Slobrok

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

the class PolicyTestCase method requireThatExternPolicySelectsFromExternSlobrok.

@Test
public void requireThatExternPolicySelectsFromExternSlobrok() throws Exception {
    PolicyTestFrame frame = newPutDocumentFrame("doc:scheme:");
    Slobrok slobrok = new Slobrok();
    List<TestServer> servers = new ArrayList<>();
    for (int i = 0; i < 10; ++i) {
        TestServer server = new TestServer("docproc/cluster.default/" + i, null, slobrok, new DocumentProtocol(manager));
        server.net.registerSession("chain.default");
        servers.add(server);
    }
    setupExternPolicy(frame, slobrok, "docproc/cluster.default/*/chain.default", 10);
    Set<String> lst = new HashSet<>();
    for (int i = 0; i < 10; ++i) {
        RoutingNode leaf = frame.select(1).get(0);
        String recipient = leaf.getRoute().toString();
        lst.add(recipient);
        leaf.handleReply(new EmptyReply());
        assertNotNull(frame.getReceptor().getReply(TIMEOUT));
    }
    assertEquals(10, lst.size());
    for (TestServer server : servers) {
        server.destroy();
    }
    frame.destroy();
}
Also used : Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Test(org.junit.Test)

Example 29 with Slobrok

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

the class MessageBusDocumentApiTestCase method setUp.

@Before
public void setUp() throws ListenFailedException {
    slobrok = new Slobrok();
    String slobrokConfigId = "raw:slobrok[1]\n" + "slobrok[0].connectionspec tcp/localhost:" + slobrok.port() + "\n";
    MessageBusParams params = new MessageBusParams();
    params.getRPCNetworkParams().setIdentity(new Identity("test/feeder"));
    params.getRPCNetworkParams().setSlobrokConfigId(slobrokConfigId);
    params.setDocumentManagerConfigId("file:src/test/cfg/documentmanager.cfg");
    params.setRouteName("Route");
    params.setRoutingConfigId("file:src/test/cfg/messagebus.cfg");
    params.setTraceLevel(9);
    params.setSourceSessionParams(new SourceSessionParams().setThrottlePolicy(null));
    access = new MessageBusDocumentAccess(params);
    destination = new VisitableDestination(slobrokConfigId, params.getDocumentManagerConfigId());
}
Also used : MessageBusDocumentAccess(com.yahoo.documentapi.messagebus.MessageBusDocumentAccess) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) MessageBusParams(com.yahoo.documentapi.messagebus.MessageBusParams) Identity(com.yahoo.messagebus.network.Identity) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) Before(org.junit.Before)

Example 30 with Slobrok

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

the class SharedIntermediateSessionTestCase 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);
    SharedIntermediateSession session = mbus.newIntermediateSession(new IntermediateSessionParams());
    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) ListenFailedException(com.yahoo.jrt.ListenFailedException) 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