use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.
the class DryRunGatewayConnection method writeOperations.
@Override
public InputStream writeOperations(List<Document> docs) throws ServerResponseException, IOException {
StringBuilder result = new StringBuilder();
for (Document doc : docs) {
OperationStatus operationStatus = new OperationStatus("ok", doc.getOperationId(), ErrorCode.OK, false, "");
result.append(operationStatus.render());
}
return new ByteArrayInputStream(result.toString().getBytes(StandardCharsets.UTF_8));
}
use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.
the class V3MockParsingRequestHandler method respondConditionNotMet.
private void respondConditionNotMet(PrintWriter responseWriter, String docId) {
final OperationStatus operationStatus = new OperationStatus("this is a test", docId, ErrorCode.ERROR, true, "trace");
writeResponse(responseWriter, operationStatus);
}
use of com.yahoo.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.
the class V3MockParsingRequestHandler method respondOK.
private void respondOK(PrintWriter responseWriter, String docId) {
final OperationStatus operationStatus = new OperationStatus("Doc fed", docId, ErrorCode.OK, false, "Trace message");
writeResponse(responseWriter, operationStatus);
}
use of com.yahoo.vespa.http.client.core.OperationStatus 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.vespa.http.client.core.OperationStatus in project vespa by vespa-engine.
the class ClientFeederV3 method transferPreviousRepliesToResponse.
private void transferPreviousRepliesToResponse(BlockingQueue<OperationStatus> operations) throws InterruptedException {
OperationStatus status = feedReplies.poll();
while (status != null) {
outstandingOperations.decrementAndGet();
operations.put(status);
status = feedReplies.poll();
}
}
Aggregations