Search in sources :

Example 1 with SourceSessionParams

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);
}
Also used : StaticThrottlePolicy(com.yahoo.messagebus.StaticThrottlePolicy) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams)

Example 2 with SourceSessionParams

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();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Message(com.yahoo.messagebus.Message) ReplyQueue(com.yahoo.messagebus.jdisc.test.ReplyQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) RemoteServer(com.yahoo.messagebus.jdisc.test.RemoteServer) Test(org.junit.Test)

Example 3 with SourceSessionParams

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());
}
Also used : SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) Test(org.junit.Test)

Example 4 with SourceSessionParams

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;
}
Also used : MessageBus(com.yahoo.messagebus.MessageBus) SharedMessageBus(com.yahoo.messagebus.shared.SharedMessageBus) SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) LocalNetwork(com.yahoo.messagebus.network.local.LocalNetwork) SharedMessageBus(com.yahoo.messagebus.shared.SharedMessageBus) MessageBusParams(com.yahoo.messagebus.MessageBusParams) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) SharedSourceSession(com.yahoo.messagebus.shared.SharedSourceSession)

Example 5 with SourceSessionParams

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;
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) DataType(com.yahoo.document.DataType) ReplyContext(com.yahoo.vespa.http.server.ReplyContext) DocumentType(com.yahoo.document.DocumentType) OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus) Assert.assertThat(org.junit.Assert.assertThat) Answer(org.mockito.stubbing.Answer) ByteArrayInputStream(java.io.ByteArrayInputStream) SharedSourceSession(com.yahoo.messagebus.shared.SharedSourceSession) ErrorCode(com.yahoo.vespa.http.client.core.ErrorCode) Matchers.anyObject(org.mockito.Matchers.anyObject) SessionCache(com.yahoo.container.jdisc.messagebus.SessionCache) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) MetricReceiver(com.yahoo.metrics.simple.MetricReceiver) Splitter(com.google.common.base.Splitter) FeedHandlerV3(com.yahoo.vespa.http.server.FeedHandlerV3) Executor(java.util.concurrent.Executor) Utf8(com.yahoo.text.Utf8) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) AccessLog(com.yahoo.container.logging.AccessLog) HttpRequest(com.yahoo.container.jdisc.HttpRequest) FeedParams(com.yahoo.vespa.http.client.config.FeedParams) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) ReferencedResource(com.yahoo.jdisc.ReferencedResource) Executors(java.util.concurrent.Executors) Result(com.yahoo.messagebus.Result) DocumentApiMetrics(com.yahoo.documentapi.metrics.DocumentApiMetrics) Mockito(org.mockito.Mockito) Headers(com.yahoo.vespa.http.client.core.Headers) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) HttpResponse(com.yahoo.container.jdisc.HttpResponse) InputStream(java.io.InputStream) Mockito.mock(org.mockito.Mockito.mock) ReferencedResource(com.yahoo.jdisc.ReferencedResource) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) SharedSourceSession(com.yahoo.messagebus.shared.SharedSourceSession) Result(com.yahoo.messagebus.Result) FeedHandlerV3(com.yahoo.vespa.http.server.FeedHandlerV3) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) Executor(java.util.concurrent.Executor) DocumentmanagerConfig(com.yahoo.document.config.DocumentmanagerConfig) DocumentApiMetrics(com.yahoo.documentapi.metrics.DocumentApiMetrics) OperationStatus(com.yahoo.vespa.http.client.core.OperationStatus) ReplyContext(com.yahoo.vespa.http.server.ReplyContext) SessionCache(com.yahoo.container.jdisc.messagebus.SessionCache) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric)

Aggregations

SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)13 Test (org.junit.Test)5 SharedSourceSession (com.yahoo.messagebus.shared.SharedSourceSession)3 SessionCache (com.yahoo.container.jdisc.messagebus.SessionCache)2 DocumentApiMetrics (com.yahoo.documentapi.metrics.DocumentApiMetrics)2 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)2 MessageBusParams (com.yahoo.messagebus.MessageBusParams)2 Before (org.junit.Before)2 Splitter (com.google.common.base.Splitter)1 Pair (com.yahoo.collections.Pair)1 ComponentId (com.yahoo.component.ComponentId)1 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)1 ContainerDocumentConfig (com.yahoo.container.core.document.ContainerDocumentConfig)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 MbusServerProvider (com.yahoo.container.jdisc.messagebus.MbusServerProvider)1 SourceSessionKey (com.yahoo.container.jdisc.messagebus.SessionCache.SourceSessionKey)1 AccessLog (com.yahoo.container.logging.AccessLog)1 CallStack (com.yahoo.docproc.CallStack)1 DocprocService (com.yahoo.docproc.DocprocService)1