io.netty.channel.ChannelProgressiveFuture Java Examples

The following examples show how to use io.netty.channel.ChannelProgressiveFuture. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProgressiveFutureListener.java    From blade with Apache License 2.0 5 votes vote down vote up
@Override
public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) {
    if (total < 0) { // total unknown
        log.debug("{} Transfer progress: {}", future.channel(), progress);
    } else {
        log.debug("{} Transfer progress: {}/{}", future.channel(), progress, total);
    }
}
 
Example #2
Source File: ProgressiveFutureListener.java    From blade with Apache License 2.0 5 votes vote down vote up
@Override
public void operationComplete(ChannelProgressiveFuture future) {
    try {
        raf.close();
        log.debug("{} Transfer complete.", future.channel());
    } catch (Exception e) {
        log.error("RandomAccessFile close error", e);
    }
}
 
Example #3
Source File: NettyResponseChannel.java    From ambry with Apache License 2.0 5 votes vote down vote up
/**
 * Called once the write is complete i.e. either all chunks that were needed to be written were written or there
 * was an error  writing the chunks.
 * @param future the {@link ChannelProgressiveFuture} that is being listened on.
 */
@Override
public void operationComplete(ChannelProgressiveFuture future) {
  if (future.isSuccess()) {
    logger.trace("Response sending complete on channel {}", ctx.channel());
    completeRequest(request == null || !request.isKeepAlive(), false);
  } else {
    handleChannelWriteFailure(future.cause(), true);
  }
}
 
Example #4
Source File: NettyResponseChannel.java    From ambry with Apache License 2.0 3 votes vote down vote up
/**
 * Uses {@code progress} to determine chunks whose callbacks need to be invoked.
 * @param future the {@link ChannelProgressiveFuture} that is being listened on.
 * @param progress the total number of bytes that have been written starting from the time writes were invoked via
 *                 {@link ChunkedWriteHandler}.
 * @param total the total number of bytes that need to be written i.e. the target number. This is not relevant to
 *              {@link ChunkedWriteHandler} because there is no target number. All calls to this function except
 *              the very last one will have a negative {@code total}.
 */
@Override
public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) {
  logger.trace("{} bytes of response written on channel {}", progress, ctx.channel());
  while (chunksAwaitingCallback.peek() != null
      && progress >= chunksAwaitingCallback.peek().writeCompleteThreshold) {
    chunksAwaitingCallback.poll().resolveChunk(null);
  }
}