use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class VespaFeedHandlerRemove method handle.
@Override
public HttpResponse handle(HttpRequest request) {
if (request.getProperty("status") != null) {
return new MetricResponse(context.getMetrics().getMetricSet());
}
MessagePropertyProcessor.PropertySetter properties = getPropertyProcessor().buildPropertySetter(request);
String route = properties.getRoute().toString();
FeedResponse response = new FeedResponse(new RouteMetricSet(route, null));
SingleSender sender = new SingleSender(response, getSharedSender(route));
sender.addMessageProcessor(properties);
response.setAbortOnFeedError(properties.getAbortOnFeedError());
if (request.hasProperty("id")) {
sender.remove(new DocumentId(request.getProperty("id")));
} else if (request.hasProperty("id[0]")) {
int index = 0;
while (request.hasProperty("id[" + index + "]")) {
sender.remove(new DocumentId(request.getProperty("id[" + index + "]")));
++index;
}
}
if (request.getData() != null) {
try {
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(getRequestInputStream(request), "UTF-8"));
while ((line = reader.readLine()) != null) {
sender.remove(new DocumentId(line));
}
} catch (Exception e) {
response.addError(e.getClass() + ": " + e.getCause());
}
}
sender.done();
long millis = getTimeoutMillis(request);
boolean completed = sender.waitForPending(millis);
if (!completed)
response.addError(Error.TIMEOUT, "Timed out after " + millis + " ms waiting for responses");
return response;
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class GetSearcher method sendDocumentGetMessages.
private void sendDocumentGetMessages(List<String> documentIds, String fieldSet, SingleSender sender) {
for (String docIdStr : documentIds) {
DocumentId docId = new DocumentId(docIdStr);
GetDocumentMessage getMsg = new GetDocumentMessage(docId, fieldSet);
sender.send(getMsg);
if (log.isLoggable(LogLevel.DEBUG)) {
log.log(LogLevel.DEBUG, "Sent GetDocumentMessage for " + docId.toString());
}
}
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class DocumentRetrieverTest method testShowDocSize.
@Test
public void testShowDocSize() throws DocumentRetrieverException {
ClientParameters params = createParameters().setDocumentIds(asIterator(DOC_ID_1)).setShowDocSize(true).build();
Document document = new Document(DataType.DOCUMENT, new DocumentId(DOC_ID_1));
when(mockedSession.syncSend(any())).thenReturn(new GetDocumentReply(document));
DocumentRetriever documentRetriever = createDocumentRetriever(params);
documentRetriever.retrieveDocuments();
assertTrue(outContent.toString().contains(String.format("Document size: %d bytes", document.getSerializedSize())));
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class DocumentRetrieverTest method testTrace.
@Test
public void testTrace() throws DocumentRetrieverException {
final int traceLevel = 9;
ClientParameters params = createParameters().setDocumentIds(asIterator(DOC_ID_1)).setTraceLevel(traceLevel).build();
GetDocumentReply reply = new GetDocumentReply(new Document(DataType.DOCUMENT, new DocumentId(DOC_ID_1)));
reply.getTrace().getRoot().addChild("childnode");
when(mockedSession.syncSend(any())).thenReturn(reply);
DocumentRetriever documentRetriever = createDocumentRetriever(params);
documentRetriever.retrieveDocuments();
verify(mockedSession, times(1)).setTraceLevel(traceLevel);
assertTrue(outContent.toString().contains("<trace>"));
}
use of com.yahoo.document.DocumentId in project vespa by vespa-engine.
the class BucketStatsRetrieverTest method testRoute.
@Test
public void testRoute() throws BucketStatsException {
String route = "default";
BucketId bucketId = bucketIdFactory.getBucketId(new DocumentId("id:ns:type::another"));
GetBucketListReply reply = new GetBucketListReply();
reply.getBuckets().add(new GetBucketListReply.BucketInfo(bucketId, "I like turtles!"));
when(mockedSession.syncSend(any())).thenReturn(reply);
BucketStatsRetriever retriever = new BucketStatsRetriever(mockedFactory, route, t -> {
});
retriever.retrieveBucketList(new BucketId(0), bucketSpace);
verify(mockedSession).syncSend(argThat(new ArgumentMatcher<Message>() {
@Override
public boolean matches(Object o) {
return ((Message) o).getRoute().equals(Route.parse(route));
}
}));
}
Aggregations