Refine search
private DataBuffer toDataBuffer(ContentChunk chunk) { // We must copy until this is resolved: // https://github.com/eclipse/jetty.project/issues/2429 // Use copy instead of buffer wrapping because Callback#succeeded() is // used not only to release the buffer but also to request more data // which is a problem for codecs that buffer data. DataBuffer buffer = this.bufferFactory.allocateBuffer(chunk.buffer.capacity()); buffer.write(chunk.buffer); chunk.callback.succeeded(); return buffer; }
@Override protected void onCompleteFailure(Throwable x) { _callback.failed(x); }
/** * <p>Creates a non-blocking callback from the given incomplete CompletableFuture.</p> * <p>When the callback completes, either succeeding or failing, the * CompletableFuture is also completed, respectively via * {@link CompletableFuture#complete(Object)} or * {@link CompletableFuture#completeExceptionally(Throwable)}.</p> * * @param completable the CompletableFuture to convert into a callback * @return a callback that when completed, completes the given CompletableFuture */ static Callback from(CompletableFuture<?> completable) { return from(completable, InvocationType.NON_BLOCKING); }
public void onClose() { if (LOG.isDebugEnabled()) LOG.debug("onClose {}",this); Callback callback = _interested.get(); if (callback != null && _interested.compareAndSet(callback, null)) callback.failed(new ClosedChannelException()); }
/** * Call to signal that a read is now possible. */ public void fillable() { Callback callback = _interested.get(); if (LOG.isDebugEnabled()) LOG.debug("{} fillable {}",this,callback); if (callback != null && _interested.compareAndSet(callback, null)) callback.succeeded(); else if (LOG.isDebugEnabled()) LOG.debug("{} lost race {}",this,callback); }
protected void onResponseContent(HttpServletRequest request, HttpServletResponse response, Response proxyResponse, byte[] buffer, int offset, int length, Callback callback) { try { if (_log.isDebugEnabled()) _log.debug("{} proxying content to downstream: {} bytes", getRequestId(request), length); response.getOutputStream().write(buffer, offset, length); callback.succeeded(); } catch (Throwable x) { callback.failed(x); } }
private void notifyReset(Stream stream, ResetFrame frame, Callback callback) { Listener listener = this.listener; if (listener != null) { try { listener.onReset(stream, frame, callback); } catch (Throwable x) { LOG.info("Failure while notifying listener " + listener, x); callback.failed(x); } } else { callback.succeeded(); } }
protected void failedCallback(final Callback callback, final Throwable x) { if (NonBlockingThread.isNonBlockingThread()) { try { getExecutor().execute(new Runnable() { @Override public void run() { callback.failed(x); } }); } catch(RejectedExecutionException e) { LOG.debug(e); callback.failed(x); } } else { callback.failed(x); } }
@Override public InvocationType getInvocationType() { return _callback.getInvocationType(); }
public void onClose() { if (LOG.isDebugEnabled()) LOG.debug("onClose {}",this); Callback callback = _interested.get(); if (callback != null && _interested.compareAndSet(callback, null)) callback.failed(new ClosedChannelException()); }
/** * Call to signal that a read is now possible. */ public boolean fillable() { if (LOG.isDebugEnabled()) LOG.debug("fillable {}",this); Callback callback = _interested.get(); if (callback != null && _interested.compareAndSet(callback, null)) { callback.succeeded(); return true; } if (LOG.isDebugEnabled()) LOG.debug("{} lost race {}",this,callback); return false; }
@Override public void onContent(Response response, ByteBuffer content, Callback callback) { if (content.remaining() == 0) { if (LOG.isDebugEnabled()) LOG.debug("Skipped empty content {}", content); callback.succeeded(); return; } boolean closed; synchronized (lock) { closed = this.closed; if (!closed) { if (LOG.isDebugEnabled()) LOG.debug("Queueing content {}", content); chunks.add(new DeferredContentProvider.Chunk(content, callback)); lock.notifyAll(); } } if (closed) { if (LOG.isDebugEnabled()) LOG.debug("InputStream closed, ignored content {}", content); callback.failed(new AsynchronousCloseException()); } }
private void notifyData(Stream stream, DataFrame frame, Callback callback) { Listener listener = this.listener; if (listener != null) { try { listener.onData(stream, frame, callback); } catch (Throwable x) { LOG.info("Failure while notifying listener " + listener, x); callback.failed(x); } } else { callback.succeeded(); } }