@PreDestroy public void destroy() { executor.shutdownNow(); try { executor.awaitTermination(30, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } // unannounce try { getFutureResult(announcementClient.unannounce(), DiscoveryException.class); } catch (DiscoveryException e) { if (e.getCause() instanceof ConnectException) { log.error( "Cannot connect to discovery server for unannounce: %s", e.getCause().getMessage()); } else { log.error(e); } } }
public static void main(String[] args) { try { Bootstrap app = new Bootstrap( new CassandraModule(), new NodeModule(), new HttpServerModule(), new JaxrsModule(), new JsonModule(), new MBeanModule(), new JmxModule(), new DiscoveryModule(), new HttpEventModule()) .strictConfig(); app.initialize(); } catch (Exception e) { log.error(e); // Cassandra prevents the vm from shutting down on its own System.exit(1); } }