本文整理汇总了Java中org.jboss.netty.channel.ChannelFuture.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelFuture.isCancelled方法的具体用法?Java ChannelFuture.isCancelled怎么用?Java ChannelFuture.isCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.netty.channel.ChannelFuture
的用法示例。
在下文中一共展示了ChannelFuture.isCancelled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: operationComplete
import org.jboss.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture cf) throws Exception {
if (!cf.isSuccess()) {
synchronized (connections) {
NodeConnection c = connections.remove(node.getNodeId());
if (c != null) c.nuke();
cf.getChannel().close();
}
String message = "[unknown error]";
if (cf.isCancelled()) message = "Timed out on connect";
if (cf.getCause() != null) message = cf.getCause().getMessage();
logger.debug("[{}->{}] Could not connect to RPC " +
"node: {}",
new Object[]{syncManager.getLocalNodeId(),
node.getNodeId(),
message});
} else {
logger.trace("[{}->{}] Channel future successful",
syncManager.getLocalNodeId(),
node.getNodeId());
}
}
示例2: createClient
import org.jboss.netty.channel.ChannelFuture; //导入方法依赖的package包/类
protected Client createClient(String targetIP, int targetPort, int connectTimeout, String key) throws Exception {
ClientBootstrap bootstrap = new ClientBootstrap(nioClient);
bootstrap.setOption("tcpNoDelay", Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.nodelay", "true")));
bootstrap.setOption("reuseAddress", Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.reuseaddress", "true")));
if (connectTimeout < 1000) {
bootstrap.setOption("connectTimeoutMillis", 1000);
} else {
bootstrap.setOption("connectTimeoutMillis", connectTimeout);
}
NettyClientHandler handler = new NettyClientHandler(this, key);
bootstrap.setPipelineFactory(new NettyClientPipelineFactory(handler));
ChannelFuture future = bootstrap.connect(new InetSocketAddress(targetIP, targetPort));
future.awaitUninterruptibly(connectTimeout);
if (!future.isDone()) {
LOGGER.error("Create connection to " + targetIP + ":" + targetPort + " timeout!");
throw new Exception("Create connection to " + targetIP + ":" + targetPort + " timeout!");
}
if (future.isCancelled()) {
LOGGER.error("Create connection to " + targetIP + ":" + targetPort + " cancelled by user!");
throw new Exception("Create connection to " + targetIP + ":" + targetPort + " cancelled by user!");
}
if (!future.isSuccess()) {
LOGGER.error("Create connection to " + targetIP + ":" + targetPort + " error", future.getCause());
throw new Exception("Create connection to " + targetIP + ":" + targetPort + " error", future.getCause());
}
NettyClient client = new NettyClient(future, key, connectTimeout);
handler.setClient(client);
return client;
}