@Override public void destroy() throws InterruptedException { if (this.defaultEventLoopGroup) { // Clean up the EventLoopGroup if we created it in the constructor this.eventLoopGroup.shutdownGracefully().sync(); } }
@Override public Future<T> sync() throws InterruptedException { return delegate.sync(); }
@Override public void destroy() throws InterruptedException { if (this.defaultEventLoopGroup) { // Clean up the EventLoopGroup if we created it in the constructor this.eventLoopGroup.shutdownGracefully().sync(); } }
public void stop() throws IOException, InterruptedException { LOG.info("Stopping LlapOutputFormatService"); if (listeningChannelFuture != null) { listeningChannelFuture.channel().close().sync(); listeningChannelFuture = null; } else { LOG.warn("LlapOutputFormatService does not appear to have a listening port to close."); } eventLoopGroup.shutdownGracefully(1, WAIT_TIME, TimeUnit.SECONDS).sync(); }
public void stop() throws IOException, InterruptedException { LOG.info("Stopping LlapOutputFormatService"); if (listeningChannelFuture != null) { listeningChannelFuture.channel().close().sync(); listeningChannelFuture = null; } else { LOG.warn("LlapOutputFormatService does not appear to have a listening port to close."); } eventLoopGroup.shutdownGracefully(1, WAIT_TIME, TimeUnit.SECONDS).sync(); }
@Override public void stopAndWait() { if (isStop) { return; } isStop = true; System.out.println(); log.info("{}Blade shutdown ...", getStartedSymbol()); try { if (this.bossGroup != null) { this.bossGroup.shutdownGracefully().sync(); } if (this.workerGroup != null) { this.workerGroup.shutdownGracefully().sync(); } log.info("{}Blade shutdown successful", getStartedSymbol()); } catch (Exception e) { log.error("Blade shutdown error", e); } }
@Override public void stopAndWait() { if (isStop) { return; } isStop = true; System.out.println(); log.info("{}Blade shutdown ...", getStartedSymbol()); try { if (this.bossGroup != null) { this.bossGroup.shutdownGracefully().sync(); } if (this.workerGroup != null) { this.workerGroup.shutdownGracefully().sync(); } log.info("{}Blade shutdown successful", getStartedSymbol()); } catch (Exception e) { log.error("Blade shutdown error", e); } }
@AfterClass public static void shutdownEventLoopGroup() throws InterruptedException { eventLoopGroup.shutdownGracefully().sync(); }
@AfterClass public static void shutdownEventLoopGroup() throws InterruptedException { eventLoopGroup.shutdownGracefully().sync(); }
register0(ch, interestOps, task); }).sync(); } catch (InterruptedException ignore) {
private List<ADnsAnswer> resolveIpAddresses(String hostName, DnsRecordType dnsRecordType, boolean includeIpVersion) throws InterruptedException, ExecutionException { LOG.debug("Attempting to resolve [{}] records for [{}]", dnsRecordType, hostName); if (isShutdown()) { throw new DnsClientNotRunningException(); } validateHostName(hostName); final DefaultDnsQuestion aRecordDnsQuestion = new DefaultDnsQuestion(hostName, dnsRecordType); /* The DnsNameResolver.resolveAll(DnsQuestion) method handles all redirects through CNAME records to * ultimately resolve a list of IP addresses with TTL values. */ return resolver.resolveAll(aRecordDnsQuestion).sync().get().stream() .map(dnsRecord -> decodeDnsRecord(dnsRecord, includeIpVersion)) .filter(Objects::nonNull) // Removes any entries which the IP address could not be extracted for. .collect(Collectors.toList()); }
register0(ch, interestOps, task); }).sync(); } catch (InterruptedException ignore) {
@Override public void shutdown() { bootstrap.config().group().shutdownGracefully(); try { bootstrap.config().group().terminationFuture().sync(); } catch (InterruptedException e) { GlowServer.logger.log(Level.SEVERE, "Datagram server shutdown process interrupted!", e); } } }
@Override public void shutdown() { channel.close(); bootstrap.config().group().shutdownGracefully(); bootstrap.config().childGroup().shutdownGracefully(); try { bootstrap.config().group().terminationFuture().sync(); bootstrap.config().childGroup().terminationFuture().sync(); } catch (InterruptedException e) { GlowServer.logger.log(Level.SEVERE, "Socket server shutdown process interrupted!", e); } } }
@Test public void shouldLogOnlyTheFirstCaughtException() throws Exception { AssertableLogProvider logProvider = new AssertableLogProvider(); BoltConnection connection = mock( BoltConnection.class ); HouseKeeper houseKeeper = new HouseKeeper( connection, logProvider.getLog( HouseKeeper.class ) ); Bootstrap bootstrap = newBootstrap( houseKeeper ); RuntimeException error1 = new RuntimeException( "error #1" ); RuntimeException error2 = new RuntimeException( "error #2" ); RuntimeException error3 = new RuntimeException( "error #3" ); try ( ServerSocket serverSocket = new ServerSocket( 0 ) ) { ChannelFuture future = bootstrap.connect( "localhost", serverSocket.getLocalPort() ).sync(); Channel channel = future.channel(); // fire multiple errors channel.pipeline().fireExceptionCaught( error1 ); channel.pipeline().fireExceptionCaught( error2 ); channel.pipeline().fireExceptionCaught( error3 ); // await for the channel to be closed by the HouseKeeper channel.closeFuture().sync(); } finally { // make sure event loop group is always terminated bootstrap.config().group().shutdownGracefully().sync(); } logProvider.assertExactly( inLog( HouseKeeper.class ).error( startsWith( "Fatal error occurred when handling a client connection" ), equalTo( error1 ) ) ); }
content = resolver.query(new DefaultDnsQuestion(hostName, DnsRecordType.TXT)).sync().get().content(); int count = content.count(DnsSection.ANSWER); final ArrayList<TxtDnsAnswer> txtRecords = new ArrayList<>(count);
@Test public void shouldNotLogExceptionsWhenEvenLoopIsShuttingDown() throws Exception { AssertableLogProvider logProvider = new AssertableLogProvider(); BoltConnection connection = mock( BoltConnection.class ); HouseKeeper houseKeeper = new HouseKeeper( connection, logProvider.getLog( HouseKeeper.class ) ); Bootstrap bootstrap = newBootstrap( houseKeeper ); try ( ServerSocket serverSocket = new ServerSocket( 0 ) ) { ChannelFuture future = bootstrap.connect( "localhost", serverSocket.getLocalPort() ).sync(); Channel channel = future.channel(); // write some messages without flushing for ( int i = 0; i < 100; i++ ) { // use void promise which should redirect all write errors back to the pipeline and the HouseKeeper channel.write( writeUtf8( channel.alloc(), "Hello" ), channel.voidPromise() ); } // stop the even loop to make all pending writes fail bootstrap.config().group().shutdownGracefully(); // await for the channel to be closed by the HouseKeeper channel.closeFuture().sync(); } finally { // make sure event loop group is always terminated bootstrap.config().group().shutdownGracefully().sync(); } logProvider.assertNoLoggingOccurred(); }
content = resolver.query(new DefaultDnsQuestion(inverseAddressFormat, DnsRecordType.PTR)).sync().get().content(); for (int i = 0; i < content.count(DnsSection.ANSWER); i++) {