• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChannelProgressiveFuture类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.netty.channel.ChannelProgressiveFuture的典型用法代码示例。如果您正苦于以下问题:Java ChannelProgressiveFuture类的具体用法?Java ChannelProgressiveFuture怎么用?Java ChannelProgressiveFuture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChannelProgressiveFuture类属于io.netty.channel包,在下文中一共展示了ChannelProgressiveFuture类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: operationComplete

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@Override
public void operationComplete(ChannelProgressiveFuture cf) {
    // The write operation failed. If the channel was cached, it means it got asynchronously closed.
    // Let's retry a second time.
    if (!abortOnThrowable(cf.cause(), cf.channel())) {

        future.touch();

        /**
         * We need to make sure we aren't in the middle of an authorization
         * process before publishing events as we will re-publish again the
         * same event after the authorization, causing unpredictable
         * behavior.
         */
        boolean startPublishing = !future.getInAuth().get() && !future.getInProxyAuth().get();
        
        if (startPublishing && asyncHandler instanceof ProgressAsyncHandler) {
            ProgressAsyncHandler<?> progressAsyncHandler = (ProgressAsyncHandler<?>) asyncHandler;
            if (notifyHeaders) {
                progressAsyncHandler.onHeadersWritten();
            } else {
                progressAsyncHandler.onContentWritten();
            }
        }
    }
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:27,代码来源:ProgressListener.java


示例2: write

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@Override
public void write(Channel channel, NettyResponseFuture<?> future) throws IOException {
    final InputStream is = inputStream;

    if (future.isStreamWasAlreadyConsumed()) {
        if (is.markSupported())
            is.reset();
        else {
            LOGGER.warn("Stream has already been consumed and cannot be reset");
            return;
        }
    } else {
        future.setStreamWasAlreadyConsumed(true);
    }

    channel.write(new ChunkedStream(is), channel.newProgressivePromise()).addListener(
            new ProgressListener(future.getAsyncHandler(), future, false, getContentLength()) {
                public void operationComplete(ChannelProgressiveFuture cf) {
                    closeSilently(is);
                    super.operationComplete(cf);
                }
            });
    channel.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:25,代码来源:NettyInputStreamBody.java


示例3: operationProgressed

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@Override
public void operationProgressed(ChannelProgressiveFuture future, long progress, long total) throws Exception {

    if (total < 0) {

        log.debug("Channel {} transfer progress: {}", future.channel(), progress);
    } else {

        log.debug("Channel {} transfer progress: {}, total {}", future.channel(), progress, total);
    }
}
 
开发者ID:thundernet8,项目名称:Razor,代码行数:12,代码来源:ProgressiveFutureListener.java


示例4: operationComplete

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@Override
public void operationComplete(ChannelProgressiveFuture future) throws Exception {

    try {

        raf.close();
        log.debug("Channel {} transfer complete", future.channel());
    } catch (Exception e) {

        log.error("Close randomAccessFile with error", e);
    }
}
 
开发者ID:thundernet8,项目名称:Razor,代码行数:13,代码来源:ProgressiveFutureListener.java


示例5: operationProgressed

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@Override
public void operationProgressed(ChannelProgressiveFuture f, long progress, long total) {
    future.touch();
    if (!notifyHeaders && asyncHandler instanceof ProgressAsyncHandler) {
        long lastLastProgress = lastProgress;
        lastProgress = progress;
        if (total < 0)
            total = expectedTotal;
        ProgressAsyncHandler.class.cast(asyncHandler).onContentWriteProgress(progress - lastLastProgress, progress, total);
    }
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:12,代码来源:ProgressListener.java


示例6: write

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@Override
public void write(final Channel channel, NettyResponseFuture<?> future) throws IOException {

    Object msg;
    if (body instanceof RandomAccessBody && !ChannelManager.isSslHandlerConfigured(channel.pipeline()) && !config.isDisableZeroCopy()) {
        msg = new BodyFileRegion((RandomAccessBody) body);

    } else {
        msg = new BodyChunkedInput(body);

        BodyGenerator bg = future.getTargetRequest().getBodyGenerator();
        if (bg instanceof FeedableBodyGenerator && !(bg instanceof ReactiveStreamsBodyGenerator)) {
            final ChunkedWriteHandler chunkedWriteHandler = channel.pipeline().get(ChunkedWriteHandler.class);
            FeedableBodyGenerator.class.cast(bg).setListener(new FeedListener() {
                @Override
                public void onContentAdded() {
                    chunkedWriteHandler.resumeTransfer();
                }
                @Override
                public void onError(Throwable t) {}
            });
        }
    }
    ChannelFuture writeFuture = channel.write(msg, channel.newProgressivePromise());

    writeFuture.addListener(new ProgressListener(future.getAsyncHandler(), future, false, getContentLength()) {
        public void operationComplete(ChannelProgressiveFuture cf) {
            closeSilently(body);
            super.operationComplete(cf);
        }
    });
    channel.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:34,代码来源:NettyBodyBody.java


示例7: writeResponseWithFuture

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
private void writeResponseWithFuture(ChannelHandlerContext ctx,
		DefaultHttpRequest request, HttpResponse response) {
	// TODO Auto-generated method stub
	ChannelFuture responseFuture;
       ChannelFuture lastresponseFuture;
       
       responseFuture = ctx.write(response,ctx.newProgressivePromise());
       lastresponseFuture = ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT);
       
       responseFuture.addListener(new ChannelProgressiveFutureListener() {
           @Override
           public void operationComplete(ChannelProgressiveFuture future) {
               System.err.println(future.channel() + " "+future.cause()+" "+future.isCancelled()+" "+future.isDone()+" "+future.isSuccess()+" "/*+future.sync()*/);
           }

		@Override
		public void operationProgressed(ChannelProgressiveFuture paramF,
				long paramLong1, long paramLong2) throws Exception {
			// TODO Auto-generated method stub
			
		}
       });
       if (!HttpHeaders.isKeepAlive(request)) {
       	lastresponseFuture.addListener(ChannelFutureListener.CLOSE);
       }
	
}
 
开发者ID:Kyunghwa-Yoo,项目名称:StitchRTSP,代码行数:28,代码来源:ServerHandler.java


示例8: operationProgressed

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lets-blade,项目名称:blade,代码行数:9,代码来源:ProgressiveFutureListener.java


示例9: operationComplete

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
@Override
public void operationComplete(ChannelProgressiveFuture future) {
    try {
        raf.close();
        log.debug("{} Transfer complete.", future.channel());
    } catch (Exception e) {
        log.error("RandomAccessFile close error", e);
    }
}
 
开发者ID:lets-blade,项目名称:blade,代码行数:10,代码来源:ProgressiveFutureListener.java


示例10: operationComplete

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
/**
 * 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());
  } else {
    handleChannelWriteFailure(future.cause(), true);
  }
}
 
开发者ID:linkedin,项目名称:ambry,代码行数:15,代码来源:NettyResponseChannel.java


示例11: operationProgressed

import io.netty.channel.ChannelProgressiveFuture; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:linkedin,项目名称:ambry,代码行数:18,代码来源:NettyResponseChannel.java



注:本文中的io.netty.channel.ChannelProgressiveFuture类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MalformedJwtException类代码示例发布时间:2022-05-21
下一篇:
Java ClientDisconnectionFromServerEvent类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap