Search in sources :

Example 21 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class MbusRequestContext method processingDone.

@Override
public void processingDone(List<Processing> processings) {
    List<DocumentMessage> messages = new ArrayList<>();
    if (messageFactory != null) {
        for (Processing processing : processings) {
            for (DocumentOperation documentOperation : processing.getDocumentOperations()) {
                messages.add(messageFactory.fromDocumentOperation(processing, documentOperation));
            }
        }
    }
    if (log.isLoggable(LogLevel.DEBUG)) {
        log.log(LogLevel.DEBUG, "Forwarding " + messages.size() + " messages from " + processings.size() + " processings.");
    }
    if (messages.isEmpty()) {
        dispatchResponse(Response.Status.OK);
        return;
    }
    long inputSequenceId = requestMsg.getSequenceId();
    ResponseMerger responseHandler = new ResponseMerger(requestMsg, messages.size(), this);
    for (Message message : messages) {
        // See comment for internalNoThrottledSource.
        dispatchRequest(message, (inputSequenceId == message.getSequenceId()) ? getUri().getPath() : "/" + internalNoThrottledSource, responseHandler);
    }
}
Also used : DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) DocumentOperation(com.yahoo.document.DocumentOperation) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) ArrayList(java.util.ArrayList) Processing(com.yahoo.docproc.Processing)

Example 22 with Message

use of com.yahoo.messagebus.Message 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 23 with Message

use of com.yahoo.messagebus.Message 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)

Example 24 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class DocumentOperationMessageV3 method newErrorMessage.

static DocumentOperationMessageV3 newErrorMessage(String operationId, Exception exception) {
    Message feedErrorMessageV3 = new FeedErrorMessage(operationId);
    DocumentOperationMessageV3 msg = new DocumentOperationMessageV3(operationId, feedErrorMessageV3);
    Hop hop = new Hop();
    hop.addDirective(new ErrorDirective(Exceptions.toMessageString(exception)));
    Route route = new Route();
    route.addHop(hop);
    feedErrorMessageV3.setRoute(route);
    return msg;
}
Also used : UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) Hop(com.yahoo.messagebus.routing.Hop) ErrorDirective(com.yahoo.messagebus.routing.ErrorDirective) Route(com.yahoo.messagebus.routing.Route)

Example 25 with Message

use of com.yahoo.messagebus.Message in project vespa by vespa-engine.

the class DocumentOperationMessageV3 method newUpdateMessage.

static DocumentOperationMessageV3 newUpdateMessage(VespaXMLFeedReader.Operation op, String operationId) {
    DocumentUpdate update = op.getDocumentUpdate();
    update.setCondition(op.getCondition());
    Message msg = new UpdateDocumentMessage(update);
    String id = (operationId == null) ? update.getId().toString() : operationId;
    return new DocumentOperationMessageV3(id, msg);
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Aggregations

Message (com.yahoo.messagebus.Message)39 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)17 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)15 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)15 Reply (com.yahoo.messagebus.Reply)14 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)13 Test (org.junit.Test)13 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)9 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 ClusterList (com.yahoo.vespaclient.ClusterList)7 Result (com.yahoo.search.Result)6 Utf8String (com.yahoo.text.Utf8String)6 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)5 Tuple2 (com.yahoo.collections.Tuple2)4 EmptyReply (com.yahoo.messagebus.EmptyReply)4