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