Search in sources :

Example 11 with ClusterList

use of com.yahoo.vespaclient.ClusterList in project vespa by vespa-engine.

the class VisitorSearcherTestCase method testNoClusterParamWhenSeveralClusters.

@Test(expected = IllegalArgumentException.class)
public void testNoClusterParamWhenSeveralClusters() throws Exception {
    DocumentSessionFactory factory = new DocumentSessionFactory(docType);
    ClusterListConfig.Storage.Builder storageCluster1 = new ClusterListConfig.Storage.Builder().configid("storage/cluster.foo").name("foo");
    ClusterListConfig.Storage.Builder storageCluster2 = new ClusterListConfig.Storage.Builder().configid("storage/cluster.bar").name("bar");
    ClusterListConfig clusterListCfg = new ClusterListConfig(new ClusterListConfig.Builder().storage(Arrays.asList(storageCluster1, storageCluster2)));
    ClusterList clusterList = new ClusterList(clusterListCfg);
    VisitSearcher searcher = new VisitSearcher(new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder().timeout(100).route("whatever").retryenabled(true)), new LoadTypeConfig(new LoadTypeConfig.Builder())), factory, docMan, clusterList, new NullFeedMetric()));
    searcher.getVisitorParameters(newQuery("visit?visit.selection=id.user=1234"), null);
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterListConfig(com.yahoo.cloud.config.ClusterListConfig) FeederConfig(com.yahoo.vespaclient.config.FeederConfig) FeedContext(com.yahoo.feedapi.FeedContext) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) LoadTypeConfig(com.yahoo.vespa.config.content.LoadTypeConfig) Test(org.junit.Test)

Example 12 with ClusterList

use of com.yahoo.vespaclient.ClusterList 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 13 with ClusterList

use of com.yahoo.vespaclient.ClusterList in project vespa by vespa-engine.

the class VdsVisitTestCase method testBadClusterName.

@Test
public void testBadClusterName() throws Exception {
    List<ClusterDef> clusterDefs = new ArrayList<>();
    clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage"));
    ClusterList clusterList = new ClusterList(clusterDefs);
    try {
        VdsVisit.resolveClusterRoute(clusterList, "borkbork");
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Your vespa cluster contains the content clusters storage, not borkbork."));
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 14 with ClusterList

use of com.yahoo.vespaclient.ClusterList in project vespa by vespa-engine.

the class VdsVisitTestCase method testExplicitClusterOptionWithMultipleClusters.

@Test
public void testExplicitClusterOptionWithMultipleClusters() {
    List<ClusterDef> clusterDefs = new ArrayList<>();
    clusterDefs.add(new ClusterDef("storage", "content/cluster.foo/storage"));
    clusterDefs.add(new ClusterDef("storage2", "content/cluster.bar/storage"));
    ClusterList clusterList = new ClusterList(clusterDefs);
    String route = VdsVisit.resolveClusterRoute(clusterList, "storage2");
    assertEquals("[Storage:cluster=storage2;clusterconfigid=content/cluster.bar/storage]", route);
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with ClusterList

use of com.yahoo.vespaclient.ClusterList in project vespa by vespa-engine.

the class DocumentRetrieverTest method testSendSingleMessage.

@Test
public void testSendSingleMessage() throws DocumentRetrieverException {
    ClientParameters params = createParameters().setDocumentIds(asIterator(DOC_ID_1)).setPriority(DocumentProtocol.Priority.HIGH_1).setNoRetry(true).setLoadTypeName("loadtype").build();
    when(mockedSession.syncSend(any())).thenReturn(createDocumentReply(DOC_ID_1));
    LoadTypeSet loadTypeSet = new LoadTypeSet();
    loadTypeSet.addLoadType(1, "loadtype", DocumentProtocol.Priority.HIGH_1);
    DocumentRetriever documentRetriever = new DocumentRetriever(new ClusterList(), mockedFactory, loadTypeSet, params);
    documentRetriever.retrieveDocuments();
    verify(mockedSession, times(1)).syncSend(argThat(new ArgumentMatcher<GetDocumentMessage>() {

        @Override
        public boolean matches(Object o) {
            GetDocumentMessage msg = (GetDocumentMessage) o;
            return msg.getPriority().equals(DocumentProtocol.Priority.HIGH_1) && !msg.getRetryEnabled() && msg.getLoadType().equals(new LoadType(1, "loadtype", DocumentProtocol.Priority.HIGH_1));
        }
    }));
    assertContainsDocument(DOC_ID_1);
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ArgumentMatcher(org.mockito.ArgumentMatcher) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) LoadType(com.yahoo.documentapi.messagebus.loadtypes.LoadType) LoadTypeSet(com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet) Test(org.junit.Test)

Aggregations

ClusterList (com.yahoo.vespaclient.ClusterList)34 Test (org.junit.Test)29 FeedContext (com.yahoo.feedapi.FeedContext)25 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)24 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)24 Chain (com.yahoo.component.chain.Chain)21 Searcher (com.yahoo.search.Searcher)20 Execution (com.yahoo.search.searchchain.Execution)20 Result (com.yahoo.search.Result)19 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)8 Message (com.yahoo.messagebus.Message)7 ClusterDef (com.yahoo.vespaclient.ClusterDef)7 FeederConfig (com.yahoo.vespaclient.config.FeederConfig)5 ArrayList (java.util.ArrayList)5 Query (com.yahoo.search.Query)4 ClusterListConfig (com.yahoo.cloud.config.ClusterListConfig)2 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)2 Hit (com.yahoo.search.result.Hit)2 HitGroup (com.yahoo.search.result.HitGroup)2 LoadTypeConfig (com.yahoo.vespa.config.content.LoadTypeConfig)2