use of com.yahoo.messagebus.shared.SharedSourceSession 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.shared.SharedSourceSession 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;
}
use of com.yahoo.messagebus.shared.SharedSourceSession in project vespa by vespa-engine.
the class DocumentProcessingHandlerTestBase method createHandler.
@Before
public void createHandler() {
documentTypeManager.register(getType());
Protocol protocol = new DocumentProtocol(documentTypeManager);
driver = ServerTestDriver.newInactiveInstanceWithProtocol(protocol);
sessionCache = new SessionCache("raw:", driver.client().slobrokId(), "test", "raw:", null, "raw:", documentTypeManager);
ContainerBuilder builder = driver.parent().newContainerBuilder();
ComponentRegistry<DocprocService> registry = new ComponentRegistry<>();
handler = new DocumentProcessingHandler(registry, new ComponentRegistry<>(), new ComponentRegistry<>(), new DocumentProcessingHandlerParameters().setDocumentTypeManager(documentTypeManager).setContainerDocumentConfig(new ContainerDocumentConfig(new ContainerDocumentConfig.Builder())));
builder.serverBindings().bind("mbus://*/*", handler);
ReferencedResource<SharedSourceSession> sessionRef = sessionCache.retainSource(new SourceSessionParams());
MbusClient sourceClient = new MbusClient(sessionRef.getResource());
builder.clientBindings().bind("mbus://*/source", sourceClient);
builder.clientBindings().bind("mbus://*/" + MbusRequestContext.internalNoThrottledSource, sourceClient);
sourceClient.start();
List<Pair<String, CallStack>> callStacks = getCallStacks();
List<AbstractResource> resources = new ArrayList<>();
for (Pair<String, CallStack> callStackPair : callStacks) {
DocprocService service = new DocprocService(callStackPair.getFirst());
service.setCallStack(callStackPair.getSecond());
service.setInService(true);
ComponentId serviceId = new ComponentId(service.getName());
registry.register(serviceId, service);
ComponentId sessionName = ComponentId.fromString("chain." + serviceId);
MbusServerProvider serviceProvider = new MbusServerProvider(sessionName, sessionCache, driver.parent());
serviceProvider.get().start();
serviceProviders.add(serviceProvider);
MbusClient intermediateClient = new MbusClient(serviceProvider.getSession());
builder.clientBindings().bind("mbus://*/" + sessionName.stringValue(), intermediateClient);
intermediateClient.start();
resources.add(intermediateClient);
}
driver.parent().activateContainer(builder);
sessionRef.getReference().close();
sourceClient.release();
for (AbstractResource resource : resources) {
resource.release();
}
remoteServer = RemoteServer.newInstance(driver.client().slobrokId(), "foobar", protocol);
}
Aggregations