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());
}
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);
}
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);
}
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);
}
}
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);
}
Aggregations