Search in sources :

Example 6 with Document

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);
    }
}
Also used : EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) Document(com.yahoo.vespa.http.client.core.Document)

Example 7 with Document

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);
}
Also used : Document(com.yahoo.vespa.http.client.core.Document) CharsetEncoder(java.nio.charset.CharsetEncoder)

Example 8 with 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;
    }
}
Also used : Document(com.yahoo.vespa.http.client.core.Document)

Example 9 with 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;
    }
}
Also used : Document(com.yahoo.vespa.http.client.core.Document)

Example 10 with 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);
    }
}
Also used : EndpointResult(com.yahoo.vespa.http.client.core.EndpointResult) Document(com.yahoo.vespa.http.client.core.Document) IOException(java.io.IOException) ServerResponseException(com.yahoo.vespa.http.client.core.ServerResponseException)

Aggregations

Document (com.yahoo.vespa.http.client.core.Document)18 Endpoint (com.yahoo.vespa.http.client.config.Endpoint)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 ConnectionParams (com.yahoo.vespa.http.client.config.ConnectionParams)5 FeedParams (com.yahoo.vespa.http.client.config.FeedParams)4 EndpointResult (com.yahoo.vespa.http.client.core.EndpointResult)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Header (org.apache.http.Header)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Result (com.yahoo.vespa.http.client.Result)1 Cluster (com.yahoo.vespa.http.client.config.Cluster)1 SessionParams (com.yahoo.vespa.http.client.config.SessionParams)1 OperationStatus (com.yahoo.vespa.http.client.core.OperationStatus)1 ServerResponseException (com.yahoo.vespa.http.client.core.ServerResponseException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ByteBuffer (java.nio.ByteBuffer)1 CharsetEncoder (java.nio.charset.CharsetEncoder)1 ArrayDeque (java.util.ArrayDeque)1