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);
}
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();
}
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();
}
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());
}
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());
}
Aggregations