@Override public void cleanup() { if (node != null && !node.isClosed()) { node.close(); node = null; } } }
@Override public synchronized void stop() throws Exception { if (instance != null && !instance.isClosed()) { String port = getPort(); logger.info("Stopping Elastic Search"); instance.close(); instance = null; logger.info("Elastic Search on port {} stopped", port); } } }
@Override public void close() throws BackendException { if (node != null && !node.isClosed()) { node.close(); } client.close(); }
/** * Close the connection to the remote elasticsearch client. This should only be called when the application is * terminated. * Please avoid to open and close the ElasticsearchClient for the same cluster and index more than once. * To avoid that this method is called more than once, the elasticsearch_client object is set to null * as soon this was called the first time. This is needed because the finalize method calls this * method as well. */ public void close() { if (this.elasticsearchClient != null) { this.elasticsearchClient.close(); this.elasticsearchClient = null; } if (this.elasticsearchNode != null) { this.elasticsearchNode.close(); this.elasticsearchNode = null; } }
@Override public void cleanup() throws DBException { if (!remoteMode) { if (!node.isClosed()) { client.close(); node.close(); } } else { client.close(); } }
public synchronized void start(String clusterName, String host, int port) throws Exception { if (instance != null) { String msg = String.format( "An instance of this Embedded Elastic Search server is already running on port: %d. " + "It must be stopped before you can call start again.", getPort() ); logger.error(msg); throw new IllegalStateException(msg); } final Settings settings = getSettings(clusterName, host, port); dataDir = setupDataDir(settings.get(ElasticSearchConfiguration.EMBEDDED_DATA_PATH_DEFAULT_VALUE)); logger.info("Starting ElasticSearch for cluster {} ", settings.get("cluster.name")); instance = new PluginConfigurableNode(settings, singletonList(Netty4Plugin.class)); instance.start(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { try { if (instance != null) { instance.close(); } } catch (IOException e) { logger.error("Error closing ElasticSearch"); } })); logger.info("ElasticSearch cluster {} started in local mode on port {}", instance.settings().get("cluster.name"), getPort()); }
private static void closeNode(Node node) { try { LoggerContext context = (LoggerContext) LogManager.getContext(false); Configurator.shutdown(context); node.close(); Thread.sleep(250); } catch (Throwable e) { //ignore } }
public static void main(String[] args) throws Exception { final Timer.Context timer = Stagemonitor.getMetric2Registry().timer(name("startElasticsearch").build()).time(); startElasticsearch(); Stagemonitor.init(); timer.stop(); printResults(); node.close(); }
/** * Tear down after class. * * @throws Exception * the exception */ @AfterClass public static void tearDownAfterClass() throws Exception { node.close(); }
@AfterClass public static void tearDownAfterClass() throws Exception { node.close(); }
@AfterClass public static void tearDownAfterClass() throws Exception { node.close(); }
/** * Tear down after class. * * @throws Exception * the exception */ @AfterClass public static void tearDownAfterClass() throws Exception { if (node != null) node.close(); }
@AfterClass public static void tearDownAfterClass() throws Exception { node.close(); }
/** * Tear down after class. * * @throws Exception * the exception */ @AfterClass public static void tearDownAfterClass() throws Exception { if (node != null) node.close(); }
/** * Tear down after class. * * @throws Exception * the exception */ @AfterClass public static void tearDownAfterClass() throws Exception { if (node != null) node.close(); }
@AfterClass public static void tearDownAfterClass() throws Exception { // node.stop(); node.close(); }
/** * Tear down after class. * * @throws Exception * the exception */ @AfterClass public static void tearDownAfterClass() throws Exception { node.close(); }
@After public void tearDown() throws Exception { if (checkIfServerRunning() && node != null) { node.close(); } }
@After public void tearDown() throws Exception { if (checkIfServerRunning() && node != null) { node.close(); } }
@After public void tearDown() { if (checkIfServerRunning() && node != null) { node.close(); } tearDownInternal(); }