List of usage examples for io.netty.channel.nio NioEventLoopGroup isShutdown
@Override public boolean isShutdown()
From source file:com.linkedin.r2.transport.http.client.TestHttpClientFactory.java
License:Apache License
@Test(dataProvider = "configs") public void testShutdownNoTimeout(boolean restOverStream, String protocolVersion) throws Exception { NioEventLoopGroup eventLoop = new NioEventLoopGroup(); ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); HttpClientFactory factory = getHttpClientFactory(eventLoop, true, scheduler, true); Server server = new HttpServerBuilder().build(); try {//from w w w.j av a 2 s . c o m server.start(); List<Client> clients = new ArrayList<Client>(); for (int i = 0; i < 100; i++) { HashMap<String, String> properties = new HashMap<>(); properties.put(HttpClientFactory.HTTP_PROTOCOL_VERSION, protocolVersion); clients.add(new TransportClientAdapter(factory.getClient(properties), restOverStream)); } for (Client c : clients) { RestRequest r = new RestRequestBuilder(new URI(URI)).build(); c.restRequest(r).get(30, TimeUnit.SECONDS); } } finally { server.stop(); } FutureCallback<None> factoryShutdown = new FutureCallback<None>(); factory.shutdown(factoryShutdown); try { factoryShutdown.get(1, TimeUnit.SECONDS); Assert.fail("Factory shutdown should have timed out"); } catch (TimeoutException e) { // Expected } Assert.assertFalse(eventLoop.isShutdown(), "Boss should not be shut down"); Assert.assertFalse(scheduler.isShutdown(), "Scheduler should not be shut down"); }
From source file:com.relayrides.pushy.apns.PushManagerTest.java
License:Open Source License
@Test public void testShutdown() throws Exception { {//from w w w . j a va2 s. c om final PushManager<ApnsPushNotification> defaultGroupPushManager = new PushManager<ApnsPushNotification>( TEST_ENVIRONMENT, SSLTestUtil.createSSLContextForTestClient(), 1, null, null, null, ApnsConnection.DEFAULT_SENT_NOTIFICATION_BUFFER_CAPACITY); defaultGroupPushManager.start(); defaultGroupPushManager.shutdown(); assertTrue(defaultGroupPushManager.isShutDown()); } { final NioEventLoopGroup group = new NioEventLoopGroup(1); final PushManager<ApnsPushNotification> providedGroupPushManager = new PushManager<ApnsPushNotification>( TEST_ENVIRONMENT, SSLTestUtil.createSSLContextForTestClient(), 1, group, null, null, ApnsConnection.DEFAULT_SENT_NOTIFICATION_BUFFER_CAPACITY); providedGroupPushManager.start(); providedGroupPushManager.shutdown(); assertTrue(providedGroupPushManager.isShutDown()); assertFalse(group.isShutdown()); group.shutdownGracefully(); } { final ExecutorService listenerExecutorService = Executors.newSingleThreadExecutor(); final PushManager<ApnsPushNotification> providedExecutorServicePushManager = new PushManager<ApnsPushNotification>( TEST_ENVIRONMENT, SSLTestUtil.createSSLContextForTestClient(), 1, null, listenerExecutorService, null, ApnsConnection.DEFAULT_SENT_NOTIFICATION_BUFFER_CAPACITY); providedExecutorServicePushManager.start(); providedExecutorServicePushManager.shutdown(); assertTrue(providedExecutorServicePushManager.isShutDown()); assertFalse(listenerExecutorService.isShutdown()); listenerExecutorService.shutdown(); } }
From source file:com.turo.pushy.apns.MockApnsServerTest.java
License:Open Source License
@Test public void testShutdownWithProvidedEventLoopGroup() throws Exception { final NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup(1); try {// ww w . jav a 2 s . com final MockApnsServer providedGroupServer = new MockApnsServerBuilder() .setServerCredentials( MockApnsServerTest.class.getResourceAsStream(SERVER_CERTIFICATES_FILENAME), MockApnsServerTest.class.getResourceAsStream(SERVER_KEY_FILENAME), null) .setEventLoopGroup(eventLoopGroup).build(); assertTrue(providedGroupServer.start(PORT).await().isSuccess()); assertTrue(providedGroupServer.shutdown().await().isSuccess()); assertFalse(eventLoopGroup.isShutdown()); } finally { eventLoopGroup.shutdownGracefully(); } }
From source file:com.turo.pushy.apns.server.MockApnsServerTest.java
License:Open Source License
@Test public void testShutdownWithProvidedEventLoopGroup() throws Exception { final NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup(1); try {//from ww w .j av a 2 s. co m final MockApnsServer providedGroupServer = new MockApnsServerBuilder() .setServerCredentials(getClass().getResourceAsStream(SERVER_CERTIFICATES_FILENAME), getClass().getResourceAsStream(SERVER_KEY_FILENAME), null) .setHandlerFactory(new AcceptAllPushNotificationHandlerFactory()) .setEventLoopGroup(eventLoopGroup).build(); assertTrue(providedGroupServer.start(PORT).await().isSuccess()); assertTrue(providedGroupServer.shutdown().await().isSuccess()); assertFalse(eventLoopGroup.isShutdown()); } finally { eventLoopGroup.shutdownGracefully().await(); } }