use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage in project vespa by vespa-engine.
the class MockDispatchDocproc method process.
@Override
public Progress process(Processing processing) {
for (DocumentOperation op : processing.getDocumentOperations()) {
PutDocumentMessage message = new PutDocumentMessage((DocumentPut) op);
ListenableFuture<Response> future = createRequest(message).dispatch();
try {
responses.add(future.get());
} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
}
return Progress.DONE;
}
use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage in project vespa by vespa-engine.
the class FeedTesterV3 method setupFeederHandler.
FeedHandlerV3 setupFeederHandler() throws Exception {
Executor threadPool = Executors.newCachedThreadPool();
DocumentmanagerConfig docMan = new DocumentmanagerConfig(new DocumentmanagerConfig.Builder().enablecompression(true));
FeedHandlerV3 feedHandlerV3 = new FeedHandlerV3(new FeedHandlerV3.Context(threadPool, AccessLog.voidAccessLog(), new NullFeedMetric()), docMan, null, /* session cache */
null, /* thread pool config */
new DocumentApiMetrics(MetricReceiver.nullImplementation, "test")) {
@Override
protected ReferencedResource<SharedSourceSession> retainSource(SessionCache sessionCache, SourceSessionParams sessionParams) {
SharedSourceSession sharedSourceSession = mock(SharedSourceSession.class);
try {
Mockito.stub(sharedSourceSession.sendMessageBlocking(anyObject())).toAnswer((Answer) invocation -> {
Object[] args = invocation.getArguments();
PutDocumentMessage putDocumentMessage = (PutDocumentMessage) args[0];
ReplyContext replyContext = (ReplyContext) putDocumentMessage.getContext();
replyContext.feedReplies.add(new OperationStatus("message", replyContext.docId, ErrorCode.OK, false, "trace"));
Result result = mock(Result.class);
when(result.isAccepted()).thenReturn(true);
return result;
});
} catch (InterruptedException e) {
e.printStackTrace();
}
Result result = mock(Result.class);
when(result.isAccepted()).thenReturn(true);
ReferencedResource<SharedSourceSession> refSharedSessopn = new ReferencedResource<>(sharedSourceSession, () -> {
});
return refSharedSessopn;
}
};
feedHandlerV3.injectDocumentManangerForTests(createDoctypeManager());
return feedHandlerV3;
}
use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage in project vespa by vespa-engine.
the class DummyVisitorSession method addDocumentReply.
public void addDocumentReply(String docId) {
Document replyDoc = new Document(documentType, docId);
autoReplyMessages.add(new PutDocumentMessage(new DocumentPut(replyDoc)));
}
use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage 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);
}
use of com.yahoo.documentapi.messagebus.protocol.PutDocumentMessage in project vespa by vespa-engine.
the class SingleSender method put.
@Override
public void put(Document doc, TestAndSetCondition condition) {
PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(doc));
message.setCondition(condition);
send(message);
}
Aggregations