io.netty.util.concurrent.GlobalEventExecutor Java Examples

The following examples show how to use io.netty.util.concurrent.GlobalEventExecutor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FiniteStateMachineTest.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Establish PCEPS TLS connection with peer.
 */
@Test
public void testEstablishTLS() {
    final DefaultPCEPSessionNegotiator negotiator =
        new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE),
            this.channel, this.listener, (short) 1, 20, new OpenBuilder().setKeepalive(Uint8.ONE).build(),
            SslContextFactoryTest.createTlsConfig());
    negotiator.channelActive(null);
    assertEquals(1, this.msgsSend.size());
    assertTrue(this.msgsSend.get(0) instanceof Starttls);
    assertEquals(DefaultPCEPSessionNegotiator.State.START_TLS_WAIT, negotiator.getState());
    negotiator.handleMessage(this.startTlsMsg);
    assertEquals(DefaultPCEPSessionNegotiator.State.OPEN_WAIT, negotiator.getState());
    assertEquals(2, this.msgsSend.size());
    assertTrue(this.msgsSend.get(1) instanceof Open);
    negotiator.handleMessage(this.openMsg);
    assertEquals(DefaultPCEPSessionNegotiator.State.KEEP_WAIT, negotiator.getState());
}
 
Example #2
Source File: PlatformSSLClient.java    From wind-im with Apache License 2.0 6 votes vote down vote up
public void disconnect() {
	// logger.info("close tcp socket, Disconnecting.");
	synchronized (this.clientBoot) {
		this.channelPromise = null;
		final Future<Void> channelCloseFuture;
		if (this.channelPromise != null) {
			channelCloseFuture = this.channelPromise.channel().close();
		} else {
			channelCloseFuture = new SucceededFuture<Void>(GlobalEventExecutor.INSTANCE, null);
		}
		channelCloseFuture.addListener(new GenericFutureListener<Future<Void>>() {
			@Override
			public void operationComplete(final Future<Void> future) throws Exception {
				PlatformSSLClient.this.clientBoot.config().group().shutdownGracefully();
			}
		});
	}
	// logger.info("close netty tcp socket connection");
}
 
Example #3
Source File: EpollSocketChannel.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Override
protected Executor prepareToClose() {
    try {
        // Check isOpen() first as otherwise it will throw a RuntimeException
        // when call getSoLinger() as the fd is not valid anymore.
        if (isOpen() && config().getSoLinger() > 0) {
            // We need to cancel this key of the channel so we may not end up in a eventloop spin
            // because we try to read or write until the actual close happens which may be later due
            // SO_LINGER handling.
            // See https://github.com/netty/netty/issues/4449
            ((EpollEventLoop) eventLoop()).remove(EpollSocketChannel.this);
            return GlobalEventExecutor.INSTANCE;
        }
    } catch (Throwable ignore) {
        // Ignore the error as the underlying channel may be closed in the meantime and so
        // getSoLinger() may produce an exception. In this case we just return null.
        // See https://github.com/netty/netty/issues/4449
    }
    return null;
}
 
Example #4
Source File: ParserToSalTest.java    From bgpcep with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    final String hexMessages = "/bgp_hex.txt";
    final List<byte[]> bgpMessages = HexDumpBGPFileParser
            .parseMessages(ParserToSalTest.class.getResourceAsStream(hexMessages));
    this.mock = new BGPMock(new EventBus("test"), ServiceLoaderBGPExtensionProviderContext
            .getSingletonInstance().getMessageRegistry(), Lists.newArrayList(fixMessages(bgpMessages)));

    Mockito.doReturn(GlobalEventExecutor.INSTANCE.newSucceededFuture(null)).when(this.dispatcher)
            .createReconnectingClient(any(InetSocketAddress.class), any(InetSocketAddress.class),
                    anyInt(), any(KeyMapping.class));

    this.ext1 = new SimpleRIBExtensionProviderContext();
    this.ext2 = new SimpleRIBExtensionProviderContext();
    this.baseact = new RIBActivator();
    this.lsact = new org.opendaylight.protocol.bgp.linkstate.impl.RIBActivator();

    final CurrentAdapterSerializer serializer = mappingService.currentSerializer();
    this.baseact.startRIBExtensionProvider(this.ext1, serializer);
    this.lsact.startRIBExtensionProvider(this.ext2, serializer);
    this.codecsRegistry = new ConstantCodecsRegistry(serializer);
}
 
Example #5
Source File: Http2FrameCodecTest.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 5000)
public void newOutboundStream() {
    final Http2FrameStream stream = frameCodec.newStream();

    assertNotNull(stream);
    assertFalse(isStreamIdValid(stream.id()));

    final Promise<Void> listenerExecuted = new DefaultPromise<Void>(GlobalEventExecutor.INSTANCE);

    channel.writeAndFlush(new DefaultHttp2HeadersFrame(new DefaultHttp2Headers(), false).stream(stream))
           .addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    assertTrue(future.isSuccess());
                    assertTrue(isStreamIdValid(stream.id()));
                    listenerExecuted.setSuccess(null);
                }
            }
    );
    ByteBuf data = Unpooled.buffer().writeZero(100);
    ChannelFuture f = channel.writeAndFlush(new DefaultHttp2DataFrame(data).stream(stream));
    assertTrue(f.isSuccess());

    listenerExecuted.syncUninterruptibly();
    assertTrue(listenerExecuted.isSuccess());
}
 
Example #6
Source File: ThreadPerChannelEventLoopGroupTest.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
@Test
public void testTerminationFutureSuccessReflectively() throws Exception {
    Field terminationFutureField =
            ThreadPerChannelEventLoopGroup.class.getDeclaredField("terminationFuture");
    terminationFutureField.setAccessible(true);
    final Exception[] exceptionHolder = new Exception[1];
    for (int i = 0; i < 2; i++) {
        ThreadPerChannelEventLoopGroup loopGroup = new ThreadPerChannelEventLoopGroup(64);
        Promise<?> promise = new DefaultPromise<Void>(GlobalEventExecutor.INSTANCE) {
            @Override
            public Promise<Void> setSuccess(Void result) {
                try {
                    return super.setSuccess(result);
                } catch (IllegalStateException e) {
                    exceptionHolder[0] = e;
                    throw e;
                }
            }
        };
        terminationFutureField.set(loopGroup, promise);
        runTest(loopGroup);
    }
    // The global event executor will not terminate, but this will give the test a chance to fail.
    GlobalEventExecutor.INSTANCE.awaitTermination(100, TimeUnit.MILLISECONDS);
    assertNull(exceptionHolder[0]);
}
 
Example #7
Source File: NettyClient2.java    From wind-im with Apache License 2.0 6 votes vote down vote up
public void disconnect() {
	// logger.info("close tcp socket, Disconnecting.");
	synchronized (this.clientBoot) {
		this.channelPromise = null;
		final Future<Void> channelCloseFuture;
		if (this.channelPromise != null) {
			channelCloseFuture = this.channelPromise.channel().close();
		} else {
			channelCloseFuture = new SucceededFuture<Void>(GlobalEventExecutor.INSTANCE, null);
		}
		channelCloseFuture.addListener(new GenericFutureListener<Future<Void>>() {
			@Override
			public void operationComplete(final Future<Void> future) throws Exception {
				NettyClient2.this.clientBoot.config().group().shutdownGracefully();
			}
		});
	}
	// logger.info("close netty tcp socket connection");
}
 
Example #8
Source File: NettyClient2.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public void disconnect() {
	// logger.info("close tcp socket, Disconnecting.");
	synchronized (this.clientBoot) {
		this.channelPromise = null;
		final Future<Void> channelCloseFuture;
		if (this.channelPromise != null) {
			channelCloseFuture = this.channelPromise.channel().close();
		} else {
			channelCloseFuture = new SucceededFuture<Void>(GlobalEventExecutor.INSTANCE, null);
		}
		channelCloseFuture.addListener(new GenericFutureListener<Future<Void>>() {
			@Override
			public void operationComplete(final Future<Void> future) throws Exception {
				NettyClient2.this.clientBoot.config().group().shutdownGracefully();
			}
		});
	}
	// logger.info("close netty tcp socket connection");
}
 
Example #9
Source File: PlatformSSLClient.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public void disconnect() {
	// logger.info("close tcp socket, Disconnecting.");
	synchronized (this.clientBoot) {
		this.channelPromise = null;
		final Future<Void> channelCloseFuture;
		if (this.channelPromise != null) {
			channelCloseFuture = this.channelPromise.channel().close();
		} else {
			channelCloseFuture = new SucceededFuture<Void>(GlobalEventExecutor.INSTANCE, null);
		}
		channelCloseFuture.addListener(new GenericFutureListener<Future<Void>>() {
			@Override
			public void operationComplete(final Future<Void> future) throws Exception {
				PlatformSSLClient.this.clientBoot.config().group().shutdownGracefully();
			}
		});
	}
	// logger.info("close netty tcp socket connection");
}
 
Example #10
Source File: NettyClient2.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public void disconnect() {
	// logger.info("close tcp socket, Disconnecting.");
	synchronized (this.clientBoot) {
		this.channelPromise = null;
		final Future<Void> channelCloseFuture;
		if (this.channelPromise != null) {
			channelCloseFuture = this.channelPromise.channel().close();
		} else {
			channelCloseFuture = new SucceededFuture<Void>(GlobalEventExecutor.INSTANCE, null);
		}
		channelCloseFuture.addListener(new GenericFutureListener<Future<Void>>() {
			@Override
			public void operationComplete(final Future<Void> future) throws Exception {
				NettyClient2.this.clientBoot.config().group().shutdownGracefully();
			}
		});
	}
	// logger.info("close netty tcp socket connection");
}
 
Example #11
Source File: PlatformSSLClient.java    From openzaly with Apache License 2.0 6 votes vote down vote up
public void disconnect() {
	// logger.info("close tcp socket, Disconnecting.");
	synchronized (this.clientBoot) {
		this.channelPromise = null;
		final Future<Void> channelCloseFuture;
		if (this.channelPromise != null) {
			channelCloseFuture = this.channelPromise.channel().close();
		} else {
			channelCloseFuture = new SucceededFuture<Void>(GlobalEventExecutor.INSTANCE, null);
		}
		channelCloseFuture.addListener(new GenericFutureListener<Future<Void>>() {
			@Override
			public void operationComplete(final Future<Void> future) throws Exception {
				PlatformSSLClient.this.clientBoot.config().group().shutdownGracefully();
			}
		});
	}
	// logger.info("close netty tcp socket connection");
}
 
Example #12
Source File: NettyIoAcceptor.java    From termd with Apache License 2.0 6 votes vote down vote up
public NettyIoAcceptor(NettyIoServiceFactory factory, final IoHandler handler) {
  this.factory = factory;
  this.handler = handler;
  channelGroup = new DefaultChannelGroup("sshd-acceptor-channels", GlobalEventExecutor.INSTANCE);
  bootstrap.group(factory.eventLoopGroup)
      .channel(NioServerSocketChannel.class)
      .option(ChannelOption.SO_BACKLOG, 100)
      .handler(new LoggingHandler(LogLevel.INFO))
      .childHandler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
          ChannelPipeline p = ch.pipeline();
          p.addLast(new NettyIoSession(NettyIoAcceptor.this, handler).adapter);
        }
      });
}
 
Example #13
Source File: NettyServer.java    From Kepler with GNU Lesser General Public License v3.0 6 votes vote down vote up
public NettyServer(String ip, int port) {
    this.ip = ip;
    this.port = port;
    this.channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
    this.bootstrap = new ServerBootstrap();
    this.connectionIds = new AtomicInteger(0);
    this.connectionVersionRuleMap = new HashMap<>();

    for (int i = 0; i < 30; i++) {
        String key = "v" + i + ".version.port";

        if (ServerConfiguration.exists(key)) {
            int portNumber = ServerConfiguration.getInteger(key);

            if (portNumber > 0) {
                this.connectionVersionRuleMap.put(portNumber, new ConnectionVersionRule(portNumber, i));
            }
        }
    }
}
 
Example #14
Source File: NettyClient.java    From krpc with Apache License 2.0 6 votes vote down vote up
public void close() {

        if (workerGroup != null) {

            log.info("stopping netty client");

            timer.stop();
            timer = null;

            ChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
            for (Object ch : conns.values()) {
                if (ch != null && ch != dummyChannel)
                    allChannels.add((Channel) ch);
            }
            ChannelGroupFuture future = allChannels.close();
            future.awaitUninterruptibly();

            workerGroup.shutdownGracefully();
            workerGroup = null;

            log.info("netty client stopped");
        }
    }
 
Example #15
Source File: BoundNode.java    From simulacron with Apache License 2.0 6 votes vote down vote up
@Override
public CompletionStage<NodeConnectionReport> closeConnectionAsync(
    SocketAddress connection, CloseType type) {
  Optional<Channel> channel =
      this.clientChannelGroup
          .stream()
          .filter(c -> c.remoteAddress().equals(connection))
          .findFirst();

  if (channel.isPresent()) {
    ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
    channelGroup.add(channel.get());
    ClusterConnectionReport clusterReport = new ClusterConnectionReport(getCluster().getId());
    NodeConnectionReport report =
        clusterReport.addNode(this, Collections.singletonList(connection), getAddress());

    return closeChannelGroup(channelGroup, type).thenApply(f -> report);
  } else {
    CompletableFuture<NodeConnectionReport> failedFuture = new CompletableFuture<>();
    failedFuture.completeExceptionally(new IllegalArgumentException("Not found"));
    return failedFuture;
  }
}
 
Example #16
Source File: NettyIoAcceptor.java    From termd with Apache License 2.0 6 votes vote down vote up
public NettyIoAcceptor(NettyIoServiceFactory factory, IoHandler handler) {
  this.factory = factory;
  this.handler = handler;
  channelGroup = new DefaultChannelGroup("sshd-acceptor-channels", GlobalEventExecutor.INSTANCE);;
  bootstrap.group(factory.eventLoopGroup)
      .channel(NioServerSocketChannel.class)
      .option(ChannelOption.SO_BACKLOG, 100)
      .handler(new LoggingHandler(LogLevel.INFO))
      .childHandler(new ChannelInitializer<SocketChannel>() {
        @Override
        public void initChannel(SocketChannel ch) throws Exception {
          ChannelPipeline p = ch.pipeline();
          p.addLast(new NettyIoSession(NettyIoAcceptor.this, handler).adapter);
        }
      });
}
 
Example #17
Source File: NettyIoAcceptor.java    From aesh-readline with Apache License 2.0 6 votes vote down vote up
public NettyIoAcceptor(NettyIoServiceFactory factory, IoHandler handler) {
    this.factory = factory;
    this.handler = handler;
    channelGroup = new DefaultChannelGroup("sshd-acceptor-channels", GlobalEventExecutor.INSTANCE);;
    bootstrap.group(factory.eventLoopGroup)
            .channel(NioServerSocketChannel.class)
            .option(ChannelOption.SO_BACKLOG, 100)
            .handler(new LoggingHandler(LogLevel.INFO))
            .childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline p = ch.pipeline();
                    p.addLast(new NettyIoSession(NettyIoAcceptor.this, handler).adapter);
                }
            });
}
 
Example #18
Source File: HttpServerTests.java    From reactor-netty with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testTcpConfiguration_2() throws Exception {
	CountDownLatch latch = new CountDownLatch(10);
	LoopResources loop = LoopResources.create("testTcpConfiguration");
	ChannelGroup group = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
	doTestTcpConfiguration(
			HttpServer.from(configureTcpServer(TcpServer.create(), loop, group, latch)),
			HttpClient.from(configureTcpClient(TcpClient.create(), loop, group, latch))
	);

	assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();

	FutureMono.from(group.close())
	          .then(loop.disposeLater())
	          .block(Duration.ofSeconds(30));
}
 
Example #19
Source File: HttpServerTests.java    From reactor-netty with Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testTcpConfiguration_1() throws Exception {
	CountDownLatch latch = new CountDownLatch(10);
	LoopResources loop = LoopResources.create("testTcpConfiguration");
	ChannelGroup group = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
	doTestTcpConfiguration(
			HttpServer.create().tcpConfiguration(tcp -> configureTcpServer(tcp, loop, group, latch)),
			HttpClient.create().tcpConfiguration(tcp -> configureTcpClient(tcp, loop, group, latch))
	);

	assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();

	FutureMono.from(group.close())
	          .then(loop.disposeLater())
	          .block(Duration.ofSeconds(30));
}
 
Example #20
Source File: PreBuiltTransportClient.java    From sql4es with Apache License 2.0 6 votes vote down vote up
public void close() {
    super.close();
    if (!NetworkModule.TRANSPORT_TYPE_SETTING.exists(this.settings) || ((String)NetworkModule.TRANSPORT_TYPE_SETTING.get(this.settings)).equals("netty4")) {
        try {
            GlobalEventExecutor.INSTANCE.awaitInactivity(5L, TimeUnit.SECONDS);
        } catch (InterruptedException var3) {
            Thread.currentThread().interrupt();
        }

        try {
            ThreadDeathWatcher.awaitInactivity(5L, TimeUnit.SECONDS);
        } catch (InterruptedException var2) {
            Thread.currentThread().interrupt();
        }
    }

}
 
Example #21
Source File: BetterFixedChannelPool.java    From aws-sdk-java-v2 with Apache License 2.0 6 votes vote down vote up
private void close0() {
    if (!closed) {
        closed = true;
        for (;;) {
            AcquireTask task = pendingAcquireQueue.poll();
            if (task == null) {
                break;
            }
            ScheduledFuture<?> f = task.timeoutFuture;
            if (f != null) {
                f.cancel(false);
            }
            task.promise.setFailure(new ClosedChannelException());
        }
        acquiredChannelCount = 0;
        pendingAcquireCount = 0;

        // Ensure we dispatch this on another Thread as close0 will be called from the EventExecutor and we need
        // to ensure we will not block in a EventExecutor.
        GlobalEventExecutor.INSTANCE.execute(() -> delegateChannelPool.close());
    }
}
 
Example #22
Source File: ProxyConnectorFactory.java    From styx with Apache License 2.0 6 votes vote down vote up
private ProxyConnector(ConnectorConfig config, ProxyConnectorFactory factory) {
    this.config = requireNonNull(config);
    this.responseEnhancer = requireNonNull(factory.responseEnhancer);
    this.serverConfig = requireNonNull(factory.serverConfig);
    this.metrics = requireNonNull(factory.metrics);
    this.httpErrorStatusListener = requireNonNull(factory.errorStatusListener);
    this.channelStatsHandler = new ChannelStatisticsHandler(metrics);
    this.requestStatsCollector = new RequestStatsCollector(metrics.scope("requests"));
    this.excessConnectionRejector = new ExcessConnectionRejector(new DefaultChannelGroup(GlobalEventExecutor.INSTANCE), serverConfig.maxConnectionsCount());
    this.unwiseCharEncoder = new ConfigurableUnwiseCharsEncoder(factory.unwiseCharacters);
    if (isHttps()) {
        this.sslContext = Optional.of(newSSLContext((HttpsConnectorConfig) config, metrics));
    } else {
        this.sslContext = Optional.empty();
    }
    this.requestTracker = factory.requestTracking ? CurrentRequestTracker.INSTANCE : RequestTracker.NO_OP;
    this.httpMessageFormatter = factory.httpMessageFormatter;
    this.originsHeader = factory.originsHeader;
}
 
Example #23
Source File: RntbdClientChannelPool.java    From azure-cosmosdb-java with MIT License 6 votes vote down vote up
private void close0() {

        checkState(this.executor.inEventLoop());

        this.idleStateDetectionScheduledFuture.cancel(false);
        this.acquiredChannelCount.set(0);
        this.availableChannelCount.set(0);

        for (; ; ) {
            final AcquireTask task = this.pendingAcquisitionQueue.poll();
            if (task == null) {
                break;
            }
            final ScheduledFuture<?> timeoutFuture = task.timeoutFuture;
            if (timeoutFuture != null) {
                timeoutFuture.cancel(false);
            }
            task.promise.setFailure(new ClosedChannelException());
        }

        // Ensure we dispatch this on another Thread as close0 will be called from the EventExecutor and we need
        // to ensure we will not block in an EventExecutor

        GlobalEventExecutor.INSTANCE.execute(RntbdClientChannelPool.super::close);
    }
 
Example #24
Source File: CatNettyClient.java    From krpc with Apache License 2.0 6 votes vote down vote up
public void close() {

        if (workerGroup != null) {

            log.info("cat stopping netty client");

            timer.cancel();
            timer = null;

            ChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
            for (Object ch : conns.values()) {
                if (ch != null && ch != dummyChannel)
                    allChannels.add((Channel) ch);
            }
            ChannelGroupFuture future = allChannels.close();
            future.awaitUninterruptibly();

            workerGroup.shutdownGracefully();
            workerGroup = null;

            log.info("cat netty client stopped");
        }
    }
 
Example #25
Source File: SelfCheckHttpServer.java    From krpc with Apache License 2.0 6 votes vote down vote up
public void close() {

        if (workerGroup != null) {

            log.info("stopping selfcheck server");

            bossGroup.shutdownGracefully();
            bossGroup = null;

            ChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
            allChannels.add(serverChannel);
            for (Channel ch : conns.values()) {
                allChannels.add(ch);
            }
            ChannelGroupFuture future = allChannels.close();
            future.awaitUninterruptibly();

            workerGroup.shutdownGracefully();
            workerGroup = null;

            log.info("selfcheck server stopped");
        }
    }
 
Example #26
Source File: NettyHttpServer.java    From krpc with Apache License 2.0 6 votes vote down vote up
public void close() {

        if (workerGroup != null) {

            log.info("stopping netty server");

            bossGroup.shutdownGracefully();
            bossGroup = null;

            ChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
            allChannels.add(serverChannel);
            for (Channel ch : conns.values()) {
                allChannels.add(ch);
            }
            ChannelGroupFuture future = allChannels.close();
            future.awaitUninterruptibly();

            workerGroup.shutdownGracefully();
            workerGroup = null;

            log.info("netty server stopped");
        }
    }
 
Example #27
Source File: ServerGroups.java    From serve with Apache License 2.0 5 votes vote down vote up
public final void init() {
    allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);

    serverGroup = Connector.newEventLoopGroup(2);
    childGroup = Connector.newEventLoopGroup(configManager.getNettyThreads());
    backendGroup = Connector.newEventLoopGroup(configManager.getNettyClientThreads());
}
 
Example #28
Source File: NioSocketChannel.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
protected Executor closeExecutor() {
    if (javaChannel().isOpen() && config().getSoLinger() > 0) {
        return GlobalEventExecutor.INSTANCE;
    }
    return null;
}
 
Example #29
Source File: BGPProtocolSessionPromise.java    From bgpcep with Eclipse Public License 1.0 5 votes vote down vote up
public BGPProtocolSessionPromise(final @NonNull InetSocketAddress remoteAddress, final int retryTimer,
        final @NonNull Bootstrap bootstrap, final @NonNull BGPPeerRegistry peerRegistry) {
    super(GlobalEventExecutor.INSTANCE);
    this.address = requireNonNull(remoteAddress);
    this.retryTimer = retryTimer;
    this.bootstrap = requireNonNull(bootstrap);
    this.listenerRegistration = requireNonNull(peerRegistry).registerPeerSessionListener(
            new PeerRegistrySessionListenerImpl(StrictBGPPeerRegistry.getIpAddress(this.address)));
}
 
Example #30
Source File: UndertowContainerProvider.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
static ServerWebSocketContainer getDefaultContainer() {
    if (defaultContainerDisabled) {
        return null;
    }
    if (defaultContainer != null) {
        return defaultContainer;
    }
    synchronized (UndertowContainerProvider.class) {
        if (defaultContainer == null) {
            //this is not great, as we have no way to control the lifecycle
            //but there is not much we can do
            Supplier<EventLoopGroup> supplier = new Supplier<EventLoopGroup>() {

                @Override
                public EventLoopGroup get() {
                    return getDefaultEventLoopGroup();
                }
            };
            defaultContainer = new ServerWebSocketContainer(defaultIntrospector, UndertowContainerProvider.class.getClassLoader(), supplier, Collections.EMPTY_LIST, !invokeInIoThread, new Supplier<Executor>() {
                @Override
                public Executor get() {
                    return GlobalEventExecutor.INSTANCE;
                }
            });
        }
        return defaultContainer;
    }
}