Search in sources :

Example 1 with DocumentProtocol

use of com.yahoo.documentapi.messagebus.protocol.DocumentProtocol 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);
}
Also used : CallStack(com.yahoo.docproc.CallStack) ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) ArrayList(java.util.ArrayList) AbstractResource(com.yahoo.jdisc.AbstractResource) DocprocService(com.yahoo.docproc.DocprocService) ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol) Protocol(com.yahoo.messagebus.Protocol) Pair(com.yahoo.collections.Pair) ContainerDocumentConfig(com.yahoo.container.core.document.ContainerDocumentConfig) MbusClient(com.yahoo.messagebus.jdisc.MbusClient) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol) SharedSourceSession(com.yahoo.messagebus.shared.SharedSourceSession) MbusServerProvider(com.yahoo.container.jdisc.messagebus.MbusServerProvider) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) SessionCache(com.yahoo.container.jdisc.messagebus.SessionCache) ComponentId(com.yahoo.component.ComponentId) Before(org.junit.Before)

Example 2 with DocumentProtocol

use of com.yahoo.documentapi.messagebus.protocol.DocumentProtocol in project vespa by vespa-engine.

the class PolicyFactoryTestCase method testFactory.

// //////////////////////////////////////////////////////////////////////////////
// 
// Tests
// 
// //////////////////////////////////////////////////////////////////////////////
public void testFactory() {
    Route route = Route.parse("[MyPolicy]");
    assertTrue(src.send(createMessage(), route).isAccepted());
    Reply reply = ((Receptor) src.getReplyHandler()).getReply(60);
    assertNotNull(reply);
    System.out.println(reply.getTrace());
    assertEquals(1, reply.getNumErrors());
    assertEquals(ErrorCode.UNKNOWN_POLICY, reply.getError(0).getCode());
    Protocol obj = srv.mb.getProtocol(DocumentProtocol.NAME);
    assertTrue(obj instanceof DocumentProtocol);
    DocumentProtocol protocol = (DocumentProtocol) obj;
    protocol.putRoutingPolicyFactory("MyPolicy", new MyFactory());
    assertTrue(src.send(createMessage(), route).isAccepted());
    assertNotNull(reply = ((Receptor) src.getReplyHandler()).getReply(60));
    System.out.println(reply.getTrace());
    assertEquals(1, reply.getNumErrors());
    assertEquals(DocumentProtocol.ERROR_POLICY_FAILURE, reply.getError(0).getCode());
}
Also used : Receptor(com.yahoo.messagebus.test.Receptor) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol) Route(com.yahoo.messagebus.routing.Route) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)

Example 3 with DocumentProtocol

use of com.yahoo.documentapi.messagebus.protocol.DocumentProtocol in project vespa by vespa-engine.

the class SessionCache method start.

private void start() {
    ContainerMbusConfig mbusConfig = ConfigGetter.getConfig(ContainerMbusConfig.class, containerMbusConfigId);
    if (documentManagerConfigId != null) {
        documentTypeManager.configure(documentManagerConfigId);
    }
    LoadTypeSet loadTypeSet = new LoadTypeSet(loadTypeConfigId);
    DocumentProtocol protocol = new DocumentProtocol(documentTypeManager, identity, loadTypeSet);
    messageBus = createSharedMessageBus(mbusConfig, slobrokConfigId, identity, protocol);
    // TODO: stop doing subscriptions to config when that is to be solved in slobrok as well
    configAgent = new ConfigAgent(messagebusConfigId, messageBus.messageBus());
    configAgent.subscribe();
}
Also used : LoadTypeSet(com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet) ContainerMbusConfig(com.yahoo.container.jdisc.ContainerMbusConfig) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)

Example 4 with DocumentProtocol

use of com.yahoo.documentapi.messagebus.protocol.DocumentProtocol in project vespa by vespa-engine.

the class PolicyFactoryTestCase method setUp.

@Override
public void setUp() throws ListenFailedException {
    slobrok = new Slobrok();
    srv = new TestServer(new MessageBusParams().addProtocol(new DocumentProtocol(new DocumentTypeManager())), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    src = srv.mb.createSourceSession(new SourceSessionParams().setReplyHandler(new Receptor()));
}
Also used : Receptor(com.yahoo.messagebus.test.Receptor) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)

Example 5 with DocumentProtocol

use of com.yahoo.documentapi.messagebus.protocol.DocumentProtocol in project vespa by vespa-engine.

the class RoutableFactoryTestCase method setUp.

@Override
public void setUp() throws ListenFailedException {
    slobrok = new Slobrok();
    DocumentTypeManager docMan = new DocumentTypeManager();
    dstProtocol = new DocumentProtocol(docMan);
    dstServer = new TestServer(new MessageBusParams().addProtocol(dstProtocol), new RPCNetworkParams().setIdentity(new Identity("dst")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    dstSession = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
    srcProtocol = new DocumentProtocol(docMan);
    srcServer = new TestServer(new MessageBusParams().addProtocol(srcProtocol), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
    srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setReplyHandler(new Receptor()));
    assertTrue(srcServer.waitSlobrok("dst/session", 1));
}
Also used : Receptor(com.yahoo.messagebus.test.Receptor) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Identity(com.yahoo.messagebus.network.Identity) DocumentProtocol(com.yahoo.documentapi.messagebus.protocol.DocumentProtocol) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Aggregations

DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)5 Receptor (com.yahoo.messagebus.test.Receptor)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)2 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)2 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)2 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)2 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 ContainerMbusConfig (com.yahoo.container.jdisc.ContainerMbusConfig)1 MbusServerProvider (com.yahoo.container.jdisc.messagebus.MbusServerProvider)1 SessionCache (com.yahoo.container.jdisc.messagebus.SessionCache)1 CallStack (com.yahoo.docproc.CallStack)1 DocprocService (com.yahoo.docproc.DocprocService)1 LoadTypeSet (com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)1 AbstractResource (com.yahoo.jdisc.AbstractResource)1 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)1 Protocol (com.yahoo.messagebus.Protocol)1 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)1