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


Java ChannelFuture.cause方法代码示例

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


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

示例1: start

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void start() throws EmbeddedServletContainerException {
    ServerBootstrap b = new ServerBootstrap();
    groups(b);
    servletExecutor = new DefaultEventExecutorGroup(50);
    b.childHandler(new NettyEmbeddedServletInitializer(servletExecutor, context));

    // Don't yet need the complexity of lifecycle state, listeners etc, so tell the context it's initialised here
    context.setInitialised(true);

    ChannelFuture future = b.bind(address).awaitUninterruptibly();
    //noinspection ThrowableResultOfMethodCallIgnored
    Throwable cause = future.cause();
    if (null != cause) {
        throw new EmbeddedServletContainerException("Could not start Netty server", cause);
    }
    logger.info(context.getServerInfo() + " started on port: " + getPort());
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:19,代码来源:NettyEmbeddedServletContainer.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: sendResponse

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void sendResponse(ChannelHandlerContext ctx, ServiceResponse<?> resObj, int timeout)
		throws JsonGenerationException, JsonMappingException, IOException {
	StringWriter writer = new StringWriter();
	this.objectMapper.writeValue(writer, resObj);
	writer.write(Constants.PROTOCOL_REQUEST_DELIMITER);

	ChannelFuture future = ctx.writeAndFlush(writer.toString());

	try {
		boolean success = future.await(timeout, TimeUnit.MILLISECONDS);

		if (future.cause() != null) {
			throw new NettoIOException("error response error ", future.cause());
		} else if (!success) {
			throw new NettoIOException("response error timeout");
		}
	} catch (InterruptedException e) {
		throw new RemoteAccessException("await Interrupted", e);
	} finally {

	}
}
 
开发者ID:sylinklee,项目名称:netto_rpc,代码行数:23,代码来源:AbstractServiceChannelHandler.java

示例4: requestData

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
public void requestData(String data) {
    if (ctx != null) {
        try {
            ChannelFuture f = ctx.writeAndFlush(Unpooled.copiedBuffer(data, CharsetUtil.UTF_8)).sync();

            if (!f.isSuccess())
                try {
                    throw f.cause();
                } catch (Throwable throwable) {
                    throwable.printStackTrace();
                }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:17,代码来源:EchoClientHandler.java

示例5: channelRead

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    ByteBuf in = (ByteBuf) msg;
    String sentData = in.toString(CharsetUtil.UTF_8);
    String returnee = sentData + "-::=::-" + "{}";

    RequestProcessor reprocessor = EchoServer.process(sentData);

    if (reprocessor != null)
        returnee = sentData + "-::=::-" + reprocessor.getProcessedData();

    ChannelFuture f = ctx.writeAndFlush(Unpooled.copiedBuffer(returnee, CharsetUtil.UTF_8)).sync();

    if (!f.isSuccess())
        try {
            throw f.cause();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:21,代码来源:EchoServerHandler.java

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

示例7: operationComplete

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

  if (!future.isSuccess()) {
    removeFromMap(coordinationId);
    if (future.channel().isActive()) {
      if(future.cause() != null){
        setException(future.cause());
      } else {
        setException(new RpcException("Unknown failure when sending message."));
      }
    } else {
      setException(new ChannelClosedException());
    }
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:RequestIdMap.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) throws Exception {
  final String msg = String.format("[%s]: Channel closed %s", rpcConfig.getName(), clientConnection.getName());

  final ChannelClosedException ex = future.cause() != null ? new ChannelClosedException(msg, future.cause()) : new ChannelClosedException(msg);
  logger.info(msg);
  clientConnection.channelClosed(ex);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:RpcBus.java

示例10: operationComplete

import io.netty.channel.ChannelFuture; //导入方法依赖的package包/类
@Override
public void operationComplete(ChannelFuture future) throws Exception {
  if (!future.isSuccess()) {
    AsyncCall call = rpcChannel.removePendingCall(id);
    if (call != null) {
      if (future.cause() instanceof IOException) {
        call.setFailed((IOException) future.cause());
      } else {
        call.setFailed(new IOException(future.cause()));
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:14,代码来源:AsyncRpcChannel.java


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