本文整理了Java中io.netty.bootstrap.Bootstrap.attr()
方法的一些代码示例,展示了Bootstrap.attr()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bootstrap.attr()
方法的具体详情如下:
包路径:io.netty.bootstrap.Bootstrap
类名称:Bootstrap
方法名:attr
暂无
代码示例来源:origin: jamesdbloom/mockserver
.group(eventLoopGroup)
.channel(NioSocketChannel.class)
.attr(REGISTRATION_FUTURE, registrationFuture)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
代码示例来源:origin: normanmaurer/netty-in-action
bootstrap.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000);
bootstrap.attr(id, 123456);
ChannelFuture future = bootstrap.connect(
new InetSocketAddress("www.manning.com", 80));
代码示例来源:origin: jamesdbloom/mockserver
.option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024))
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectionTimeoutMillis)
.attr(SECURE, httpRequest.isSecure() != null && httpRequest.isSecure())
.attr(REMOTE_SOCKET, remoteAddress)
.attr(RESPONSE_FUTURE, httpResponseSettableFuture)
.handler(new HttpClientInitializer(proxyConfiguration, mockServerLogger))
.connect(remoteAddress)
代码示例来源:origin: Netflix/zuul
public ChannelFuture connect(final EventLoop eventLoop, String host, final int port, CurrentPassport passport) {
Class socketChannelClass;
if (Server.USE_EPOLL.get()) {
socketChannelClass = EpollSocketChannel.class;
} else {
socketChannelClass = NioSocketChannel.class;
}
SocketAddress socketAddress = new InetSocketAddress(host, port);
final Bootstrap bootstrap = new Bootstrap()
.channel(socketChannelClass)
.handler(channelInitializer)
.group(eventLoop)
.attr(CurrentPassport.CHANNEL_ATTR, passport)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connPoolConfig.getConnectTimeout())
.option(ChannelOption.SO_KEEPALIVE, connPoolConfig.getTcpKeepAlive())
.option(ChannelOption.TCP_NODELAY, connPoolConfig.getTcpNoDelay())
.option(ChannelOption.SO_SNDBUF, connPoolConfig.getTcpSendBufferSize())
.option(ChannelOption.SO_RCVBUF, connPoolConfig.getTcpReceiveBufferSize())
.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, connPoolConfig.getNettyWriteBufferHighWaterMark())
.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, connPoolConfig.getNettyWriteBufferLowWaterMark())
.option(ChannelOption.AUTO_READ, connPoolConfig.getNettyAutoRead())
.remoteAddress(socketAddress);
ZuulBootstrap zuulBootstrap = new ZuulBootstrap(bootstrap);
if (!zuulBootstrap.getResolver(eventLoop).isResolved(socketAddress)) {
LOGGER.warn("NettyClientConnectionFactory got an unresolved server address, host: " + host + ", port: " + port);
unresolvedDiscoveryHost.increment();
}
return bootstrap.connect();
}
代码示例来源:origin: netty/netty
bs.attr(POOL_KEY, this);
ChannelFuture f = connectChannel(bs);
if (f.isDone()) {
代码示例来源:origin: redisson/redisson
bs.attr(POOL_KEY, this);
ChannelFuture f = connectChannel(bs);
if (f.isDone()) {
代码示例来源:origin: Netflix/zuul
public ChannelFuture connect(final EventLoop eventLoop, String host, final int port, CurrentPassport passport) {
Class socketChannelClass;
if (Server.USE_EPOLL.get()) {
socketChannelClass = EpollSocketChannel.class;
} else {
socketChannelClass = NioSocketChannel.class;
}
SocketAddress socketAddress = new InetSocketAddress(host, port);
final Bootstrap bootstrap = new Bootstrap()
.channel(socketChannelClass)
.handler(channelInitializer)
.group(eventLoop)
.attr(CurrentPassport.CHANNEL_ATTR, passport)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connPoolConfig.getConnectTimeout())
.option(ChannelOption.SO_KEEPALIVE, connPoolConfig.getTcpKeepAlive())
.option(ChannelOption.TCP_NODELAY, connPoolConfig.getTcpNoDelay())
.option(ChannelOption.SO_SNDBUF, connPoolConfig.getTcpSendBufferSize())
.option(ChannelOption.SO_RCVBUF, connPoolConfig.getTcpReceiveBufferSize())
.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, connPoolConfig.getNettyWriteBufferHighWaterMark())
.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, connPoolConfig.getNettyWriteBufferLowWaterMark())
.option(ChannelOption.AUTO_READ, connPoolConfig.getNettyAutoRead())
.remoteAddress(socketAddress);
ZuulBootstrap zuulBootstrap = new ZuulBootstrap(bootstrap);
if (!zuulBootstrap.getResolver(eventLoop).isResolved(socketAddress)) {
LOGGER.warn("NettyClientConnectionFactory got an unresolved server address, host: " + host + ", port: " + port);
unresolvedDiscoveryHost.increment();
}
return bootstrap.connect();
}
代码示例来源:origin: wildfly/wildfly
bs.attr(POOL_KEY, this);
ChannelFuture f = connectChannel(bs);
if (f.isDone()) {
代码示例来源:origin: reactor/reactor-netty
/**
* Inject default attribute to the future child {@link Channel} connections. They
* will be available via {@link Channel#attr(AttributeKey)}.
*
* @param key the attribute key
* @param value the attribute value
* @param <T> the attribute type
*
* @return a new {@link UdpClient}
*
* @see Bootstrap#attr(AttributeKey, Object)
*/
public final <T> UdpClient attr(AttributeKey<T> key, T value) {
Objects.requireNonNull(key, "key");
Objects.requireNonNull(value, "value");
return bootstrap(b -> b.attr(key, value));
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* Inject default attribute to the future child {@link Channel} connections. They
* will be available via {@link Channel#attr(AttributeKey)}.
*
* @param key the attribute key
* @param value the attribute value
* @param <T> the attribute type
*
* @return a new {@link UdpServer}
*
* @see Bootstrap#attr(AttributeKey, Object)
*/
public final <T> UdpServer attr(AttributeKey<T> key, T value) {
Objects.requireNonNull(key, "key");
Objects.requireNonNull(value, "value");
return bootstrap(b -> b.attr(key, value));
}
代码示例来源:origin: reactor/reactor-netty
/**
* Inject default attribute to the future child {@link Channel} connections. They
* will be available via {@link Channel#attr(AttributeKey)}.
*
* @param key the attribute key
* @param value the attribute value
* @param <T> the attribute type
*
* @return a new {@link UdpServer}
*
* @see Bootstrap#attr(AttributeKey, Object)
*/
public final <T> UdpServer attr(AttributeKey<T> key, T value) {
Objects.requireNonNull(key, "key");
Objects.requireNonNull(value, "value");
return bootstrap(b -> b.attr(key, value));
}
代码示例来源:origin: reactor/reactor-netty
/**
* Inject default attribute to the future {@link Channel} connection. They will be
* available via {@link Channel#attr(AttributeKey)}.
* If the {@code value} is {@code null}, the attribute of the specified {@code key}
* is removed.
*
* @param key the attribute key
* @param value the attribute value
* @param <T> the attribute type
*
* @return a new {@link TcpClient}
*
* @see Bootstrap#attr(AttributeKey, Object)
*/
public final <T> TcpClient attr(AttributeKey<T> key, @Nullable T value) {
Objects.requireNonNull(key, "key");
return bootstrap(b -> b.attr(key, value));
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* Inject default attribute to the future child {@link Channel} connections. They
* will be available via {@link Channel#attr(AttributeKey)}.
*
* @param key the attribute key
* @param value the attribute value
* @param <T> the attribute type
*
* @return a new {@link UdpClient}
*
* @see Bootstrap#attr(AttributeKey, Object)
*/
public final <T> UdpClient attr(AttributeKey<T> key, T value) {
Objects.requireNonNull(key, "key");
Objects.requireNonNull(value, "value");
return bootstrap(b -> b.attr(key, value));
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
/**
* Inject default attribute to the future {@link Channel} connection. They will be
* available via {@link Channel#attr(AttributeKey)}.
* If the {@code value} is {@code null}, the attribute of the specified {@code key}
* is removed.
*
* @param key the attribute key
* @param value the attribute value
* @param <T> the attribute type
*
* @return a new {@link TcpClient}
*
* @see Bootstrap#attr(AttributeKey, Object)
*/
public final <T> TcpClient attr(AttributeKey<T> key, @Nullable T value) {
Objects.requireNonNull(key, "key");
return bootstrap(b -> b.attr(key, value));
}
代码示例来源:origin: reactor/reactor-netty
static HttpClientConfiguration getAndClean(Bootstrap b) {
HttpClientConfiguration hcc = (HttpClientConfiguration) b.config()
.attrs()
.get(CONF_KEY);
b.attr(CONF_KEY, null);
if (hcc == null) {
hcc = DEFAULT;
}
return hcc;
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
static HttpClientConfiguration getAndClean(Bootstrap b) {
HttpClientConfiguration hcc = (HttpClientConfiguration) b.config()
.attrs()
.get(CONF_KEY);
b.attr(CONF_KEY, null);
if (hcc == null) {
hcc = DEFAULT;
}
return hcc;
}
代码示例来源:origin: nuls-io/nuls
public NettyClient(Node node) {
this.node = node;
boot = new Bootstrap();
boot.attr(NodeAttributeKey.NODE_KEY, node);
boot.group(worker)
.channel(NioSocketChannel.class)
// .option(ChannelOption.SO_BACKLOG, 1024)
.option(ChannelOption.TCP_NODELAY, true) //Send messages immediately
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.SO_SNDBUF, 128 * 1024)
.option(ChannelOption.SO_RCVBUF, 128 * 1024)
.option(ChannelOption.RCVBUF_ALLOCATOR, AdaptiveRecvByteBufAllocator.DEFAULT)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNETCI_TIME_OUT)
.handler(new NulsChannelInitializer<>(new ClientChannelHandler()));
}
代码示例来源:origin: reactor/reactor-netty
@SuppressWarnings("unchecked")
static HttpClientConfiguration getOrCreate(Bootstrap b) {
HttpClientConfiguration hcc = (HttpClientConfiguration) b.config()
.attrs()
.get(CONF_KEY);
if (hcc == null) {
hcc = new HttpClientConfiguration();
b.attr(CONF_KEY, hcc);
}
return hcc;
}
代码示例来源:origin: io.projectreactor.netty/reactor-netty
@SuppressWarnings("unchecked")
static HttpClientConfiguration getOrCreate(Bootstrap b) {
HttpClientConfiguration hcc = (HttpClientConfiguration) b.config()
.attrs()
.get(CONF_KEY);
if (hcc == null) {
hcc = new HttpClientConfiguration();
b.attr(CONF_KEY, hcc);
}
return hcc;
}
代码示例来源:origin: com.netflix.zuul/zuul-core
public ChannelFuture connect(final EventLoop eventLoop, String host, final int port, CurrentPassport passport) {
Class socketChannelClass;
if (Server.USE_EPOLL.get()) {
socketChannelClass = EpollSocketChannel.class;
} else {
socketChannelClass = NioSocketChannel.class;
}
SocketAddress socketAddress = new InetSocketAddress(host, port);
final Bootstrap bootstrap = new Bootstrap()
.channel(socketChannelClass)
.handler(channelInitializer)
.group(eventLoop)
.attr(CurrentPassport.CHANNEL_ATTR, passport)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connPoolConfig.getConnectTimeout())
.option(ChannelOption.SO_KEEPALIVE, connPoolConfig.getTcpKeepAlive())
.option(ChannelOption.TCP_NODELAY, connPoolConfig.getTcpNoDelay())
.option(ChannelOption.SO_SNDBUF, connPoolConfig.getTcpSendBufferSize())
.option(ChannelOption.SO_RCVBUF, connPoolConfig.getTcpReceiveBufferSize())
.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, connPoolConfig.getNettyWriteBufferHighWaterMark())
.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, connPoolConfig.getNettyWriteBufferLowWaterMark())
.option(ChannelOption.AUTO_READ, connPoolConfig.getNettyAutoRead())
.remoteAddress(socketAddress);
ZuulBootstrap zuulBootstrap = new ZuulBootstrap(bootstrap);
if (!zuulBootstrap.getResolver(eventLoop).isResolved(socketAddress)) {
LOGGER.warn("NettyClientConnectionFactory got an unresolved server address, host: " + host + ", port: " + port);
unresolvedDiscoveryHost.increment();
}
return bootstrap.connect();
}
内容来源于网络,如有侵权,请联系作者删除!