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


Java ChannelFuture.awaitUninterruptibly方法代码示例

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


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

示例1: bootstrap

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public boolean bootstrap(HostAndPort seed, 
                         Node localNode) throws SyncException {
    this.localNode = localNode;
    succeeded = false;
    SocketAddress sa =
            new InetSocketAddress(seed.getHostText(), seed.getPort());
    ChannelFuture future = bootstrap.connect(sa);
    future.awaitUninterruptibly();
    if (!future.isSuccess()) {
        logger.debug("Could not connect to " + seed, future.cause());
        return false;
    }
    Channel channel = future.channel();
    logger.debug("[{}] Connected to {}", 
                 localNode != null ? localNode.getNodeId() : null,
                 seed);
    
    try {
        channel.closeFuture().await();
    } catch (InterruptedException e) {
        logger.debug("Interrupted while waiting for bootstrap");
        return succeeded;
    }
    return succeeded;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:26,代码来源:BootstrapClient.java

示例2: connect

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
protected boolean connect(String hostname, int port) {
    ready = false;
    if (channel == null || !channel.isActive()) {
        SocketAddress sa =
                new InetSocketAddress(hostname, port);
        ChannelFuture future = clientBootstrap.connect(sa);
        future.awaitUninterruptibly();
        if (!future.isSuccess()) {
            logger.error("Could not connect to " + hostname + 
                         ":" + port, future.cause());
            return false;
        }
        channel = future.channel();
    }
    while (!ready && channel != null && channel.isActive()) {
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) { }
    }
    if (!ready || channel == null || !channel.isActive()) {
        logger.warn("Timed out connecting to {}:{}", hostname, port);
        return false;
    }
    logger.debug("Connected to {}:{}", hostname, port);
    return true;
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:27,代码来源:RemoteSyncManager.java


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