protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
protected ExecutorService createShutdownExecutorService() { final String baseThreadIdentifier = this.getName() + '[' + Integer.toHexString(this.hashCode()) + "]-Shutdown-Thread"; final ThreadFactory factory = new ThreadFactory() { private int counter; @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, baseThreadIdentifier + "(" + counter++ + ')'); t.setDaemon(true); return t; } }; return Executors.newFixedThreadPool(2, factory); } }
@NameValue public String getName() { return transport.getName(); }
@NameValue public String getName() { return transport.getName(); }
@Test public void testStartStop() throws IOException { LOGGER.log(Level.INFO, "Running: testStartStop ({0})", transport.getName()); try { transport.bind(PORT); transport.start(); } finally { transport.shutdownNow(); } }
@Test public void testConnectorHandlerConnect() throws Exception { LOGGER.log(Level.INFO, "Running: testConnectorHandlerConnect ({0})", transport.getName()); Connection connection = null; try { transport.bind(PORT); transport.start(); Future<Connection> future = transport.connect("localhost", PORT); connection = future.get(10, TimeUnit.SECONDS); assertTrue(connection != null); } finally { if (connection != null) { connection.closeSilently(); } transport.shutdownNow(); } }
@Test public void testWorkerThreadPoolConfiguration2() throws Exception { LOGGER.log(Level.INFO, "Running: testWorkerThreadPoolConfiguration2 ({0})", transport.getName()); ThreadPoolConfig config = ThreadPoolConfig.defaultConfig(); config.setCorePoolSize(1); config.setMaxPoolSize(1); config.setPoolName("custom"); transport.setWorkerThreadPoolConfig(config); transport.setIOStrategy(SameThreadIOStrategy.getInstance()); assertNull(transport.getWorkerThreadPoolConfig()); assertNull(transport.getWorkerThreadPool()); }
@Test public void testReadWriteTimeout() throws Exception { LOGGER.log(Level.INFO, "Running: testReadWriteTimeout ({0})", transport.getName()); assertEquals(30, transport.getWriteTimeout(TimeUnit.SECONDS)); assertEquals(30, transport.getReadTimeout(TimeUnit.SECONDS)); transport.setReadTimeout(45, TimeUnit.MINUTES); assertEquals(TimeUnit.MILLISECONDS.convert(45, TimeUnit.MINUTES), transport.getReadTimeout(TimeUnit.MILLISECONDS)); assertEquals(30, transport.getWriteTimeout(TimeUnit.SECONDS)); transport.setReadTimeout(-5, TimeUnit.SECONDS); assertEquals(-1, transport.getReadTimeout(TimeUnit.MILLISECONDS)); transport.setReadTimeout(0, TimeUnit.SECONDS); assertEquals(-1, transport.getReadTimeout(TimeUnit.MILLISECONDS)); }
@Test public void testStartStopStart() throws Exception { LOGGER.log(Level.INFO, "Running: testStartStopStart ({0})", transport.getName()); try { transport.bind(PORT); transport.start(); Future<Connection> future = transport.connect("localhost", PORT); Connection connection = future.get(10, TimeUnit.SECONDS); assertTrue(connection != null); connection.closeSilently(); transport.shutdownNow(); assertTrue(transport.isStopped()); transport.bind(PORT); transport.start(); assertTrue(!transport.isStopped()); future = transport.connect("localhost", PORT); connection = future.get(10, TimeUnit.SECONDS); assertTrue(connection != null); connection.closeSilently(); } finally { transport.shutdownNow(); } }
@Test public void testWorkerThreadPoolConfiguration() throws Exception { LOGGER.log(Level.INFO, "Running: testWorkerThreadPoolConfiguration ({0})", transport.getName()); ThreadPoolConfig config = ThreadPoolConfig.defaultConfig(); config.setCorePoolSize(1); config.setMaxPoolSize(1); config.setPoolName("custom"); transport.setWorkerThreadPoolConfig(config); transport.setIOStrategy(WorkerThreadIOStrategy.getInstance()); ThreadPoolConfig underTest = transport.getWorkerThreadPoolConfig(); assertEquals(1, underTest.getCorePoolSize()); assertEquals(1, underTest.getMaxPoolSize()); assertEquals("custom", underTest.getPoolName()); }