@Override public void operationComplete(final Future<Void> future) throws Exception { BaseHttp2Server.this.bootstrap.config().group().shutdownGracefully(); } });
@Override public void shutdown() { channel.close(); bootstrap.config().group().shutdownGracefully(); bootstrap.config().childGroup().shutdownGracefully(); try { bootstrap.config().group().terminationFuture().sync(); bootstrap.config().childGroup().terminationFuture().sync(); } catch (InterruptedException e) { GlowServer.logger.log(Level.SEVERE, "Socket server shutdown process interrupted!", e); } } }
this.bootstrap.config().group().terminationFuture().addListener(new GenericFutureListener() {
/** * 动态添加aesToken * * @param aesToken * @return */ public boolean addAesToken(AesToken aesToken) { if (bootstrap == null) { return false; } ServerBootstrapConfig c = bootstrap.config(); ((WeixinServerInitializer) c.childHandler()).addAesToken(aesToken); return true; }
/** * 关闭微信服务 * * @param blocking * 阻塞关闭 * @return */ public boolean shutdown(boolean blocking) { if (bootstrap == null) { return false; } ServerBootstrapConfig c = bootstrap.config(); Future<?> bossF = c.group().shutdownGracefully(); Future<?> workerF = c.childGroup().shutdownGracefully(); if (blocking) { bossF.awaitUninterruptibly(); workerF.awaitUninterruptibly(); } messageHandlerList = null; messageInterceptorList = null; messageDispatcher = null; bootstrap = null; return true; }
@Override public void operationComplete(final Future<Void> future) throws Exception { MockApnsServer.this.bootstrap.config().group().shutdownGracefully(); } });
@Override public void operationComplete(final Future<Void> future) throws Exception { BaseHttp2Server.this.bootstrap.config().group().shutdownGracefully(); } });
/** * Remove a configuration given its unique name from the given {@link * ServerBootstrap} * * @param b a server bootstrap * @param name a configuration name */ public static ServerBootstrap removeConfiguration(ServerBootstrap b, String name) { Objects.requireNonNull(b, "bootstrap"); Objects.requireNonNull(name, "name"); b.childHandler(removeConfiguration(b.config().childHandler(), name)); return b; }
static HttpServerConfiguration getAndClean(ServerBootstrap b) { HttpServerConfiguration hcc = (HttpServerConfiguration) b.config() .attrs() .get(CONF_KEY); b.attr(CONF_KEY, null); if (hcc == null) { hcc = DEFAULT; } return hcc; }
@Override protected void shutDown() throws Exception { channelGroup.close().awaitUninterruptibly(); List<Future<?>> futures = new ArrayList<>(); futures.add(bootstrap.config().group().shutdownGracefully(0, CLOSE_CHANNEL_TIMEOUT, TimeUnit.SECONDS)); futures.add(bootstrap.config().childGroup().shutdownGracefully(0, CLOSE_CHANNEL_TIMEOUT, TimeUnit.SECONDS)); for (Future<?> future : futures) { future.awaitUninterruptibly(); } LOG.info("Tracker service stopped at {}", url); }
static HttpServerConfiguration getAndClean(ServerBootstrap b) { HttpServerConfiguration hcc = (HttpServerConfiguration) b.config() .attrs() .get(CONF_KEY); b.attr(CONF_KEY, null); if (hcc == null) { hcc = DEFAULT; } return hcc; }
@Override protected void shutDown() throws Exception { channelGroup.close().awaitUninterruptibly(); List<Future<?>> futures = new ArrayList<>(); futures.add(bootstrap.config().group().shutdownGracefully(0, CLOSE_CHANNEL_TIMEOUT, TimeUnit.SECONDS)); futures.add(bootstrap.config().childGroup().shutdownGracefully(0, CLOSE_CHANNEL_TIMEOUT, TimeUnit.SECONDS)); for (Future<?> future : futures) { future.awaitUninterruptibly(); } LOG.info("Tracker service stopped at {}", url); }
/** * Find Ssl support in the given server bootstrap * * @param b a bootstrap to search * * @return any {@link SslProvider} found or null */ @Nullable public static SslProvider findSslSupport(ServerBootstrap b) { SslSupportConsumer ssl = BootstrapHandlers.findConfiguration(SslSupportConsumer.class, b.config().childHandler()); if (ssl == null) { return null; } return ssl.sslProvider; }
@SuppressWarnings("unchecked") static HttpServerConfiguration getOrCreate(ServerBootstrap b) { HttpServerConfiguration hcc = (HttpServerConfiguration) b.config() .attrs() .get(CONF_KEY); if (hcc == null) { hcc = new HttpServerConfiguration(); b.attr(CONF_KEY, hcc); } return hcc; }
@SuppressWarnings("unchecked") static HttpServerConfiguration getOrCreate(ServerBootstrap b) { HttpServerConfiguration hcc = (HttpServerConfiguration) b.config() .attrs() .get(CONF_KEY); if (hcc == null) { hcc = new HttpServerConfiguration(); b.attr(CONF_KEY, hcc); } return hcc; }
static ServerBootstrap updatePort(ServerBootstrap b, int port) { return b.localAddress(_updatePort(b.config().localAddress(), port)); }
static ServerBootstrap updateHost(ServerBootstrap b, String host) { return b.localAddress(_updateHost(b.config().localAddress(), host)); }
static ServerBootstrap updateHost(ServerBootstrap b, String host) { return b.localAddress(_updateHost(b.config().localAddress(), host)); }