use of com.yahoo.feedapi.FeedContext 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);
}
use of com.yahoo.feedapi.FeedContext 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.feedapi.FeedContext in project vespa by vespa-engine.
the class GetSearcherTestCase method testConfig.
@Test
public void testConfig() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder().timeout(58).route("route66").retryenabled(false)), defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=doc:batman:dahnahnahnah"));
assertEquals(1, factory.messages.size());
{
Message m = factory.messages.get(0);
assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
GetDocumentMessage gdm = (GetDocumentMessage) m;
DocumentId d = gdm.getDocumentId();
assertEquals("doc:batman:dahnahnahnah", d.toString());
assertEquals("[all]", gdm.getFieldSet());
assertEquals(Route.parse("route66"), gdm.getRoute());
assertFalse(gdm.getRetryEnabled());
assertTrue(58000 >= gdm.getTimeRemaining());
}
}
use of com.yahoo.feedapi.FeedContext in project vespa by vespa-engine.
the class GetSearcherTestCase method testConsistentResultOrdering.
@Test
public void testConsistentResultOrdering() throws Exception {
GetDocumentReply[] replies = new GetDocumentReply[] { new GetDocumentReply(new Document(docType, new DocumentId("userdoc:kittens:1:2"))), new GetDocumentReply(new Document(docType, new DocumentId("userdoc:kittens:7:8"))), new GetDocumentReply(new Document(docType, new DocumentId("userdoc:kittens:555:123"))) };
// Use a predefined reply list to ensure messages are answered out of order
DocumentSessionFactory factory = new DocumentSessionFactory(docType, null, false, replies);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id[0]=userdoc:kittens:555:123&id[1]=userdoc:kittens:1:2&id[2]=userdoc:kittens:7:8"));
assertEquals(3, factory.messages.size());
assertEquals(3, result.hits().size());
// Hits must be in the same order as their document IDs in the query
assertHits(result.hits(), "userdoc:kittens:555:123", "userdoc:kittens:1:2", "userdoc:kittens:7:8");
assertEquals(0, ((DocumentHit) result.hits().get(0)).getIndex());
assertEquals(1, ((DocumentHit) result.hits().get(1)).getIndex());
assertEquals(2, ((DocumentHit) result.hits().get(2)).getIndex());
}
use of com.yahoo.feedapi.FeedContext in project vespa by vespa-engine.
the class GetSearcherTestCase method testGetMultipleDocumentsQueryAndPOST.
// Test that you can use both query string and POSTed IDs
@Test
public void testGetMultipleDocumentsQueryAndPOST() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
String data = "userdoc:kittens:5:6\nuserdoc:kittens:7:8\nuserdoc:kittens:9:10";
MockHttpRequest request = new MockHttpRequest(data.getBytes("utf-8"), "/get/?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4");
Query query = new Query(request.toRequest());
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(query);
assertEquals(5, factory.messages.size());
assertEquals(5, result.hits().size());
assertNull(result.hits().getErrorHit());
assertHits(result.hits(), "userdoc:kittens:1:2", "userdoc:kittens:3:4", "userdoc:kittens:5:6", "userdoc:kittens:7:8", "userdoc:kittens:9:10");
}
Aggregations