本文整理汇总了Java中io.netty.channel.ChannelFuture.isDone方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelFuture.isDone方法的具体用法?Java ChannelFuture.isDone怎么用?Java ChannelFuture.isDone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.channel.ChannelFuture
的用法示例。
在下文中一共展示了ChannelFuture.isDone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeObject
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public Channel makeObject() throws Exception {
ChannelFuture connectFuture =
bootstrap.connect(loc.getIp(), loc.getPort());
int ticks = 10000;
while (ticks-- > 0) {
if (connectFuture.isDone()) {
return connectFuture.channel();
}
Thread.sleep(10);
}
if (!connectFuture.isDone()) {
throw new TimeoutException("connect " + loc + " timeout");
} else {
return connectFuture.channel();
}
}
示例2: write
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public ProtocolFuture write(byte[] data) {
this.lastActive = System.currentTimeMillis();
if (!isClosed()) {
ChannelFuture future = channel.write(data);
return new ProtocolFuture() {
@Override
public boolean isSuccess() {
return future.isSuccess();
}
@Override
public boolean isDone() {
return future.isDone();
}
};
} else {
return ProtocolFuture.ERRORFUTURE;
}
}
示例3: operationComplete
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isDone() && future.isSuccess()) {
set(new NettyRpcChannel(future.channel()));
} else if (future.isDone() && future.cause() != null) {
setException(future.cause());
} else if (future.isDone() && future.isCancelled()) {
cancel(false);
}
}
示例4: connect
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
/**
* 执行连接调用{@link ChannelFuture executeBooterConnect(InetSocketAddress target)}
* 执行多次会把channel顶掉
* @param target
* @return
*/
protected final boolean connect(InetSocketAddress target)
{
boolean isConnect=false;
try {
log.log(logLevel,getName()+"连接中("+target+")……");
ChannelFuture cf=doConnect(target);
if(cf==null)
{//如果阻塞则使用系统调度器执行
log.log(logLevel,getName()+"连接繁忙("+target+")!稍后重连:"+isReconnect());
doReconect();//这里不能占用IO线程池
}else
{
isConnect=cf.isDone() && cf.isSuccess();
if(isConnect)
{//连接成功
log.log(logLevel,getName()+"连接成功("+target+")!"+cf.channel());
// this.channel=cf.channel();//子类去设置,通过initHandler的channelRegistered去设置更及时
//给通道加上断线重连监听器
cf.channel().closeFuture().removeListener(reconectListener);
cf.channel().closeFuture().addListener(reconectListener);
}else
{//连接不成功则10秒再执行一次连接
log.log(logLevel,getName()+"连接失败("+target+")!"+cf.channel());
doReconect();//这里不能占用IO线程池
}
}
} catch (Exception e) {
log.error(e.getMessage(),e);
}
return isConnect;
}
示例5: sendRequest
import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void sendRequest(ChannelFuture channelFuture, HttpRequest request) throws GeneralSecurityException {
if (channelFuture.isDone()) {
sendRequest(channelFuture.channel(), request);
} else {
channelFuture.addListener(future -> sendRequest(channelFuture.channel(), request));
}
}