Search in sources :

Example 1 with CallStack

use of com.yahoo.docproc.CallStack in project vespa by vespa-engine.

the class VespaFeedHandlerTestCase method setup.

public void setup(com.yahoo.messagebus.Error e, LoadTypeConfig loadTypeCfg, boolean autoReply, DummySessionFactory.ReplyFactory autoReplyFactory) throws Exception {
    DocumentTypeManager docMan = new DocumentTypeManager();
    DocumentTypeManagerConfigurer.configure(docMan, "file:" + xmlFilesPath + "documentmanager.cfg");
    if (autoReply) {
        if (autoReplyFactory != null) {
            factory = DummySessionFactory.createWithAutoReplyFactory(autoReplyFactory);
        } else {
            factory = DummySessionFactory.createWithErrorAutoReply(e);
        }
    } else {
        factory = DummySessionFactory.createDefault();
    }
    context = new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder()), loadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric());
    Executor threadPool = Executors.newCachedThreadPool();
    feedHandler = new VespaFeedHandler(context, threadPool);
    removeHandler = new VespaFeedHandlerRemove(context, threadPool);
    statusHandler = new VespaFeedHandlerStatus(context, false, false, threadPool);
    removeLocationHandler = new VespaFeedHandlerRemoveLocation(context, threadPool);
    CallStack dpCallstack = new CallStack("bar");
    dpCallstack.addLast(new TestDocProc());
    dpCallstack.addLast(new TestLaterDocProc());
    DocprocService myservice = new DocprocService("bar");
    myservice.setCallStack(dpCallstack);
    myservice.setInService(true);
    ComponentRegistry<DocprocService> registry = new ComponentRegistry<DocprocService>();
    registry.register(new ComponentId(myservice.getName()), myservice);
    DocumentProcessingHandler handler = new DocumentProcessingHandler(registry, new ComponentRegistry<>(), new ComponentRegistry<>(), new DocumentProcessingHandlerParameters());
    Container container = Container.get();
    ComponentRegistry<RequestHandler> requestHandlerComponentRegistry = new ComponentRegistry<>();
    requestHandlerComponentRegistry.register(new ComponentId(DocumentProcessingHandler.class.getName()), handler);
    container.setRequestHandlerRegistry(requestHandlerComponentRegistry);
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) CallStack(com.yahoo.docproc.CallStack) FeederConfig(com.yahoo.vespaclient.config.FeederConfig) Container(com.yahoo.container.Container) Executor(java.util.concurrent.Executor) DocumentProcessingHandler(com.yahoo.docproc.jdisc.DocumentProcessingHandler) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) RequestHandler(com.yahoo.jdisc.handler.RequestHandler) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) FeedContext(com.yahoo.feedapi.FeedContext) ComponentId(com.yahoo.component.ComponentId) DocumentProcessingHandlerParameters(com.yahoo.docproc.jdisc.DocumentProcessingHandlerParameters)

Example 2 with CallStack

use of com.yahoo.docproc.CallStack in project vespa by vespa-engine.

the class DocprocMessageProcessor method processDocumentOperations.

public void processDocumentOperations(List<DocumentOperation> documentOperations, Message m) throws Exception {
    Processing processing = Processing.createProcessingFromDocumentOperations(docproc.getName(), documentOperations, new CallStack(docproc.getCallStack()));
    processing.setServiceName(docproc.getName());
    processing.setDocprocServiceRegistry(docprocServiceRegistry);
    processing.setVariable("route", m.getRoute());
    processing.setVariable("timeout", m.getTimeRemaining());
    DocumentProcessor.Progress progress = docproc.getExecutor().process(processing);
    while (DocumentProcessor.Progress.LATER.equals(progress)) {
        Thread.sleep(50);
        progress = docproc.getExecutor().process(processing);
    }
    if (progress == DocumentProcessor.Progress.FAILED || progress == DocumentProcessor.Progress.PERMANENT_FAILURE) {
        throw new RuntimeException("Processing of " + documentOperations + " failed: " + progress + ".");
    }
    m.setRoute((Route) processing.getVariable("route"));
    m.setTimeRemaining((Long) processing.getVariable("timeout"));
}
Also used : CallStack(com.yahoo.docproc.CallStack) DocumentProcessor(com.yahoo.docproc.DocumentProcessor) Processing(com.yahoo.docproc.Processing)

Example 3 with CallStack

use of com.yahoo.docproc.CallStack in project vespa by vespa-engine.

the class DocumentProcessingHandlerAllMessageTypesTestCase method getCallStacks.

@Override
public List<Pair<String, CallStack>> getCallStacks() {
    CallStack stack = new CallStack();
    stack.addLast(new YallaDocumentProcessor());
    stack.addLast(new WaitingDefaultDocumentProcessor());
    stack.addLast(new WaitingCustomDocumentProcessor());
    ArrayList<Pair<String, CallStack>> stacks = new ArrayList<>(1);
    stacks.add(new Pair<>(FOOBAR, stack));
    return stacks;
}
Also used : CallStack(com.yahoo.docproc.CallStack) ArrayList(java.util.ArrayList) Pair(com.yahoo.collections.Pair)

Example 4 with CallStack

use of com.yahoo.docproc.CallStack 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 5 with CallStack

use of com.yahoo.docproc.CallStack in project vespa by vespa-engine.

the class DocumentProcessingHandler method convertToCallStack.

private static CallStack convertToCallStack(Chain<DocumentProcessor> chain, Statistics statistics, Metric metric) {
    CallStack stack = new CallStack(chain.getId().stringValue(), statistics, metric);
    for (DocumentProcessor processor : chain.components()) {
        processor.getFieldMap().putAll(DocprocService.schemaMap.chainMap(chain.getId().stringValue(), processor.getId().stringValue()));
        stack.addLast(processor);
    }
    return stack;
}
Also used : CallStack(com.yahoo.docproc.CallStack) DocumentProcessor(com.yahoo.docproc.DocumentProcessor)

Aggregations

CallStack (com.yahoo.docproc.CallStack)9 Pair (com.yahoo.collections.Pair)5 ArrayList (java.util.ArrayList)5 DocumentProcessor (com.yahoo.docproc.DocumentProcessor)3 ComponentId (com.yahoo.component.ComponentId)2 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)2 Processing (com.yahoo.docproc.Processing)2 Tuple2 (com.yahoo.collections.Tuple2)1 Container (com.yahoo.container.Container)1 ContainerDocumentConfig (com.yahoo.container.core.document.ContainerDocumentConfig)1 MbusServerProvider (com.yahoo.container.jdisc.messagebus.MbusServerProvider)1 SessionCache (com.yahoo.container.jdisc.messagebus.SessionCache)1 Call (com.yahoo.docproc.Call)1 DocprocService (com.yahoo.docproc.DocprocService)1 HandledProcessingException (com.yahoo.docproc.HandledProcessingException)1 DocumentProcessingHandler (com.yahoo.docproc.jdisc.DocumentProcessingHandler)1 DocumentProcessingHandlerParameters (com.yahoo.docproc.jdisc.DocumentProcessingHandlerParameters)1 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)1 FeedContext (com.yahoo.feedapi.FeedContext)1 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)1