@Override public void close() { try { connectionManager.destroy(); clientTransport.shutdownNow(); final ExecutorService service = clientConfig.executorService(); if (service != null) { service.shutdown(); } if (timeoutExecutor != null) { timeoutExecutor.stop(); timeoutExecutor.getThreadPool().shutdownNow(); } } catch (IOException ignored) { } }
@Override protected void destroyInstance(final TCPNIOTransport instance) { try { instance.shutdownNow(); } catch (final IOException e) { DEBUG_LOG.log(Level.WARNING, "An error occurred while shutting down the Grizzly transport", e.getMessage()); } }
private void closeTransport(TCPNIOTransport transport) { if (transport != null) { try { transport.shutdownNow(); } catch (IOException e) { Logger.getLogger(GrizzlyClientSocket.class.getName()) .log(Level.INFO, "Exception thrown when closing Grizzly transport: " + e.getMessage(), e); } } }
private void closeTransport(TCPNIOTransport transport) { if (transport != null) { try { transport.shutdownNow(); } catch (IOException e) { Logger.getLogger(GrizzlyClientSocket.class.getName()) .log(Level.INFO, "Exception thrown when closing Grizzly transport: " + e.getMessage(), e); } } }
static void closeSharedTransport() { synchronized (TRANSPORT_LOCK) { if (transport != null) { try { Logger.getLogger(GrizzlyClientSocket.class.getName()).log(Level.FINE, "Stopping shared container."); transport.shutdownNow(); } catch (IOException e) { Logger.getLogger(GrizzlyClientSocket.class.getName()) .log(Level.INFO, "Exception thrown when closing Grizzly transport: " + e.getMessage(), e); } } transport = null; } }
static void closeSharedTransport() { synchronized (TRANSPORT_LOCK) { if (transport != null) { try { Logger.getLogger(GrizzlyClientSocket.class.getName()).log(Level.FINE, "Stopping shared container."); transport.shutdownNow(); } catch (IOException e) { Logger.getLogger(GrizzlyClientSocket.class.getName()) .log(Level.INFO, "Exception thrown when closing Grizzly transport: " + e.getMessage(), e); } } transport = null; } }
/** * <p> Immediately shuts down the listener. </p> * * @throws IOException if an error occurs when attempting to shut down the listener */ public synchronized void shutdownNow() throws IOException { if (state == State.STOPPED) { return; } try { serverConnection = null; transport.shutdownNow(); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "Stopped listener bound to [{0}]", host + ':' + port); } } finally { state = State.STOPPED; if (shutdownFuture != null) { shutdownFuture.result(this); } } }
/** * <p> Immediately shuts down the listener. </p> * * @throws IOException if an error occurs when attempting to shut down the listener */ public synchronized void shutdownNow() throws IOException { if (state == State.STOPPED) { return; } try { serverConnection = null; transport.shutdownNow(); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "Stopped listener bound to [{0}]", host + ':' + port); } } finally { state = State.STOPPED; if (shutdownFuture != null) { shutdownFuture.result(this); } } }
/** * <p> Immediately shuts down the listener. </p> * * @throws IOException if an error occurs when attempting to shut down the listener */ public synchronized void shutdownNow() throws IOException { if (state == State.STOPPED) { return; } try { serverConnection = null; transport.shutdownNow(); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.log(Level.INFO, "Stopped listener bound to [{0}]", host + ':' + port); } } finally { state = State.STOPPED; if (shutdownFuture != null) { shutdownFuture.result(this); } } }
@Override public void close() { try { connectionManager.destroy(); clientTransport.shutdownNow(); final ExecutorService service = clientConfig.executorService(); if (service != null) { service.shutdown(); } if (timeoutExecutor != null) { timeoutExecutor.stop(); timeoutExecutor.getThreadPool().shutdownNow(); } } catch (IOException ignored) { } }
@Override public void close() { try { connectionManager.destroy(); clientTransport.shutdownNow(); final ExecutorService service = clientConfig.executorService(); if (service != null) { service.shutdown(); } if (timeoutExecutor != null) { timeoutExecutor.stop(); timeoutExecutor.getThreadPool().shutdownNow(); } } catch (IOException ignored) { } }
@Override public void close() { try { connectionManager.destroy(); clientTransport.shutdownNow(); final ExecutorService service = clientConfig.executorService(); if (service != null) { service.shutdown(); } if (timeoutExecutor != null) { timeoutExecutor.stop(); timeoutExecutor.getThreadPool().shutdownNow(); } } catch (IOException ignored) { } }
@Override public void close() { try { connectionManager.destroy(); clientTransport.shutdownNow(); final ExecutorService service = clientConfig.executorService(); if (service != null) { service.shutdown(); } if (timeoutExecutor != null) { timeoutExecutor.stop(); timeoutExecutor.getThreadPool().shutdownNow(); } } catch (IOException ignored) { } }
@After public void tearDown() throws IOException { serverSideConnections.clear(); if (transport != null) { transport.shutdownNow(); } }
@After public void tearDown() throws IOException { serverSideConnections.clear(); if (transport != null) { transport.shutdownNow(); } }
@Override public void tearDown() { try { poisonFuture.get(20, TimeUnit.SECONDS); clientWriter.close(); clientconnection.closeSilently(); servertransport.shutdownNow(); clienttransport.shutdownNow(); } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Close", ex); } }
public static void main(String[] args) throws Exception { // Create a FilterChain using FilterChainBuilder FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless(); // Add filters to the chain filterChainBuilder.add(new TransportFilter()); filterChainBuilder.add(new GIOPFilter()); filterChainBuilder.add(new EchoFilter()); // Create TCP NIO transport final TCPNIOTransport transport = TCPNIOTransportBuilder.newInstance().build(); transport.setProcessor(filterChainBuilder.build()); try { // Bind server socket and start transport transport.bind(PORT); transport.start(); System.out.println("Press <enter> to exit..."); System.in.read(); } finally { transport.shutdownNow(); } } }
@Test public void testCustomThreadPoolSameThreadStrategy() throws Exception { final int poolSize = Math.max(Runtime.getRuntime().availableProcessors()/2, 1); final ThreadPoolConfig poolCfg = ThreadPoolConfig.defaultConfig(); poolCfg.setCorePoolSize(poolSize).setMaxPoolSize(poolSize); final TCPNIOTransport tcpTransport = TCPNIOTransportBuilder.newInstance() .setReuseAddress(true) .setIOStrategy(SameThreadIOStrategy.getInstance()) .setSelectorThreadPoolConfig(poolCfg) .setWorkerThreadPoolConfig(null) .build(); try { tcpTransport.start(); } finally { tcpTransport.shutdownNow(); } }
@Test public void testCustomThreadPoolWorkerThreadStrategy() throws Exception { final int selectorPoolSize = Math.max(Runtime.getRuntime().availableProcessors()/2, 1); final ThreadPoolConfig selectorPoolCfg = ThreadPoolConfig.defaultConfig(); selectorPoolCfg.setCorePoolSize(selectorPoolSize).setMaxPoolSize(selectorPoolSize); final int workerPoolSize = Runtime.getRuntime().availableProcessors() * 2 ; final ThreadPoolConfig workerPoolCfg = ThreadPoolConfig.defaultConfig(); workerPoolCfg.setCorePoolSize(workerPoolSize).setMaxPoolSize(workerPoolSize); final TCPNIOTransport tcpTransport = TCPNIOTransportBuilder.newInstance() .setReuseAddress(true) .setIOStrategy(WorkerThreadIOStrategy.getInstance()) .setSelectorThreadPoolConfig(selectorPoolCfg) .setWorkerThreadPoolConfig(workerPoolCfg) .build(); try { tcpTransport.start(); } finally { tcpTransport.shutdownNow(); } } }
transport1.shutdownNow(); transport2.shutdownNow();