public Flag(String name) { attributeKey = AttributeKey.newInstance(name); }
public Flag(String name) { attributeKey = AttributeKey.newInstance(name); }
final AttributeKey<Integer> id = AttributeKey.newInstance("ID"); Bootstrap bootstrap = new Bootstrap(); bootstrap.group(new NioEventLoopGroup())
public Flag(String name) { attributeKey = AttributeKey.newInstance(name); }
/** * 初始化连接池 * @throws Exception */ private void initConnPool() throws Exception { for (int i = 0; i < connConfig.poolSize; i++) { ChannelFuture future = bstrap.connect(connConfig.host, connConfig.port).sync(); Channel channel = future.channel(); // 计数器 channel.attr(AttributeKey.newInstance(Result.COUNTER)).set(new AtomicLong()); // result map ConcurrentHashMap<Long, Result> resultMap = new ConcurrentHashMap<Long, Result>(100, 0.75f, 16); channel.attr(AttributeKey.newInstance(Result.RESULT_MAP)).set(resultMap); connectionPool.add(future); } }
private void cacheNode(Node node, SocketChannel channel) { String name = "node-" + node.getId(); boolean exists = AttributeKey.exists(name); AttributeKey attributeKey; if (exists) { attributeKey = AttributeKey.valueOf(name); } else { attributeKey = AttributeKey.newInstance(name); } Attribute<Node> attribute = channel.attr(attributeKey); attribute.set(node); }
NioServerSocketChannel.class).handler( new LoggingHandler(LogLevel.INFO)).childHandler( new NettyServerInitializer()).childAttr(AttributeKey.newInstance("abc"),"aaaa");
@Test public void processingStateClassAndKeyPair_setValue_throws_UnsupportedOperationException() { // given ChannelAttributes.ProcessingStateClassAndKeyPair instance = new ChannelAttributes.ProcessingStateClassAndKeyPair(null, null); // when Throwable ex = catchThrowable(() -> instance.setValue(AttributeKey.newInstance("someattr"))); // then Assertions.assertThat(ex).isInstanceOf(UnsupportedOperationException.class); }
static final AttributeKey<NettyTcpChannel> CHANNEL_KEY = AttributeKey.newInstance("es-channel");