use of org.opensearch.gateway.PersistedClusterStateService.Writer in project OpenSearch by opensearch-project.
the class PersistedClusterStateServiceTests method testPersistsAndReloadsTerm.
public void testPersistsAndReloadsTerm() throws IOException {
try (NodeEnvironment nodeEnvironment = newNodeEnvironment(createDataPaths())) {
final PersistedClusterStateService persistedClusterStateService = newPersistedClusterStateService(nodeEnvironment);
final long newTerm = randomNonNegativeLong();
assertThat(persistedClusterStateService.loadBestOnDiskState().currentTerm, equalTo(0L));
try (Writer writer = persistedClusterStateService.createWriter()) {
writer.writeFullStateAndCommit(newTerm, ClusterState.EMPTY_STATE);
assertThat(persistedClusterStateService.loadBestOnDiskState().currentTerm, equalTo(newTerm));
}
assertThat(persistedClusterStateService.loadBestOnDiskState().currentTerm, equalTo(newTerm));
}
}
Aggregations