use of core.framework.search.ElasticSearchIndex in project core-ng-project by neowu.
the class ElasticSearchIntegrationTest method indices.
@Test
void indices() {
List<ElasticSearchIndex> indices = elasticSearch.indices();
assertEquals(1, indices.size());
ElasticSearchIndex index = indices.get(0);
assertEquals("document", index.index);
assertEquals(IndexMetaData.State.OPEN, index.state);
}
use of core.framework.search.ElasticSearchIndex in project core-ng-project by neowu.
the class CleanupOldIndexJobTest method index.
private ElasticSearchIndex index(String index, IndexMetaData.State state) {
ElasticSearchIndex elasticSearchIndex = new ElasticSearchIndex();
elasticSearchIndex.index = index;
elasticSearchIndex.state = state;
return elasticSearchIndex;
}
use of core.framework.search.ElasticSearchIndex in project core-ng-project by neowu.
the class ElasticSearchImpl method indices.
@Override
public List<ElasticSearchIndex> indices() {
StopWatch watch = new StopWatch();
try {
AdminClient adminClient = client().admin();
ClusterStateResponse response = adminClient.cluster().state(new ClusterStateRequest().clear().metaData(true)).actionGet();
ImmutableOpenMap<String, IndexMetaData> indices = response.getState().getMetaData().indices();
List<ElasticSearchIndex> results = new ArrayList<>(indices.size());
for (ObjectObjectCursor<String, IndexMetaData> cursor : indices) {
IndexMetaData metaData = cursor.value;
ElasticSearchIndex index = new ElasticSearchIndex();
index.index = metaData.getIndex().getName();
index.state = metaData.getState();
results.add(index);
}
return results;
} catch (ElasticsearchException e) {
// due to elastic search uses async executor to run, we have to wrap the exception to retain the original place caused the exception
throw new SearchException(e);
} finally {
logger.info("indices, elapsedTime={}", watch.elapsedTime());
}
}
Aggregations