use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project wildfly-swarm by wildfly-swarm.
the class Server method stop.
public final synchronized void stop() throws ServerLifecycleException, IllegalStateException, InterruptedException {
// Use an anonymous logger because the JUL LogManager will not log after process shutdown has been received
final Logger log = Logger.getAnonymousLogger();
log.addHandler(new Handler() {
@Override
public void publish(final LogRecord record) {
System.out.println(PREFIX + record.getMessage());
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
private final String PREFIX = "[" + Server.class.getSimpleName() + "] ";
});
if (!this.isRunning()) {
throw new IllegalStateException("Server is not running");
}
if (log.isLoggable(Level.INFO)) {
log.info("Requesting shutdown...");
}
this.eventLoopGroups.forEach(EventLoopGroup::shutdownGracefully);
this.eventLoopGroups.clear();
shutdownService.shutdown();
if (!shutdownService.awaitTermination(2, TimeUnit.MINUTES)) {
log.warning("Unable to shutdown the server process cleanly.");
}
// Kill the shutdown service
shutdownService.shutdownNow();
shutdownService = null;
// Not running
running = false;
if (log.isLoggable(Level.INFO)) {
log.info("Server shutdown.");
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project reactor-netty by reactor.
the class TcpResourcesTest method before.
@Before
public void before() {
loopDisposed = new AtomicBoolean();
poolDisposed = new AtomicBoolean();
loopResources = new LoopResources() {
@Override
public EventLoopGroup onServer(boolean useNative) {
return null;
}
@Override
public Mono<Void> disposeLater() {
return Mono.<Void>empty().doOnSuccess(c -> loopDisposed.set(true));
}
@Override
public boolean isDisposed() {
return loopDisposed.get();
}
};
poolResources = new PoolResources() {
@Override
public ChannelPool selectOrCreate(SocketAddress address, Supplier<? extends Bootstrap> bootstrap, Consumer<? super Channel> onChannelCreate, EventLoopGroup group) {
return null;
}
public Mono<Void> disposeLater() {
return Mono.<Void>empty().doOnSuccess(c -> poolDisposed.set(true));
}
@Override
public boolean isDisposed() {
return poolDisposed.get();
}
};
tcpResources = new TcpResources(loopResources, poolResources);
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project reactor-netty by reactor.
the class DefaultLoopResources method disposeLater.
@Override
public Mono<Void> disposeLater() {
return Mono.defer(() -> {
EventLoopGroup cacheNativeClientGroup = cacheNativeClientLoops.get();
EventLoopGroup cacheNativeSelectGroup = cacheNativeSelectLoops.get();
EventLoopGroup cacheNativeServerGroup = cacheNativeServerLoops.get();
if (running.compareAndSet(true, false)) {
clientLoops.shutdownGracefully();
serverSelectLoops.shutdownGracefully();
serverLoops.shutdownGracefully();
if (cacheNativeClientGroup != null) {
cacheNativeClientGroup.shutdownGracefully();
}
if (cacheNativeSelectGroup != null) {
cacheNativeSelectGroup.shutdownGracefully();
}
if (cacheNativeServerGroup != null) {
cacheNativeServerGroup.shutdownGracefully();
}
}
Mono<?> clMono = FutureMono.from((Future) clientLoops.terminationFuture());
Mono<?> sslMono = FutureMono.from((Future) serverSelectLoops.terminationFuture());
Mono<?> slMono = FutureMono.from((Future) serverLoops.terminationFuture());
Mono<?> cnclMono = Mono.empty();
if (cacheNativeClientGroup != null) {
cnclMono = FutureMono.from((Future) cacheNativeClientGroup.terminationFuture());
}
Mono<?> cnslMono = Mono.empty();
if (cacheNativeSelectGroup != null) {
cnslMono = FutureMono.from((Future) cacheNativeSelectGroup.terminationFuture());
}
Mono<?> cnsrvlMono = Mono.empty();
if (cacheNativeServerGroup != null) {
cnsrvlMono = FutureMono.from((Future) cacheNativeServerGroup.terminationFuture());
}
return Mono.when(clMono, sslMono, slMono, cnclMono, cnslMono, cnsrvlMono);
});
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project reactor-netty by reactor.
the class DefaultLoopResources method cacheNativeSelectLoops.
EventLoopGroup cacheNativeSelectLoops() {
if (cacheNativeSelectLoops == cacheNativeServerLoops) {
return cacheNativeServerLoops();
}
EventLoopGroup eventLoopGroup = cacheNativeSelectLoops.get();
if (null == eventLoopGroup) {
DefaultLoop defaultLoop = DefaultLoopNativeDetector.getInstance();
EventLoopGroup newEventLoopGroup = defaultLoop.newEventLoopGroup(selectCount, threadFactory(this, "select-" + defaultLoop.getName()));
if (!cacheNativeSelectLoops.compareAndSet(null, newEventLoopGroup)) {
newEventLoopGroup.shutdownGracefully();
}
eventLoopGroup = cacheNativeSelectLoops();
}
return eventLoopGroup;
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project reactor-netty by reactor.
the class DefaultLoopResources method cacheNativeServerLoops.
EventLoopGroup cacheNativeServerLoops() {
EventLoopGroup eventLoopGroup = cacheNativeServerLoops.get();
if (null == eventLoopGroup) {
DefaultLoop defaultLoop = DefaultLoopNativeDetector.getInstance();
EventLoopGroup newEventLoopGroup = defaultLoop.newEventLoopGroup(workerCount, threadFactory(this, "server-" + defaultLoop.getName()));
if (!cacheNativeServerLoops.compareAndSet(null, newEventLoopGroup)) {
newEventLoopGroup.shutdownGracefully();
}
eventLoopGroup = cacheNativeServerLoops();
}
return eventLoopGroup;
}
Aggregations