Search in sources :

Example 1 with ComponentRegistry

use of com.yahoo.component.provider.ComponentRegistry in project vespa by vespa-engine.

the class FederationSearcherTestCase method twoTracingSources.

private Chain<Searcher> twoTracingSources(boolean strictContracts) {
    addChained(new Searcher() {

        @Override
        public Result search(Query query, Execution execution) {
            query.trace(SOURCE1, 1);
            return execution.search(query);
        }
    }, SOURCE1);
    addChained(new Searcher() {

        @Override
        public Result search(Query query, Execution execution) {
            query.trace(SOURCE2, 1);
            return execution.search(query);
        }
    }, SOURCE2);
    Chain<Searcher> mainChain = new Chain<>("default", new FederationSearcher(new FederationConfig(builder), new StrictContractsConfig(new StrictContractsConfig.Builder().searchchains(strictContracts)), new ComponentRegistry<>()));
    return mainChain;
}
Also used : StrictContractsConfig(com.yahoo.search.federation.StrictContractsConfig) Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) Execution(com.yahoo.search.searchchain.Execution) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Query(com.yahoo.search.Query) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) FederationConfig(com.yahoo.search.federation.FederationConfig) Result(com.yahoo.search.Result)

Example 2 with ComponentRegistry

use of com.yahoo.component.provider.ComponentRegistry 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 3 with ComponentRegistry

use of com.yahoo.component.provider.ComponentRegistry 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 4 with ComponentRegistry

use of com.yahoo.component.provider.ComponentRegistry in project vespa by vespa-engine.

the class ProcessingHandlerTestCase method testUserSpecifiedDefaultRendererIsNotReplacedInRegistry.

@Test
public void testUserSpecifiedDefaultRendererIsNotReplacedInRegistry() throws Exception {
    String defaultId = AbstractProcessingHandler.DEFAULT_RENDERER_ID;
    Renderer myDefaultRenderer = new ProcessingRenderer();
    ComponentRegistry<Renderer> renderers = new ComponentRegistry<>();
    renderers.register(ComponentId.fromString(defaultId), myDefaultRenderer);
    driver = new ProcessingTestDriver(Collections.<Chain<Processor>>emptyList(), renderers);
    Renderer defaultRenderer = driver.processingHandler().getRenderers().getComponent(defaultId);
    assertThat(defaultRenderer, sameInstance(myDefaultRenderer));
}
Also used : Chain(com.yahoo.component.chain.Chain) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) Renderer(com.yahoo.processing.rendering.Renderer) ProcessingRenderer(com.yahoo.processing.rendering.ProcessingRenderer) ProcessingRenderer(com.yahoo.processing.rendering.ProcessingRenderer) Test(org.junit.Test)

Example 5 with ComponentRegistry

use of com.yahoo.component.provider.ComponentRegistry in project vespa by vespa-engine.

the class LoggingRequestHandlerTestCase method setUp.

@Before
public void setUp() throws Exception {
    accessLogging = new StartTimePusher();
    ComponentRegistry<AccessLogInterface> implementers = new ComponentRegistry<>();
    implementers.register(new ComponentId("nalle"), accessLogging);
    implementers.freeze();
    executor = Executors.newCachedThreadPool();
    handler = new AccessLogTestHandler(executor, new AccessLog(implementers));
}
Also used : AccessLog(com.yahoo.container.logging.AccessLog) AccessLogInterface(com.yahoo.container.logging.AccessLogInterface) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) ComponentId(com.yahoo.component.ComponentId) Before(org.junit.Before)

Aggregations

ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)10 ComponentId (com.yahoo.component.ComponentId)7 Test (org.junit.Test)5 Query (com.yahoo.search.Query)3 Result (com.yahoo.search.Result)3 FederationConfig (com.yahoo.search.federation.FederationConfig)3 FederationSearcher (com.yahoo.search.federation.FederationSearcher)3 StrictContractsConfig (com.yahoo.search.federation.StrictContractsConfig)3 Execution (com.yahoo.search.searchchain.Execution)3 Chain (com.yahoo.component.chain.Chain)2 ChainsConfig (com.yahoo.container.core.ChainsConfig)2 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)2 CallStack (com.yahoo.docproc.CallStack)2 ServerConfig (com.yahoo.jdisc.http.ServerConfig)2 RequestFilter (com.yahoo.jdisc.http.filter.RequestFilter)2 ResponseFilter (com.yahoo.jdisc.http.filter.ResponseFilter)2 SecurityRequestFilter (com.yahoo.jdisc.http.filter.SecurityRequestFilter)2 SecurityResponseFilter (com.yahoo.jdisc.http.filter.SecurityResponseFilter)2 TargetSelector (com.yahoo.search.federation.selection.TargetSelector)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2