當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。