@Override public void start() throws IOException { startDelayedExecutor(); ((SocketBinder) transport).bind(new InetSocketAddress(address, port)); transport.start(); }
@Override public void start() throws IOException { delayedExecutor.start(); ((SocketBinder) transport).bind(new InetSocketAddress(address, port)); transport.start(); }
@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 testTimedGracefulShutdownAndThenForced() throws Exception { LOGGER.log(Level.INFO, "Running: testTimedGracefulShutdownAndThenForced ({0})", transport.getName()); final CountDownLatch latch = new CountDownLatch(1); transport.addShutdownListener(new GracefulShutdownListener() { @Override public void shutdownRequested(ShutdownContext shutdownContext) { try { Thread.sleep(20000); } catch (InterruptedException ignored) { } shutdownContext.ready(); } @Override public void shutdownForced() { latch.countDown(); } }); transport.start(); GrizzlyFuture<Transport> future = transport.shutdown(5, TimeUnit.MINUTES); Thread.sleep(3000); transport.shutdownNow(); latch.await(5, TimeUnit.SECONDS); final Transport tt = future.get(1, TimeUnit.SECONDS); assertEquals(transport, tt); assertTrue(transport.isStopped()); }
transport.start(); GrizzlyFuture<Transport> future = transport.shutdown(); Thread.sleep(3000);
transport.start(); long start = System.currentTimeMillis(); GrizzlyFuture<Transport> future = transport.shutdown();
transport.start(); GrizzlyFuture<Transport> future = transport.shutdown(5, TimeUnit.SECONDS);
transport.start(); GrizzlyFuture<Transport> future = transport.shutdown(5, TimeUnit.SECONDS); Transport tt = future.get(5100, 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(); } }
transport.start();
transport.start();
transport.start();
transport.start();
transport.start();
transport.start(); transport.configureBlocking(true);
transport.start();