Search in sources :

Example 1 with RemoveDocumentMessage

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

the class DocumentOperationMessageV3 method newRemoveMessage.

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

Example 2 with RemoveDocumentMessage

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

the class Feeder method newRemoveMessage.

private Tuple2<String, Message> newRemoveMessage(Operation op, String operationId) {
    DocumentRemove remove = new DocumentRemove(op.getRemove());
    remove.setCondition(op.getCondition());
    Message msg = new RemoveDocumentMessage(remove);
    String id = (operationId == null) ? remove.getId().toString() : operationId;
    return new Tuple2<>(id, msg);
}
Also used : RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) DocumentRemove(com.yahoo.document.DocumentRemove) 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)

Example 3 with RemoveDocumentMessage

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

the class MessageBusSyncSession method remove.

@Override
public boolean remove(DocumentRemove documentRemove, DocumentProtocol.Priority pri) {
    RemoveDocumentMessage msg = new RemoveDocumentMessage(documentRemove.getId());
    msg.setPriority(pri);
    msg.setCondition(documentRemove.getCondition());
    return remove(msg);
}
Also used : RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)

Example 4 with RemoveDocumentMessage

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

the class DumpVisitorDataHandler method onMessage.

@Override
public void onMessage(Message m, AckToken token) {
    if (m instanceof PutDocumentMessage) {
        PutDocumentMessage pm = (PutDocumentMessage) m;
        onDocument(pm.getDocumentPut().getDocument(), pm.getTimestamp());
    } else if (m instanceof RemoveDocumentMessage) {
        RemoveDocumentMessage rm = (RemoveDocumentMessage) m;
        onRemove(rm.getDocumentId());
    } else {
        throw new UnsupportedOperationException("Received unsupported message " + m.toString() + " to dump visitor data handler. This handler only accepts Put and Remove");
    }
    ack(token);
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)

Example 5 with RemoveDocumentMessage

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

the class DummyReceiver method handleMessage.

public void handleMessage(Message message) {
    messageCount++;
    if (silentNum == 0) {
        System.out.println("Received message " + message + ". Received " + messageCount + " messages so far. In queue size " + queue.size());
        if (verbose) {
            if (message instanceof PutDocumentMessage) {
                System.out.println("  Document:\n" + ((PutDocumentMessage) message).getDocumentPut().getDocument().toXML("  "));
            } else if (message instanceof RemoveDocumentMessage) {
                System.out.println("  Document id: " + ((RemoveDocumentMessage) message).getDocumentId());
            } else if (message instanceof UpdateDocumentMessage) {
                System.out.println("  Update:\n  " + ((UpdateDocumentMessage) message).getDocumentUpdate().toString());
            }
        }
    } else {
        if ((messageCount % silentNum) == 0) {
            System.out.println("Received " + messageCount + " messages so far. In queue size " + queue.size());
        }
    }
    EmptyReply reply = new EmptyReply();
    message.swapState(reply);
    if (!instant) {
        try {
            executor.execute(new Task(reply));
        } catch (RejectedExecutionException e) {
            reply.addError(new Error(ErrorCode.SESSION_BUSY, "Session " + name + "/default is busy"));
            session.reply(reply);
        }
    } else {
        session.reply(reply);
    }
}
Also used : PutDocumentMessage(com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage) RemoveDocumentMessage(com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage) Error(com.yahoo.messagebus.Error) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) EmptyReply(com.yahoo.messagebus.EmptyReply)

Aggregations

RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)9 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)5 UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)4 Message (com.yahoo.messagebus.Message)3 DocumentRemove (com.yahoo.document.DocumentRemove)2 Tuple2 (com.yahoo.collections.Tuple2)1 DocumentId (com.yahoo.document.DocumentId)1 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)1 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)1 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)1 EmptyReply (com.yahoo.messagebus.EmptyReply)1 Error (com.yahoo.messagebus.Error)1 Reply (com.yahoo.messagebus.Reply)1 Utf8String (com.yahoo.text.Utf8String)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1