Source:
private Client createInProcessNode(ElasticSearchSearchIndexConfiguration config) { String dataPath = config.getInProcessNodeDataPath(); checkNotNull(dataPath, ElasticSearchSearchIndexConfiguration.IN_PROCESS_NODE_DATA_PATH + " is required for in process Elasticsearch node"); String logsPath = config.getInProcessNodeLogsPath(); checkNotNull(logsPath, ElasticSearchSearchIndexConfiguration.IN_PROCESS_NODE_LOGS_PATH + " is required for in process Elasticsearch node"); String workPath = config.getInProcessNodeWorkPath(); checkNotNull(workPath, ElasticSearchSearchIndexConfiguration.IN_PROCESS_NODE_WORK_PATH + " is required for in process Elasticsearch node"); int numberOfShards = config.getNumberOfShards(); NodeBuilder nodeBuilder = NodeBuilder .nodeBuilder(); if (config.getClusterName() != null) { nodeBuilder = nodeBuilder.clusterName(config.getClusterName()); } this.inProcessNode = nodeBuilder .local(false) .settings( ImmutableSettings.settingsBuilder() .put("script.disable_dynamic", "false") .put("gateway.type", "local") .put("index.number_of_shards", numberOfShards) .put("index.number_of_replicas", "0") .put("path.data", dataPath) .put("path.logs", logsPath) .put("path.work", workPath) ).node(); inProcessNode.start(); Client client = inProcessNode.client(); while (true) { ClusterHealthResponse health = client.admin().cluster().prepareHealth().get(); if (health.getStatus() != ClusterHealthStatus.RED) { break; } try { Thread.sleep(1000); } catch (InterruptedException e) { throw new VertexiumException("Could not sleep", e); } LOGGER.info("Status is %s, waiting...", health.getStatus()); } return client; }

Target:
private Client createInProcessNode(ElasticSearchSearchIndexConfiguration config) { String dataPath = config.getInProcessNodeDataPath(); checkNotNull(dataPath, ElasticSearchSearchIndexConfiguration.IN_PROCESS_NODE_DATA_PATH + " is required for in process Elasticsearch node"); String logsPath = config.getInProcessNodeLogsPath(); checkNotNull(logsPath, ElasticSearchSearchIndexConfiguration.IN_PROCESS_NODE_LOGS_PATH + " is required for in process Elasticsearch node"); String workPath = config.getInProcessNodeWorkPath(); checkNotNull(workPath, ElasticSearchSearchIndexConfiguration.IN_PROCESS_NODE_WORK_PATH + " is required for in process Elasticsearch node"); int numberOfShards = config.getNumberOfShards(); NodeBuilder nodeBuilder = NodeBuilder .nodeBuilder(); if (config.getClusterName() != null) { nodeBuilder = nodeBuilder.clusterName(config.getClusterName()); } this.inProcessNode = nodeBuilder .local(false) .settings( ImmutableSettings.settingsBuilder() .put("script.disable_dynamic", "false") .put("gateway.type", "local") .put("index.number_of_shards", numberOfShards) .put("index.number_of_replicas", "0") .put("path.data", dataPath) .put("path.logs", logsPath) .put("path.work", workPath) ).node(); inProcessNode.start(); Client client = inProcessNode.client(); long startTime = System.currentTimeMillis(); while (true) { if (System.currentTimeMillis() > startTime + IN_PROCESS_NODE_WAIT_TIME_MS) { throw new VertexiumException("Status failed to exit red status after waiting " + IN_PROCESS_NODE_WAIT_TIME_MS + "ms. Giving up."); } ClusterHealthResponse health = client.admin().cluster().prepareHealth().get(); if (health.getStatus() != ClusterHealthStatus.RED) { break; } try { Thread.sleep(1000); } catch (InterruptedException e) { throw new VertexiumException("Could not sleep", e); } LOGGER.info("Status is %s, waiting...", health.getStatus()); } return client; }