use of com.yahoo.messagebus.SourceSessionParams in project vespa by vespa-engine.
the class SimpleFeeder method newSession.
private static SourceSession newSession(RPCMessageBus mbus, ReplyHandler replyHandler, boolean serial) {
SourceSessionParams params = new SourceSessionParams();
params.setReplyHandler(replyHandler);
if (serial) {
params.setThrottlePolicy(new StaticThrottlePolicy().setMaxPendingCount(1));
}
return mbus.getMessageBus().createSourceSession(params);
}
use of com.yahoo.messagebus.SourceSessionParams in project vespa by vespa-engine.
the class SharedSourceSessionTestCase method requireThatSessionCanSendMessage.
@Test
public void requireThatSessionCanSendMessage() throws InterruptedException {
RemoteServer server = RemoteServer.newInstanceWithInternSlobrok();
SharedSourceSession session = newSourceSession(server.slobrokId(), new SourceSessionParams());
ReplyQueue queue = new ReplyQueue();
Message msg = new SimpleMessage("foo").setRoute(Route.parse(server.connectionSpec()));
msg.pushHandler(queue);
assertTrue(session.sendMessage(msg).isAccepted());
assertNotNull(msg = server.awaitMessage(60, TimeUnit.SECONDS));
server.ackMessage(msg);
assertNotNull(queue.awaitReply(60, TimeUnit.SECONDS));
session.release();
server.close();
}
use of com.yahoo.messagebus.SourceSessionParams in project vespa by vespa-engine.
the class SharedSourceSessionTestCase method requireThatSessionIsClosedOnDestroy.
@Test
public void requireThatSessionIsClosedOnDestroy() {
SharedSourceSession session = newSourceSession(new SourceSessionParams());
session.release();
assertFalse("SourceSession not destroyed by release().", session.session().destroy());
}
use of com.yahoo.messagebus.SourceSessionParams in project vespa by vespa-engine.
the class ClientThreadingTestCase method newMbusClient.
private static MbusClient newMbusClient(final LocalWire wire) {
final SharedMessageBus mbus = new SharedMessageBus(new MessageBus(new LocalNetwork(wire), new MessageBusParams().addProtocol(new SimpleProtocol())));
final SharedSourceSession session = mbus.newSourceSession(new SourceSessionParams());
final MbusClient client = new MbusClient(session);
session.release();
mbus.release();
return client;
}
use of com.yahoo.messagebus.SourceSessionParams in project vespa by vespa-engine.
the class FeedTesterV3 method setupFeederHandler.
FeedHandlerV3 setupFeederHandler() throws Exception {
Executor threadPool = Executors.newCachedThreadPool();
DocumentmanagerConfig docMan = new DocumentmanagerConfig(new DocumentmanagerConfig.Builder().enablecompression(true));
FeedHandlerV3 feedHandlerV3 = new FeedHandlerV3(new FeedHandlerV3.Context(threadPool, AccessLog.voidAccessLog(), new NullFeedMetric()), docMan, null, /* session cache */
null, /* thread pool config */
new DocumentApiMetrics(MetricReceiver.nullImplementation, "test")) {
@Override
protected ReferencedResource<SharedSourceSession> retainSource(SessionCache sessionCache, SourceSessionParams sessionParams) {
SharedSourceSession sharedSourceSession = mock(SharedSourceSession.class);
try {
Mockito.stub(sharedSourceSession.sendMessageBlocking(anyObject())).toAnswer((Answer) invocation -> {
Object[] args = invocation.getArguments();
PutDocumentMessage putDocumentMessage = (PutDocumentMessage) args[0];
ReplyContext replyContext = (ReplyContext) putDocumentMessage.getContext();
replyContext.feedReplies.add(new OperationStatus("message", replyContext.docId, ErrorCode.OK, false, "trace"));
Result result = mock(Result.class);
when(result.isAccepted()).thenReturn(true);
return result;
});
} catch (InterruptedException e) {
e.printStackTrace();
}
Result result = mock(Result.class);
when(result.isAccepted()).thenReturn(true);
ReferencedResource<SharedSourceSession> refSharedSessopn = new ReferencedResource<>(sharedSourceSession, () -> {
});
return refSharedSessopn;
}
};
feedHandlerV3.injectDocumentManangerForTests(createDoctypeManager());
return feedHandlerV3;
}
Aggregations