use of org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotRequestConverters method cleanupRepository.
static Request cleanupRepository(CleanupRepositoryRequest cleanupRepositoryRequest) {
String endpoint = new RequestConverters.EndpointBuilder().addPathPartAsIs("_snapshot").addPathPart(cleanupRepositoryRequest.name()).addPathPartAsIs("_cleanup").build();
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withMasterTimeout(cleanupRepositoryRequest.masterNodeTimeout());
parameters.withTimeout(cleanupRepositoryRequest.timeout());
request.addParameters(parameters.asMap());
return request;
}
use of org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotIT method testCleanupRepository.
public void testCleanupRepository() throws IOException {
AcknowledgedResponse putRepositoryResponse = createTestRepository("test", FsRepository.TYPE, "{\"location\": \".\"}");
assertTrue(putRepositoryResponse.isAcknowledged());
CleanupRepositoryRequest request = new CleanupRepositoryRequest("test");
CleanupRepositoryResponse response = execute(request, highLevelClient().snapshot()::cleanupRepository, highLevelClient().snapshot()::cleanupRepositoryAsync);
assertThat(response.result().bytes(), equalTo(0L));
assertThat(response.result().blobs(), equalTo(0L));
}
use of org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest in project OpenSearch by opensearch-project.
the class SnapshotResiliencyTests method verifyReposThenStopServices.
@After
public void verifyReposThenStopServices() {
try {
clearDisruptionsAndAwaitSync();
final StepListener<CleanupRepositoryResponse> cleanupResponse = new StepListener<>();
final StepListener<CreateSnapshotResponse> createSnapshotResponse = new StepListener<>();
// Create another snapshot and then clean up the repository to verify that the repository works correctly no matter the
// failures seen during the previous test.
client().admin().cluster().prepareCreateSnapshot("repo", "last-snapshot").setWaitForCompletion(true).setPartial(true).execute(createSnapshotResponse);
continueOrDie(createSnapshotResponse, r -> {
final SnapshotInfo snapshotInfo = r.getSnapshotInfo();
// Snapshot can be partial because some tests leave indices in a red state because data nodes were stopped
assertThat(snapshotInfo.state(), either(is(SnapshotState.SUCCESS)).or(is(SnapshotState.PARTIAL)));
assertThat(snapshotInfo.shardFailures(), iterableWithSize(snapshotInfo.failedShards()));
assertThat(snapshotInfo.successfulShards(), is(snapshotInfo.totalShards() - snapshotInfo.failedShards()));
client().admin().cluster().cleanupRepository(new CleanupRepositoryRequest("repo"), cleanupResponse);
});
final AtomicBoolean cleanedUp = new AtomicBoolean(false);
continueOrDie(cleanupResponse, r -> cleanedUp.set(true));
runUntil(cleanedUp::get, TimeUnit.MINUTES.toMillis(1L));
if (blobStoreContext != null) {
blobStoreContext.forceConsistent();
}
BlobStoreTestUtil.assertConsistency((BlobStoreRepository) testClusterNodes.randomMasterNodeSafe().repositoriesService.repository("repo"), Runnable::run);
} finally {
testClusterNodes.nodes.values().forEach(TestClusterNodes.TestClusterNode::stop);
}
}
use of org.opensearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest in project OpenSearch by opensearch-project.
the class RestCleanupRepositoryAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
CleanupRepositoryRequest cleanupRepositoryRequest = cleanupRepositoryRequest(request.param("repository"));
cleanupRepositoryRequest.timeout(request.paramAsTime("timeout", cleanupRepositoryRequest.timeout()));
cleanupRepositoryRequest.masterNodeTimeout(request.paramAsTime("master_timeout", cleanupRepositoryRequest.masterNodeTimeout()));
return channel -> client.admin().cluster().cleanupRepository(cleanupRepositoryRequest, new RestToXContentListener<>(channel));
}
Aggregations