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);
}
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"));
}
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;
}
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);
}
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;
}
Aggregations