Search in sources :

Example 31 with ClusterList

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

the class VdsVisitTestCase method testRequireClusterOptionIfMultipleClusters.

@Test
public void testRequireClusterOptionIfMultipleClusters() {
    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);
    try {
        VdsVisit.resolveClusterRoute(clusterList, null);
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("Please use the -c option to select one of them"));
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 32 with ClusterList

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

the class VespaFeeder method parseFiles.

void parseFiles(InputStream stdin, PrintStream output) throws Exception {
    FeedContext context = new FeedContext(args.getPropertyProcessor(), args.getSessionFactory(), manager, new ClusterList(), new NullFeedMetric());
    final BufferedInputStream input = new BufferedInputStream(stdin);
    VespaFeedHandler handler = VespaFeedHandler.createFromContext(context, threadPool);
    if (args.getFiles().isEmpty()) {
        InputStreamRequest req = new InputStreamRequest(input);
        setProperties(req, input);
        FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
        if (!response.isSuccess()) {
            throw renderErrors(response.getErrorList());
        }
    } else {
        if (args.isVerbose()) {
            for (String fileName : args.getFiles()) {
                long thisSize = new File(fileName).length();
                output.println("Size of file '" + fileName + "' is " + thisSize + " B.");
            }
        }
        for (String fileName : args.getFiles()) {
            File f = new File(fileName);
            FileRequest req = new FileRequest(f);
            final BufferedInputStream inputSnooper = new BufferedInputStream(new FileInputStream(fileName));
            setProperties(req, inputSnooper);
            inputSnooper.close();
            FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
            if (!response.isSuccess()) {
                throw renderErrors(response.getErrorList());
            }
        }
    }
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) FeedContext(com.yahoo.feedapi.FeedContext) VespaFeedHandler(com.yahoo.feedhandler.VespaFeedHandler) FeedResponse(com.yahoo.feedhandler.FeedResponse) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric)

Example 33 with ClusterList

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

the class DocumentRetrieverTest method testClusterLookup.

@Test
public void testClusterLookup() throws DocumentRetrieverException {
    final String cluster = "storage", configId = "content/cluster.foo/storage", expectedRoute = "[Storage:cluster=storage;clusterconfigid=content/cluster.foo/storage]";
    ClientParameters params = createParameters().setCluster(cluster).build();
    ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef(cluster, configId)));
    DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList);
    documentRetriever.retrieveDocuments();
    verify(mockedFactory).createDocumentAccess(argThat(new ArgumentMatcher<MessageBusParams>() {

        @Override
        public boolean matches(Object o) {
            return ((MessageBusParams) o).getRoute().equals(expectedRoute);
        }
    }));
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ArgumentMatcher(org.mockito.ArgumentMatcher) ClusterDef(com.yahoo.vespaclient.ClusterDef) Test(org.junit.Test)

Example 34 with ClusterList

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

the class DocumentRetrieverTest method testInvalidClusterName.

@Test
public void testInvalidClusterName() throws DocumentRetrieverException {
    exception.expect(DocumentRetrieverException.class);
    exception.expectMessage("The Vespa cluster contains the content clusters storage, not invalidclustername. Please select a valid vespa cluster.");
    ClientParameters params = createParameters().setCluster("invalidclustername").build();
    ClusterList clusterList = new ClusterList(Collections.singletonList(new ClusterDef("storage", "content/cluster.foo/storage")));
    DocumentRetriever documentRetriever = createDocumentRetriever(params, clusterList);
    documentRetriever.retrieveDocuments();
}
Also used : ClusterList(com.yahoo.vespaclient.ClusterList) ClusterDef(com.yahoo.vespaclient.ClusterDef) 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