Search in sources :

Example 26 with Message

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

the class DocumentOperationMessageV3 method newPutMessage.

static DocumentOperationMessageV3 newPutMessage(VespaXMLFeedReader.Operation op, String operationId) {
    DocumentPut put = new DocumentPut(op.getDocument());
    put.setCondition(op.getCondition());
    Message msg = new PutDocumentMessage(put);
    String id = (operationId == null) ? put.getId().toString() : operationId;
    return new DocumentOperationMessageV3(id, msg);
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) 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) DocumentPut(com.yahoo.document.DocumentPut)

Example 27 with Message

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

the class Feeder method newErrorMessage.

private Tuple2<String, Message> newErrorMessage(String operationId, Exception e) {
    Message m = new FeedErrorMessage(operationId);
    Tuple2<String, Message> msg = new Tuple2<>(operationId, m);
    Hop hop = new Hop();
    hop.addDirective(new ErrorDirective(Exceptions.toMessageString(e)));
    Route route = new Route();
    route.addHop(hop);
    m.setRoute(route);
    return msg;
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Tuple2(com.yahoo.collections.Tuple2) Hop(com.yahoo.messagebus.routing.Hop) Utf8String(com.yahoo.text.Utf8String) ErrorDirective(com.yahoo.messagebus.routing.ErrorDirective) Route(com.yahoo.messagebus.routing.Route)

Example 28 with Message

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

the class Feeder method newUpdateMessage.

private Tuple2<String, Message> newUpdateMessage(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 Tuple2<>(id, msg);
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Tuple2(com.yahoo.collections.Tuple2) Utf8String(com.yahoo.text.Utf8String) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Example 29 with Message

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

the class Feeder method getNextMessage.

private Tuple2<String, Message> getNextMessage(String operationId) throws Exception {
    VespaXMLFeedReader.Operation op = new VespaXMLFeedReader.Operation();
    Tuple2<String, Message> msg;
    getNextOperation(op);
    switch(op.getType()) {
        case DOCUMENT:
            msg = newPutMessage(op, operationId);
            break;
        case REMOVE:
            msg = newRemoveMessage(op, operationId);
            break;
        case UPDATE:
            msg = newUpdateMessage(op, operationId);
            break;
        default:
            // typical end of feed
            return null;
    }
    log(LogLevel.DEBUG, "Successfully deserialized document id: ", msg.first);
    return msg;
}
Also used : Operation(com.yahoo.vespaxmlparser.VespaXMLFeedReader.Operation) VespaXMLFeedReader(com.yahoo.vespaxmlparser.VespaXMLFeedReader) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Operation(com.yahoo.vespaxmlparser.VespaXMLFeedReader.Operation) Utf8String(com.yahoo.text.Utf8String)

Example 30 with Message

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

the class Feeder method newPutMessage.

private Tuple2<String, Message> newPutMessage(Operation op, String operationId) {
    DocumentPut put = new DocumentPut(op.getDocument());
    put.setCondition(op.getCondition());
    Message msg = new PutDocumentMessage(put);
    String id = (operationId == null) ? put.getId().toString() : operationId;
    return new Tuple2<>(id, msg);
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) Message(com.yahoo.messagebus.Message) DocumentMessage(com.yahoo.documentapi.messagebus.protocol.DocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Tuple2(com.yahoo.collections.Tuple2) DocumentPut(com.yahoo.document.DocumentPut) Utf8String(com.yahoo.text.Utf8String)

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