Search in sources :

Example 1 with ClusterStateResponse

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);
            }
        });
    }
}
Also used : ClusterStateResponse(core.framework.search.ClusterStateResponse)

Example 2 with ClusterStateResponse

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);
}
Also used : ClusterStateResponse(core.framework.search.ClusterStateResponse) IntegrationTest(core.framework.search.IntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

ClusterStateResponse (core.framework.search.ClusterStateResponse)2 IntegrationTest (core.framework.search.IntegrationTest)1 Test (org.junit.jupiter.api.Test)1