use of core.framework.search.ClusterStateResponse in project core-ng-project by neowu.
the class CleanupOldIndexJob method cleanup.
void cleanup(LocalDate now) {
ClusterStateResponse state = elasticSearch.state();
for (var entry : state.metadata.indices.entrySet()) {
String index = entry.getKey();
indexService.createdDate(index).ifPresent(date -> {
long days = ChronoUnit.DAYS.between(date, now);
if (days >= jobConfig.indexRetentionDays) {
// delete index older than indexAliveDays, default is 30
deleteIndex(index);
} else if (days >= jobConfig.indexOpenDays && entry.getValue().state == ClusterStateResponse.IndexState.OPEN) {
// close index older than indexOpenDays, default is 7
closeIndex(index);
}
});
}
}
use of core.framework.search.ClusterStateResponse in project core-ng-project by neowu.
the class ElasticSearchIntegrationTest method state.
@Test
void state() {
ClusterStateResponse state = elasticSearch.state();
assertThat(state.metadata.indices.entrySet()).anyMatch(entry -> "document".equals(entry.getKey()) && entry.getValue().state == ClusterStateResponse.IndexState.OPEN);
}
Aggregations