private String getPort() { return instance.settings().get("http.port"); }
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()); }
@Test public void testConfigurationFile() throws BackendException { final String index = "es"; ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration(); config.set(LOCAL_MODE, true, index); config.set(CLIENT_ONLY, true, index); config.set(INDEX_CONF_FILE, Joiner.on(File.separator).join("target", "test-classes", "es_nodename_foo.yml"), index); config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index); Configuration indexConfig = config.restrictTo(index); ElasticSearchIndex idx = new ElasticSearchIndex(indexConfig); // Shouldn't throw exception idx.close(); assertEquals("foo", idx.getNode().settings().get("node.name")); config = GraphDatabaseConfiguration.buildGraphConfiguration(); config.set(LOCAL_MODE, true, index); config.set(CLIENT_ONLY, true, index); config.set(INDEX_CONF_FILE, Joiner.on(File.separator).join("target", "test-classes", "es_nodename_bar.yml"), index); config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index); indexConfig = config.restrictTo(index); idx = new ElasticSearchIndex(indexConfig); // Shouldn't throw exception idx.close(); assertEquals("bar", idx.getNode().settings().get("node.name")); }
@Override public Settings settings() { return nodeDelegate.settings(); }
@Override public Settings settings() { return nodeDelegate.settings(); }
public void unbindNode(Node node) { String clusterName = node.settings().get("cluster.name"); Set<Node> nodeSet = nodesClusterMap.get(clusterName); if (nodeSet != null) { nodeSet.remove(node); if (nodeSet.isEmpty()) { nodesClusterMap.remove(clusterName); } } } }
public void bindNode(Node node) { String clusterName = node.settings().get("cluster.name"); Set<Node> nodeSet = nodesClusterMap.get(clusterName); if (nodeSet == null) { nodeSet = new HashSet<Node>(); nodesClusterMap.put(clusterName, nodeSet); } nodeSet.add(node); }
public void unbindNode(Node node) { String clusterName = node.settings().get("cluster.name"); Set<Node> nodeSet = nodesClusterMap.get(clusterName); if (nodeSet != null) { nodeSet.remove(node); if (nodeSet.isEmpty()) { nodesClusterMap.remove(clusterName); } } } }
public void bindNode(Node node) { String clusterName = node.settings().get("cluster.name"); Set<Node> nodeSet = nodesClusterMap.get(clusterName); if (nodeSet == null) { nodeSet = new HashSet<Node>(); nodesClusterMap.put(clusterName, nodeSet); } nodeSet.add(node); }
protected static String getUrl(final Node node, final String path) { final StringBuilder urlBuf = new StringBuilder(200); urlBuf.append("http://localhost:").append(node.settings().get("http.port")); if (path.startsWith("/")) { urlBuf.append(path); } else { urlBuf.append('/').append(path); } return urlBuf.toString(); }
@Override public String toString() { String nodeName = node.settings().get("name"); String clusterName = node.settings().get("cluster.name"); boolean local = Boolean.valueOf(node.settings().get("node.local")); String prefix; if (local) { prefix = "Local node"; } else { prefix = "Node"; } return String.format("%s [%s] - cluster [%s]", prefix, nodeName, clusterName); } }
private int getMasterNodesCount() { return (int)nodes.values().stream().filter(n -> Node.NODE_MASTER_SETTING.get(n.node().settings())).count(); }
TribeClusterStateListener(Node tribeNode) { String tribeName = TRIBE_NAME_SETTING.get(tribeNode.settings()); this.tribeName = tribeName; executor = new TribeNodeClusterStateTaskExecutor(tribeName); }
TribeClusterStateListener(Node tribeNode) { String tribeName = TRIBE_NAME_SETTING.get(tribeNode.settings()); this.tribeName = tribeName; executor = new TribeNodeClusterStateTaskExecutor(tribeName); }
TribeClusterStateListener(Node tribeNode) { String tribeName = tribeNode.settings().get(TRIBE_NAME); this.tribeName = tribeName; executor = new TribeNodeClusterStateTaskExecutor(tribeName); }
/** Start an embedded Elasticsearch node. The node will not store any data locally (non-datanode) but will connect to a cluster using the default Elasticsearch settings (those available in /etc/elasticsearch/elasticsearch.yml). */ private void startNode() { LOG.info("Starting embedded Elasticsearch client (non-datanode)..."); this.node = NodeBuilder.nodeBuilder().client(true).node(); LOG.info("Successfully joined Elasticsearch cluster '"+ClusterName.clusterNameFromSettings(node.settings())+'"'); }
/** Start an embedded Elasticsearch node. The node will not store any data locally (non-datanode) but will connect to a cluster using the default Elasticsearch settings (those available in /etc/elasticsearch/elasticsearch.yml). */ private void startNode() { LOG.info("Starting embedded Elasticsearch client (non-datanode)..."); this.node = NodeBuilder.nodeBuilder().client(true).node(); LOG.info("Successfully joined Elasticsearch cluster '"+ClusterName.clusterNameFromSettings(node.settings())+'"'); }