/** * This method will block if the async write queue is currently larger * than the configured maximum. The amount of time that this method * will block is dependent on the write timeout of the transport * associated with the specified connection. */ private static void blockUntilQueueFree(final Connection c) { if (!c.canWrite()) { final FutureImpl<Boolean> future = Futures.createSafeFuture(); // Connection may be obtained by calling FilterChainContext.getConnection(). c.notifyCanWrite(new WriteHandler() { @Override public void onWritePossible() throws Exception { future.result(TRUE); } @Override public void onError(Throwable t) { future.failure(makeIOException(t)); } }); block(c, future); } }
@Override public synchronized void flush() throws IOException { final Connection c = feedableBodyGenerator.context.getConnection(); if (isReady()) { boolean notReady = writeUntilFullOrDone(c); if (!isDone()) { if (notReady) { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } else { // write queue is full, leverage WriteListener to let us know // when it is safe to write again. c.notifyCanWrite(new WriteHandlerImpl()); } } } else { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public void notifyWritePossible(WriteHandler writeHandler) { connection.getConnection().notifyCanWrite(writeHandler); }
@Override public boolean isValid() { if (!connection.canWrite() && writeHandlerRegistered.compareAndSet(false, true)) { connection.notifyCanWrite(new WriteHandler() { @Override public void onWritePossible() throws Exception { writeHandlerRegistered.set(false); taskProcessor.processTask(); } @Override public void onError(Throwable t) { writeHandlerRegistered.set(false); Logger.getLogger(GrizzlyWriter.class.getName()).log(Level.WARNING, t.getMessage(), t); // TODO: do what? } }); return false; } return true; } }
@Override public boolean isValid() { if (!connection.canWrite() && writeHandlerRegistered.compareAndSet(false, true)) { connection.notifyCanWrite(new WriteHandler() { @Override public void onWritePossible() throws Exception { writeHandlerRegistered.set(false); taskProcessor.processTask(); } @Override public void onError(Throwable t) { writeHandlerRegistered.set(false); Logger.getLogger(GrizzlyWriter.class.getName()).log(Level.WARNING, t.getMessage(), t); // TODO: do what? } }); return false; } return true; } }
/** * This method will block if the async write queue is currently larger * than the configured maximum. The amount of time that this method * will block is dependent on the write timeout of the transport * associated with the specified connection. */ private static void blockUntilQueueFree(final Connection c) { if (!c.canWrite()) { final FutureImpl<Boolean> future = Futures.createSafeFuture(); // Connection may be obtained by calling FilterChainContext.getConnection(). c.notifyCanWrite(new WriteHandler() { @Override public void onWritePossible() throws Exception { future.result(TRUE); } @Override public void onError(Throwable t) { future.failure(makeIOException(t)); } }); block(c, future); } }
/** * This method will block if the async write queue is currently larger * than the configured maximum. The amount of time that this method * will block is dependent on the write timeout of the transport * associated with the specified connection. */ private static void blockUntilQueueFree(final Connection c) { if (!c.canWrite()) { final FutureImpl<Boolean> future = Futures.createSafeFuture(); // Connection may be obtained by calling FilterChainContext.getConnection(). c.notifyCanWrite(new WriteHandler() { @Override public void onWritePossible() throws Exception { future.result(TRUE); } @Override public void onError(Throwable t) { future.failure(makeIOException(t)); } }); block(c, future); } }
/** * This method will block if the async write queue is currently larger * than the configured maximum. The amount of time that this method * will block is dependent on the write timeout of the transport * associated with the specified connection. */ private static void blockUntilQueueFree(final Connection c) { if (!c.canWrite()) { final FutureImpl<Boolean> future = Futures.createSafeFuture(); // Connection may be obtained by calling FilterChainContext.getConnection(). c.notifyCanWrite(new WriteHandler() { @Override public void onWritePossible() throws Exception { future.result(TRUE); } @Override public void onError(Throwable t) { future.failure(makeIOException(t)); } }); block(c, future); } }
@Override public synchronized void flush() throws IOException { final Connection c = feedableBodyGenerator.context.getConnection(); if (isReady()) { boolean notReady = writeUntilFullOrDone(c); if (!isDone()) { if (notReady) { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } else { // write queue is full, leverage WriteListener to let us know // when it is safe to write again. c.notifyCanWrite(new WriteHandlerImpl()); } } } else { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } }
@Override public synchronized void flush() throws IOException { final Connection c = feedableBodyGenerator.context.getConnection(); if (isReady()) { boolean notReady = writeUntilFullOrDone(c); if (!isDone()) { if (notReady) { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } else { // write queue is full, leverage WriteListener to let us know // when it is safe to write again. c.notifyCanWrite(new WriteHandlerImpl()); } } } else { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } }
@Override public synchronized void flush() throws IOException { final Connection c = feedableBodyGenerator.context.getConnection(); if (isReady()) { boolean notReady = writeUntilFullOrDone(c); if (!isDone()) { if (notReady) { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } else { // write queue is full, leverage WriteListener to let us know // when it is safe to write again. c.notifyCanWrite(new WriteHandlerImpl()); } } } else { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } }
@Override public synchronized void flush() throws IOException { final Connection c = feedableBodyGenerator.context.getConnection(); if (isReady()) { boolean notReady = writeUntilFullOrDone(c); if (!isDone()) { if (notReady) { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } else { // write queue is full, leverage WriteListener to let us know // when it is safe to write again. c.notifyCanWrite(new WriteHandlerImpl()); } } } else { notifyReadyToFeed(new ReadyToFeedListenerImpl()); } }