public static void main(String[] args) throws Exception { final InternalNode node = new InternalNode(); node.start(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { node.close(); } }); } }
@Override public Client client() { return this.node.client(); }
@Override public void run() { node.close(); } });
protected ExtendedInternalNode doCreateInternal(Dictionary properties) { Thread.currentThread().setContextClassLoader(Node.class.getClassLoader()); ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder(); builder.put(settings); builder.classLoader(Node.class.getClassLoader()); if (properties != null) { for (Enumeration e = properties.keys(); e.hasMoreElements();) { String key = e.nextElement().toString(); Object oval = properties.get(key); String val = oval != null ? oval.toString() : null; builder.put(key, val); } } ExtendedInternalNode node = new ExtendedInternalNode(context, new InternalNode(builder.build(), false)); try { node.start(); } catch (RuntimeException t) { doDestroy(node); throw t; } return node; }
@Override public Node start() { Node n = this.node.start(); this.storage.init(); this.httpServiceTracker.open(); this.mbeanServerTracker.open(); return n; }
@Override public Node stop() { this.mbeanServerTracker.close(); this.httpServiceTracker.close(); this.storage.destroy(); return this.node.stop(); }
@Override public boolean isClosed() { return this.node.isClosed(); }
@Override public Settings settings() { return this.node.settings(); }
public void setNode(InternalNode node) { this.node = node; this.controller = node.injector().getInstance(RestController.class); }
@Override public void run() { node.close(); } });
protected Node doCreateInternal(Dictionary properties) { ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder(); builder.put(settings); builder.classLoader(NodeFactory.class.getClassLoader()); if (properties != null) { for (Enumeration e = properties.keys(); e.hasMoreElements();) { String key = e.nextElement().toString(); Object oval = properties.get(key); String val = oval != null ? oval.toString() : null; builder.put(key, val); } } Node node = new InternalNode(builder.build(), false); try { node.start(); node.client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet(); } catch (RuntimeException t) { doDestroy(node); throw t; } return node; }
public void close() { if (lifecycle.started()) { stop();
@Override public void awaitStop() { while (node != null && !node.isClosed()) { try { Thread.sleep(200L); } catch (InterruptedException e) { // Ignore } } }
this.settings = pluginsService.updatedSettings(); this.environment = new Environment(this.settings());
public static void main(String[] args) throws Exception { final InternalNode node = new InternalNode(); node.start(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { node.close(); } }); } }
@Override public void close() { stop(); this.node.close(); }
public void close() { if (lifecycle.started()) { stop();
@Override public boolean isReady() { return node != null && node.client().admin().cluster().prepareHealth() .setWaitForYellowStatus() .setTimeout(TimeValue.timeValueSeconds(30L)) .get() .getStatus() != ClusterHealthStatus.RED; }
@Override public void start() { LoggerFactory.getLogger(SearchServer.class).info("Starting Elasticsearch[{}] on port {}", settings.clusterName(), settings.tcpPort()); node = new InternalNode(settings.build(), false); node.start(); }