本文整理了Java中io.netty.channel.nio.NioEventLoopGroup.shutdownGracefully()
方法的一些代码示例,展示了NioEventLoopGroup.shutdownGracefully()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NioEventLoopGroup.shutdownGracefully()
方法的具体详情如下:
包路径:io.netty.channel.nio.NioEventLoopGroup
类名称:NioEventLoopGroup
方法名:shutdownGracefully
暂无
代码示例来源:origin: ffay/lanproxy
@Override
public void stop() {
serverBossGroup.shutdownGracefully();
serverWorkerGroup.shutdownGracefully();
}
代码示例来源:origin: ffay/lanproxy
@Override
public void stop() {
serverBossGroup.shutdownGracefully();
serverWorkerGroup.shutdownGracefully();
}
代码示例来源:origin: ffay/lanproxy
@Override
public void stop() {
workerGroup.shutdownGracefully();
}
代码示例来源:origin: apache/rocketmq-externals
public void shutdown() {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
代码示例来源:origin: alibaba/Sentinel
private void cleanUp() {
if (channel != null) {
channel.close();
channel = null;
}
if (eventLoopGroup != null) {
eventLoopGroup.shutdownGracefully();
}
}
代码示例来源:origin: codingapi/tx-lcn
@Override
public void destroy() throws Exception {
if (workerGroup != null) {
workerGroup.shutdownGracefully();
}
if (bossGroup != null) {
bossGroup.shutdownGracefully();
}
log.info("server was down.");
}
代码示例来源:origin: Graylog2/graylog2-server
public void stop() {
LOG.debug("Attempting to stop DNS client");
if (nettyEventLoop == null) {
LOG.error("DNS resolution event loop not initialized");
return;
}
// Shutdown event loop (required by Netty).
final Future<?> shutdownFuture = nettyEventLoop.shutdownGracefully();
shutdownFuture.addListener(future -> LOG.debug("DNS client shutdown successful"));
}
代码示例来源:origin: jamesdbloom/mockserver
public void stop() {
scheduler.shutdown();
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
eventLoopGroup.shutdownGracefully(0, 1, TimeUnit.MILLISECONDS);
}
代码示例来源:origin: alibaba/Sentinel
@Override
public void stop() {
// If still initializing, wait for ready.
while (currentState.get() == SERVER_STATUS_STARTING) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// Ignore.
}
}
if (currentState.compareAndSet(SERVER_STATUS_STARTED, SERVER_STATUS_OFF)) {
try {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
connectionPool.shutdownAll();
failedTimes.set(0);
RecordLog.info("[NettyTransportServer] Sentinel token server stopped");
} catch (Exception ex) {
RecordLog.warn("[NettyTransportServer] Failed to stop token server (port=" + port + ")", ex);
}
}
}
代码示例来源:origin: blynkkk/blynk-server
public void start(BufferedReader commandInputStream) {
this.nioEventLoopGroup = new NioEventLoopGroup(1);
try {
Bootstrap b = new Bootstrap();
b.group(nioEventLoopGroup)
.channel(NioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true)
.handler(getChannelInitializer());
// Start the connection attempt.
this.channel = b.connect(host, port).sync().channel();
readUserInput(commandInputStream);
} catch (UnresolvedAddressException uae) {
log.error("Host name '{}' is invalid. Please make sure it is correct name.", host);
} catch (ConnectTimeoutException cte) {
log.error("Timeout exceeded when connecting to '{}:{}'. "
+ "Please make sure host available and port is open on target host.", host, port);
} catch (IOException | InterruptedException e) {
log.error("Error running client. Shutting down.", e);
} catch (Exception e) {
log.error(e);
} finally {
// The connection is closed automatically on shutdown.
nioEventLoopGroup.shutdownGracefully();
}
}
代码示例来源:origin: blynkkk/blynk-server
public ChannelFuture stop() {
if (nioEventLoopGroup.isTerminated()) {
return channel.voidPromise();
}
ChannelFuture channelFuture = channel.close().awaitUninterruptibly();
nioEventLoopGroup.shutdownGracefully();
return channelFuture;
}
}
代码示例来源:origin: normanmaurer/netty-in-action
f.channel().closeFuture().sync();
} finally {
group.shutdownGracefully().sync();
代码示例来源:origin: apache/hive
private synchronized void shutdown(Throwable error) {
if (running) {
if (error == null) {
LOG.info("Shutting down Spark Remote Driver.");
} else {
LOG.error("Shutting down Spark Remote Driver due to error: " + error, error);
}
running = false;
for (JobWrapper<?> job : activeJobs.values()) {
cancelJob(job);
}
if (error != null) {
try {
protocol.sendError(error).get(futureTimeout, TimeUnit.MILLISECONDS);
} catch(InterruptedException|ExecutionException|TimeoutException e) {
LOG.warn("Failed to send out the error during RemoteDriver shutdown", e);
}
}
if (jc != null) {
jc.stop();
}
clientRpc.close();
egroup.shutdownGracefully();
synchronized (shutdownLock) {
shutdownLock.notifyAll();
}
}
}
代码示例来源:origin: ethereum/ethereumj
group.shutdownGracefully().sync();
代码示例来源:origin: relayrides/pushy
@TearDown
public void tearDown() throws Exception {
this.client.close().await();
this.server.shutdown().await();
final Future<?> clientShutdownFuture = this.clientEventLoopGroup.shutdownGracefully();
final Future<?> serverShutdownFuture = this.serverEventLoopGroup.shutdownGracefully();
clientShutdownFuture.await();
serverShutdownFuture.await();
}
代码示例来源:origin: micronaut-projects/micronaut-core
private void stopInternal() {
try {
workerGroup.shutdownGracefully()
.addListener(this::logShutdownErrorIfNecessary);
parentGroup.shutdownGracefully()
.addListener(this::logShutdownErrorIfNecessary);
webSocketSessions.close();
applicationContext.publishEvent(new ServerShutdownEvent(this));
if (serviceInstance != null) {
applicationContext.publishEvent(new ServiceShutdownEvent(serviceInstance));
}
if (applicationContext.isRunning()) {
applicationContext.stop();
}
} catch (Throwable e) {
if (LOG.isErrorEnabled()) {
LOG.error("Error stopping Micronaut server: " + e.getMessage(), e);
}
}
}
代码示例来源:origin: mpusher/mpush
@Override
protected void doStop(Listener listener) throws Throwable {
if (workerGroup != null) workerGroup.shutdownGracefully();
ServiceDiscoveryFactory.create().syncStop();
CacheManagerFactory.create().destroy();
listener.onSuccess();
}
代码示例来源:origin: wisdom-projects/holer
@Override
public void stop()
{
workerGroup.shutdownGracefully();
}
代码示例来源:origin: org.jboss.errai/errai-bus
@Override
public void run() {
try {
webSocketHandler.stop();
channelFuture.channel().close();
log.info("web socket server stopped.");
}
catch (Exception e) {
throw new RuntimeException(e);
}
finally {
bossGroup.shutdownGracefully();
workerGroup.shutdownGracefully();
}
}
});
代码示例来源:origin: linkedin/flashback
/**
* Stop proxy server
* */
public void stop() {
ChannelGroupFuture future = _allChannels.close().awaitUninterruptibly();
if (!future.isSuccess()) {
final Iterator<ChannelFuture> iter = future.iterator();
while (iter.hasNext()) {
final ChannelFuture cf = iter.next();
if (!cf.isSuccess()) {
LOG.warn(String.format("Failed to close channel %s because %s", cf.channel(), cf.cause()));
}
}
}
_acceptorGroup.shutdownGracefully();
_upstreamWorkerGroup.shutdownGracefully();
_downstreamWorkerGroup.shutdownGracefully();
}
内容来源于网络,如有侵权,请联系作者删除!