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


Java ChannelFuture.isCancelled方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:nsg-ethz,项目名称:iTAP-controller,代码行数:24,代码来源:RPCService.java

示例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;
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:30,代码来源:NettyClientFactory.java


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