当前位置: 首页>>代码示例>>Java>>正文


Java ChannelFuture.await方法代码示例

本文整理汇总了Java中org.jboss.netty.channel.ChannelFuture.await方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelFuture.await方法的具体用法?Java ChannelFuture.await怎么用?Java ChannelFuture.await使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.netty.channel.ChannelFuture的用法示例。


在下文中一共展示了ChannelFuture.await方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: send

import org.jboss.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void send(Object message, boolean sent) throws RemotingException {
    super.send(message, sent);
    
    boolean success = true;
    int timeout = 0;
    try {
        ChannelFuture future = channel.write(message);
        if (sent) {
            timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
            success = future.await(timeout);
        }
        Throwable cause = future.getCause();
        if (cause != null) {
            throw cause;
        }
    } catch (Throwable e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e);
    }
    
    if(! success) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress()
                + "in timeout(" + timeout + "ms) limit");
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:NettyChannel.java

示例2: send

import org.jboss.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void send(Object message, boolean sent) throws RemotingException {
    super.send(message, sent);
    
    boolean success = true;
    int timeout = 0;
    try {
        ChannelFuture future = channel.write(message);
        //FIXME  sent为true的话   要等待数据写完才返回,失败抛出异常   add by jileng
        if (sent) {
            timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
            // 写超时了,难道不能取消这次写操作?
            success = future.await(timeout);
        }
        Throwable cause = future.getCause();
        if (cause != null) {
            throw cause;
        }
    } catch (Throwable e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e);
    }
    
    if(! success) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress()
                + "in timeout(" + timeout + "ms) limit");
    }
}
 
开发者ID:spccold,项目名称:dubbo-comments,代码行数:27,代码来源:NettyChannel.java

示例3: send

import org.jboss.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void send(Object message, boolean sent) throws RemotingException {
    super.send(message, sent); //调用父类的send方法进行异常判断
    
    boolean success = true;
    int timeout = 0;
    try {
        //NIO框架通知执行写操作
        ChannelFuture future = channel.write(message);
        if (sent) {//如果已经发送成功
            timeout = getUrl().getPositiveParameter(Constants.TIMEOUT_KEY, Constants.DEFAULT_TIMEOUT);
            success = future.await(timeout);
        }
        //获得失败原因
        Throwable cause = future.getCause();
        if (cause != null) {
            throw cause;
        }
    } catch (Throwable e) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress() + ", cause: " + e.getMessage(), e);
    }
    
    if(! success) {
        throw new RemotingException(this, "Failed to send message " + message + " to " + getRemoteAddress()
                + "in timeout(" + timeout + "ms) limit");
    }
}
 
开发者ID:DoubleSmile,项目名称:dubbo-learning,代码行数:27,代码来源:NettyChannel.java

示例4: write

import org.jboss.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void write(byte[] data, int offest, int length) throws IOException {
	ChannelBuffer channelBuffer = ChannelBuffers.wrappedBuffer(data, offest, length);
	ChannelFuture channelFuture = httpChannel.channel().write(channelBuffer);
	try {
		channelFuture.await();
	} catch (InterruptedException e) {
		throw new IOException(e);
	}
	if(!channelFuture.isSuccess()){
		logger.error("stream write fail. connected[{}]", channelFuture.getChannel().isConnected());
		throw new IOException();
	}
}
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:14,代码来源:StreamWriter.java


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