use of com.yahoo.vespa.http.client.core.Document in project vespa by vespa-engine.
the class IOThread method drainDocumentQueueWhenFailingPermanently.
private void drainDocumentQueueWhenFailingPermanently(Exception exception) {
// first, clear sentOperations:
resultQueue.failPending(exception);
for (Document document : documentQueue.removeAllDocuments()) {
EndpointResult endpointResult = EndPointResultFactory.createError(endpoint, document.getOperationId(), exception);
resultQueue.failOperation(endpointResult, clusterId);
}
}
use of com.yahoo.vespa.http.client.core.Document in project vespa by vespa-engine.
the class FeedClientImpl method stream.
@Override
public void stream(String documentId, CharSequence documentData, Object context) {
CharsetEncoder charsetEncoder = StandardCharsets.UTF_8.newEncoder();
charsetEncoder.onMalformedInput(CodingErrorAction.REPORT);
charsetEncoder.onUnmappableCharacter(CodingErrorAction.REPORT);
final Document document = new Document(documentId, documentData, context);
operationProcessor.sendDocument(document);
}
use of com.yahoo.vespa.http.client.core.Document in project vespa by vespa-engine.
the class DocumentQueue method poll.
Document poll() {
synchronized (queue) {
Document document = queue.poll();
queue.notifyAll();
return document;
}
}
use of com.yahoo.vespa.http.client.core.Document in project vespa by vespa-engine.
the class DocumentQueue method poll.
Document poll(long timeout, TimeUnit unit) throws InterruptedException {
synchronized (queue) {
long remainingToWait = unit.toMillis(timeout);
while (queue.isEmpty()) {
long startTime = System.currentTimeMillis();
queue.wait(remainingToWait);
remainingToWait -= (System.currentTimeMillis() - startTime);
if (remainingToWait <= 0) {
break;
}
}
Document document = queue.poll();
queue.notifyAll();
return document;
}
}
use of com.yahoo.vespa.http.client.core.Document in project vespa by vespa-engine.
the class IOThread method drainFirstDocumentsInQueueIfOld.
private void drainFirstDocumentsInQueueIfOld() {
while (true) {
Optional<Document> document = documentQueue.pollDocumentIfTimedoutInQueue(localQueueTimeOut);
if (!document.isPresent()) {
return;
}
EndpointResult endpointResult = EndPointResultFactory.createTransientError(endpoint, document.get().getOperationId(), new Exception("Not sending document operation, timed out in queue after " + document.get().timeInQueueMillis() + " ms."));
resultQueue.failOperation(endpointResult, clusterId);
}
}
Aggregations