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


Java ChannelFuture.isSuccess方法代码示例

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


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

示例1: operationComplete

import io.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.channel().close();
        }
        
        String message = "[unknown error]";
        if (cf.isCancelled()) message = "Timed out on connect";
        if (cf.cause() != null) message = cf.cause().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:xuraylei,项目名称:fresco_floodlight,代码行数:24,代码来源:RPCService.java

示例2: reply

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
/**
 * 通知消息
 *
 * @param channel
 * @param socketMessage
 */
static void reply(Channel channel, SocketMessage socketMessage) {
    ChannelFuture future = channel.writeAndFlush(socketMessage);

    if (future.isSuccess()) {
        // 成功
    } else if (future.cause() != null) {
        // FIXME: 2017/8/8 全部转换为领域模型
        // 异常
        LOGGER.error("{}", future.cause());
    } else {
        // 取消
        //  throw new Exception("客户端取消执行");
        LOGGER.error("Client cancel receive message.");
    }
}
 
开发者ID:freedompy,项目名称:commelina,代码行数:22,代码来源:ReplyUtils.java

示例3: 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

示例4: 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;
    }
}
 
开发者ID:935237604,项目名称:easysocket,代码行数:21,代码来源:NettyChannel.java

示例5: operationComplete

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture channelFuture) throws Exception {
    if (!channelFuture.isSuccess()) {
        channelFuture.channel().close();

        if (count.incrementAndGet() < MAX_RETRY) {
            final EventLoop loop = channelFuture.channel().eventLoop();

            loop.schedule(() -> {
                controller.connectRetry(this.ip, this.port, this);
            }, 1L, TimeUnit.SECONDS);
        } else {
            log.info("Connection to the ovsdb {}:{} failed",
                     this.ip.toString(), this.port.toString());
        }
    } else {
        handleNewNodeConnection(channelFuture.channel());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:Controller.java

示例6: operationComplete

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture f) throws Exception {
    final long et = System.nanoTime() - mark;
    if (!f.isSuccess()) {
        if (configuration.isAutoReconnect())
            reconnect(configuration.getReconnectInterval(), future, host, port);
        else {
            logger.debug("failed to connected to host: " + host + ", port: " + port + ", elapsed createTime: " + NANOSECONDS.toMillis(et) + " ms");
            future.failure(f.cause());
        }
    } else {
        transport.setChannel(f.channel());
        future.success(null);
        logger.debug("connected to host: " + host + ", port: " + port + ", elapsed createTime: " + NANOSECONDS.toMillis(et) + " ms");
    }
}
 
开发者ID:leonchen83,项目名称:redis-cluster-watchdog,代码行数:17,代码来源:NioInitiator.java

示例7: 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

示例8: 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);
    }
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:11,代码来源:RpcClient.java

示例9: operationComplete

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture future) {
    if (!future.isSuccess()) {
      Throwable ex = future.cause();
      if(ex == null){
        sendFailure(new UserRpcException(null, "Unknown failure when sending message.", null));
      } else {
        sendFailure(new UserRpcException(null, "Failure when sending message.", ex));
      }
    }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:RpcBus.java

示例10: messageSent

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
private void messageSent(ChannelHandlerContext context, ChannelFuture future, RequestHandler requestHandler)
{
    try {
        if (!future.isSuccess()) {
            onError(context, new TTransportException("Sending request failed", future.cause()));
            return;
        }

        requestHandler.onRequestSent();
    }
    catch (Throwable t) {
        onError(context, t);
    }
}
 
开发者ID:airlift,项目名称:drift,代码行数:15,代码来源:ThriftClientHandler.java

示例11: operationComplete

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture future) throws Exception {
    connectComplete = true;

    if (future.isSuccess()) {
        if (future.channel().isOpen()) {
            if (trace) {
                log.trace("Channel connect future completed successfully [to={}]", id);
            }
        } else {
            // Channel was disconnect()'ed while we were connecting.
            becomeDisconnected();
        }
    } else if (firstError == null) {
        if (trace) {
            log.trace("Notifying on connect future failure [to={}]", id, future.cause());
        }

        firstError = NettyErrorUtils.unwrap(future.cause());

        ChannelPipeline pipeline = future.channel().pipeline();

        if (pipeline.names().contains(NettyClientStateHandler.class.getName())) {
            pipeline.fireExceptionCaught(firstError);
        } else {
            becomeDisconnected();
        }
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:30,代码来源:NettyClient.java

示例12: sendResponse

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
default void sendResponse(ChannelHandlerContext ctx, Object msg) {
    ChannelFuture f = ctx.writeAndFlush(msg);
    LOG.trace(Constants.LOG_RETURNING_RESPONSE, msg);
    if (!f.isSuccess()) {
        LOG.error(Constants.ERR_WRITING_RESPONSE, f.cause());
    }
}
 
开发者ID:NationalSecurityAgency,项目名称:qonduit,代码行数:8,代码来源:HttpHandler.java

示例13: operationComplete

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture future) {
    if (future.isSuccess()) {
        log.info("Successfully connected with remote server ...");
        inbound.read();
    } else {
        log.error("Failed establishing connection with remote server ...");
        inbound.close();
    }
}
 
开发者ID:thebagchi,项目名称:heimdall-proxy,代码行数:11,代码来源:TcpProxyClient.java

示例14: open

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
/**
 * Opens the connection to the given serial port.
 *
 * @param address The serial port, must not be null.
 * @throws IOException if opening of the channel fails.
 */
public void open(RxtxDeviceAddress address) throws IOException {
    requireNonNull(address);

    lock.lock();

    try {

        checkIfChannelIsClose();

        Log.debug(SERIAL, "Opening channel at serial port '" + address.value() + "'.");

        ChannelFuture future = bootstrap.connect(address).syncUninterruptibly();
        if (!future.isSuccess()) {
            fireOnError();
            throw new IOException("Serial channel couldn't be opened!");
        }

        Log.debug(SERIAL, "Serial channel was successfully opened.");

        currentChannel = future.channel();

    } catch (Exception e) {
        throw new IOException("Can not connect to '"+address.value()+"'!", e);
    } finally {
        lock.unlock();
    }
}
 
开发者ID:tbressler,项目名称:waterrower-core,代码行数:34,代码来源:RxtxCommunicationService.java

示例15: operationComplete

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void operationComplete(ChannelFuture future) {
	if (!future.isSuccess()) {
		future.channel().close();
	}
}
 
开发者ID:osswangxining,项目名称:mqttserver,代码行数:6,代码来源:TcpChannelEntity.java


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