Search in sources :

Example 6 with GetDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage in project vespa by vespa-engine.

the class DocumentRetriever method createDocumentRequest.

private Message createDocumentRequest(String docid, LoadType loadType) {
    GetDocumentMessage msg = new GetDocumentMessage(new DocumentId(docid), params.fieldSet);
    msg.setPriority(params.priority);
    msg.setRetryEnabled(!params.noRetry);
    if (loadType != null) {
        msg.setLoadType(loadType);
    }
    return msg;
}
Also used : GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) DocumentId(com.yahoo.document.DocumentId)

Example 7 with GetDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage 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)

Example 8 with GetDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage in project vespa by vespa-engine.

the class DocumentProcessingHandlerAllMessageTypesTestCase method get.

private void get() throws InterruptedException {
    GetDocumentMessage message = new GetDocumentMessage(new DocumentId("doc:this:is:a:test"), "fieldset?");
    assertTrue(sendMessage(FOOBAR, message));
    Message result = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
    assertNotNull(result);
    remoteServer.ackMessage(result);
    Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
    assertNotNull(reply);
    assertThat(result, instanceOf(GetDocumentMessage.class));
    assertFalse(reply.hasErrors());
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) BatchDocumentUpdateMessage(com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Reply(com.yahoo.messagebus.Reply)

Example 9 with GetDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage 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());
    }
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Searcher(com.yahoo.search.Searcher) FeederConfig(com.yahoo.vespaclient.config.FeederConfig) Result(com.yahoo.search.Result) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Test(org.junit.Test)

Example 10 with GetDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage in project vespa by vespa-engine.

the class GetSearcherTestCase method testConfigChanges.

@Test
public void testConfigChanges() throws Exception {
    String config = "raw:timeout 37\nroute \"riksveg18\"\nretryenabled true";
    DocumentSessionFactory factory = new DocumentSessionFactory(docType);
    GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder().timeout(58).route("riksveg18").retryenabled(true)), defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
    Chain<Searcher> searchChain = new Chain<>(searcher);
    new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=doc:batman:dahnahnahnah"));
    assertEquals(1, factory.messages.size());
    assertEquals(1, factory.getSessionsCreated());
    {
        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("riksveg18"), gdm.getRoute());
        assertTrue(gdm.getRetryEnabled());
        assertTrue(58000 >= gdm.getTimeRemaining());
    }
    factory.messages.clear();
    FeederConfig newConfig = new FeederConfig(new FeederConfig.Builder().timeout(123).route("e6").retryenabled(false));
    searcher.getMessagePropertyProcessor().configure(newConfig, defLoadTypeCfg);
    new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=doc:spiderman:does_whatever_a_spider_can"));
    // riksveg18 is created again, and e6 is created as well.
    assertEquals(3, factory.getSessionsCreated());
    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:spiderman:does_whatever_a_spider_can", d.toString());
        assertEquals("[all]", gdm.getFieldSet());
        assertEquals(Route.parse("e6"), gdm.getRoute());
        assertFalse(gdm.getRetryEnabled());
        assertTrue(123000 >= gdm.getTimeRemaining());
    }
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Searcher(com.yahoo.search.Searcher) FeederConfig(com.yahoo.vespaclient.config.FeederConfig) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Test(org.junit.Test)

Aggregations

GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)13 Test (org.junit.Test)9 Message (com.yahoo.messagebus.Message)8 ClusterList (com.yahoo.vespaclient.ClusterList)8 Chain (com.yahoo.component.chain.Chain)7 FeedContext (com.yahoo.feedapi.FeedContext)7 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)7 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)7 Searcher (com.yahoo.search.Searcher)7 Execution (com.yahoo.search.searchchain.Execution)7 Result (com.yahoo.search.Result)6 DocumentId (com.yahoo.document.DocumentId)3 Reply (com.yahoo.messagebus.Reply)2 FeederConfig (com.yahoo.vespaclient.config.FeederConfig)2 Document (com.yahoo.document.Document)1 DocumentAccessException (com.yahoo.documentapi.DocumentAccessException)1 LoadType (com.yahoo.documentapi.messagebus.loadtypes.LoadType)1 LoadTypeSet (com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet)1 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)1 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)1