本文整理了Java中io.netty.bootstrap.Bootstrap.config()
方法的一些代码示例,展示了Bootstrap.config()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bootstrap.config()
方法的具体详情如下:
包路径:io.netty.bootstrap.Bootstrap
类名称:Bootstrap
方法名:config
暂无
代码示例来源:origin: redisson/redisson
public EventLoopGroup getEventLoopGroup() {
return bootstrap.config().group();
}
代码示例来源:origin: redisson/redisson
public EventLoopGroup getEventLoopGroup() {
return bootstrap.config().group();
}
代码示例来源:origin: netty/netty
executor = bootstrap.config().group().next();
this.maxConnections = maxConnections;
this.maxPendingAcquires = maxPendingAcquires;
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void shutdown() {
bootstrap.config().group().shutdownGracefully();
try {
bootstrap.config().group().terminationFuture().sync();
} catch (InterruptedException e) {
GlowServer.logger.log(Level.SEVERE,
"Datagram server shutdown process interrupted!",
e);
}
}
}
代码示例来源:origin: redisson/redisson
executor = bootstrap.config().group().next();
this.maxConnections = maxConnections;
this.maxPendingAcquires = maxPendingAcquires;
代码示例来源:origin: redisson/redisson
AddressResolver<InetSocketAddress> resolver = (AddressResolver<InetSocketAddress>) bootstrap.config().resolver().getResolver(bootstrap.config().group().next());
Future<InetSocketAddress> resolveFuture = resolver.resolve(InetSocketAddress.createUnresolved(uri.getHost(), uri.getPort()));
resolveFuture.addListener(new FutureListener<InetSocketAddress>() {
代码示例来源:origin: netty/netty
@Override
public final Future<Channel> acquire() {
return acquire(bootstrap.config().group().next().<Channel>newPromise());
}
代码示例来源:origin: redisson/redisson
AddressResolver<InetSocketAddress> resolver = (AddressResolver<InetSocketAddress>) bootstrap.config().resolver().getResolver(bootstrap.config().group().next());
Future<InetSocketAddress> resolveFuture = resolver.resolve(InetSocketAddress.createUnresolved(uri.getHost(), uri.getPort()));
resolveFuture.addListener(new FutureListener<InetSocketAddress>() {
代码示例来源:origin: redisson/redisson
private void reconnect(final RedisConnection connection, final int attempts){
int timeout = 2 << attempts;
if (bootstrap.config().group().isShuttingDown()) {
return;
}
try {
timer.newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
tryReconnect(connection, Math.min(BACKOFF_CAP, attempts + 1));
}
}, timeout, TimeUnit.MILLISECONDS);
} catch (IllegalStateException e) {
// skip
}
}
代码示例来源:origin: redisson/redisson
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
if (connection.isClosed() || bootstrap.config().group().isShuttingDown()) {
return;
代码示例来源:origin: redisson/redisson
private void reconnect(final RedisConnection connection, final int attempts){
int timeout = 2 << attempts;
if (bootstrap.config().group().isShuttingDown()) {
return;
}
try {
timer.newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
tryReconnect(connection, Math.min(BACKOFF_CAP, attempts + 1));
}
}, timeout, TimeUnit.MILLISECONDS);
} catch (IllegalStateException e) {
// skip
}
}
代码示例来源:origin: redisson/redisson
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
if (connection.isClosed() || bootstrap.config().group().isShuttingDown()) {
return;
代码示例来源:origin: redisson/redisson
@Override
public final Future<Channel> acquire() {
return acquire(bootstrap.config().group().next().<Channel>newPromise());
}
代码示例来源:origin: relayrides/pushy
@Override
public void run() {
final Bootstrap bootstrap = ApnsChannelFactory.this.bootstrapTemplate.clone()
.channelFactory(new AugmentingReflectiveChannelFactory<>(
ClientChannelClassUtil.getSocketChannelClass(ApnsChannelFactory.this.bootstrapTemplate.config().group()),
CHANNEL_READY_PROMISE_ATTRIBUTE_KEY, channelReadyPromise));
final ChannelFuture connectFuture = bootstrap.connect();
connectFuture.addListener(new GenericFutureListener<ChannelFuture>() {
@Override
public void operationComplete(final ChannelFuture future) {
if (!future.isSuccess()) {
// This may seem spurious, but our goal here is to accurately report the cause of
// connection failure; if we just wait for connection closure, we won't be able to
// tell callers anything more specific about what went wrong.
tryFailureAndLogRejectedCause(channelReadyPromise, future.cause());
}
}
});
connectFuture.channel().closeFuture().addListener(new GenericFutureListener<ChannelFuture> () {
@Override
public void operationComplete(final ChannelFuture future) {
// We always want to try to fail the "channel ready" promise if the connection closes; if it has
// already succeeded, this will have no effect.
channelReadyPromise.tryFailure(
new IllegalStateException("Channel closed before HTTP/2 preface completed."));
}
});
}
}, delay, TimeUnit.SECONDS);
代码示例来源:origin: wildfly/wildfly
@Override
public final Future<Channel> acquire() {
return acquire(bootstrap.config().group().next().<Channel>newPromise());
}
代码示例来源:origin: redisson/redisson
private void tryReconnect(final RedisConnection connection, final int nextAttempt) {
if (connection.isClosed() || bootstrap.config().group().isShuttingDown()) {
return;
代码示例来源:origin: redisson/redisson
private void tryReconnect(final RedisConnection connection, final int nextAttempt) {
if (connection.isClosed() || bootstrap.config().group().isShuttingDown()) {
return;
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldLogOnlyTheFirstCaughtException() throws Exception
{
AssertableLogProvider logProvider = new AssertableLogProvider();
BoltConnection connection = mock( BoltConnection.class );
HouseKeeper houseKeeper = new HouseKeeper( connection, logProvider.getLog( HouseKeeper.class ) );
Bootstrap bootstrap = newBootstrap( houseKeeper );
RuntimeException error1 = new RuntimeException( "error #1" );
RuntimeException error2 = new RuntimeException( "error #2" );
RuntimeException error3 = new RuntimeException( "error #3" );
try ( ServerSocket serverSocket = new ServerSocket( 0 ) )
{
ChannelFuture future = bootstrap.connect( "localhost", serverSocket.getLocalPort() ).sync();
Channel channel = future.channel();
// fire multiple errors
channel.pipeline().fireExceptionCaught( error1 );
channel.pipeline().fireExceptionCaught( error2 );
channel.pipeline().fireExceptionCaught( error3 );
// await for the channel to be closed by the HouseKeeper
channel.closeFuture().sync();
}
finally
{
// make sure event loop group is always terminated
bootstrap.config().group().shutdownGracefully().sync();
}
logProvider.assertExactly(
inLog( HouseKeeper.class ).error( startsWith( "Fatal error occurred when handling a client connection" ), equalTo( error1 ) ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldNotLogExceptionsWhenEvenLoopIsShuttingDown() throws Exception
{
AssertableLogProvider logProvider = new AssertableLogProvider();
BoltConnection connection = mock( BoltConnection.class );
HouseKeeper houseKeeper = new HouseKeeper( connection, logProvider.getLog( HouseKeeper.class ) );
Bootstrap bootstrap = newBootstrap( houseKeeper );
try ( ServerSocket serverSocket = new ServerSocket( 0 ) )
{
ChannelFuture future = bootstrap.connect( "localhost", serverSocket.getLocalPort() ).sync();
Channel channel = future.channel();
// write some messages without flushing
for ( int i = 0; i < 100; i++ )
{
// use void promise which should redirect all write errors back to the pipeline and the HouseKeeper
channel.write( writeUtf8( channel.alloc(), "Hello" ), channel.voidPromise() );
}
// stop the even loop to make all pending writes fail
bootstrap.config().group().shutdownGracefully();
// await for the channel to be closed by the HouseKeeper
channel.closeFuture().sync();
}
finally
{
// make sure event loop group is always terminated
bootstrap.config().group().shutdownGracefully().sync();
}
logProvider.assertNoLoggingOccurred();
}
代码示例来源:origin: AsyncHttpClient/async-http-client
ChannelHandler httpBootstrapHandler = socksBootstrap.config().handler();
内容来源于网络,如有侵权,请联系作者删除!