Search in sources :

Example 1 with UpdateDocumentMessage

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

the class DocumentProcessingHandlerAllMessageTypesTestCase method batchDocumentUpdate.

private void batchDocumentUpdate() throws InterruptedException {
    DocumentUpdate doc1 = new DocumentUpdate(getType(), new DocumentId("userdoc:test:12345:multi:1"));
    DocumentUpdate doc2 = new DocumentUpdate(getType(), new DocumentId("userdoc:test:12345:multi:2"));
    Field testField = getType().getField("blahblah");
    doc1.addFieldUpdate(FieldUpdate.createAssign(testField, new StringFieldValue("1 not yet processed")));
    doc2.addFieldUpdate(FieldUpdate.createAssign(testField, new StringFieldValue("2 not yet processed")));
    BatchDocumentUpdateMessage message = new BatchDocumentUpdateMessage(12345);
    message.addUpdate(doc1);
    message.addUpdate(doc2);
    assertTrue(sendMessage(FOOBAR, message));
    Message remote1 = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
    assertTrue(remote1 instanceof UpdateDocumentMessage);
    remoteServer.ackMessage(remote1);
    assertNull(driver.client().awaitReply(100, TimeUnit.MILLISECONDS));
    Message remote2 = remoteServer.awaitMessage(60, TimeUnit.SECONDS);
    assertTrue(remote2 instanceof UpdateDocumentMessage);
    remoteServer.ackMessage(remote2);
    Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS);
    assertNotNull(reply);
    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) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) BatchDocumentUpdateMessage(com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage) Reply(com.yahoo.messagebus.Reply) UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Example 2 with UpdateDocumentMessage

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

Example 3 with UpdateDocumentMessage

use of com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage 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 4 with UpdateDocumentMessage

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

Example 5 with UpdateDocumentMessage

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

the class SingleSender method update.

@Override
public void update(DocumentUpdate update, TestAndSetCondition condition) {
    UpdateDocumentMessage message = new UpdateDocumentMessage(update);
    message.setCondition(condition);
    send(message);
}
Also used : UpdateDocumentMessage(com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)

Aggregations

UpdateDocumentMessage (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage)7 PutDocumentMessage (com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage)5 RemoveDocumentMessage (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage)5 Message (com.yahoo.messagebus.Message)4 Reply (com.yahoo.messagebus.Reply)3 DocumentUpdate (com.yahoo.document.DocumentUpdate)2 BatchDocumentUpdateMessage (com.yahoo.documentapi.messagebus.protocol.BatchDocumentUpdateMessage)2 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)2 Tuple2 (com.yahoo.collections.Tuple2)1 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)1 DocumentAccessException (com.yahoo.documentapi.DocumentAccessException)1 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)1 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)1 RemoveDocumentReply (com.yahoo.documentapi.messagebus.protocol.RemoveDocumentReply)1 UpdateDocumentReply (com.yahoo.documentapi.messagebus.protocol.UpdateDocumentReply)1 EmptyReply (com.yahoo.messagebus.EmptyReply)1 Error (com.yahoo.messagebus.Error)1 Utf8String (com.yahoo.text.Utf8String)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1