Search in sources :

Example 6 with GetRepositoriesResponse

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse in project OpenSearch by opensearch-project.

the class RestRepositoriesAction method doCatRequest.

@Override
protected RestChannelConsumer doCatRequest(RestRequest request, NodeClient client) {
    GetRepositoriesRequest getRepositoriesRequest = new GetRepositoriesRequest();
    getRepositoriesRequest.local(request.paramAsBoolean("local", getRepositoriesRequest.local()));
    getRepositoriesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getRepositoriesRequest.masterNodeTimeout()));
    return channel -> client.admin().cluster().getRepositories(getRepositoriesRequest, new RestResponseListener<GetRepositoriesResponse>(channel) {

        @Override
        public RestResponse buildResponse(GetRepositoriesResponse getRepositoriesResponse) throws Exception {
            return RestTable.buildResponse(buildTable(request, getRepositoriesResponse), channel);
        }
    });
}
Also used : List(java.util.List) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) NodeClient(org.opensearch.client.node.NodeClient) GET(org.opensearch.rest.RestRequest.Method.GET) RestRequest(org.opensearch.rest.RestRequest) RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) Table(org.opensearch.common.Table) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse) RestResponse(org.opensearch.rest.RestResponse) RestResponseListener(org.opensearch.rest.action.RestResponseListener) Collections.singletonList(java.util.Collections.singletonList) RestResponse(org.opensearch.rest.RestResponse) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Example 7 with GetRepositoriesResponse

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse in project OpenSearch by opensearch-project.

the class SnapshotIT method testSnapshotDeleteRepository.

public void testSnapshotDeleteRepository() throws IOException {
    String repository = "test";
    assertTrue(createTestRepository(repository, FsRepository.TYPE, "{\"location\": \".\"}").isAcknowledged());
    GetRepositoriesRequest request = new GetRepositoriesRequest();
    GetRepositoriesResponse response = execute(request, highLevelClient().snapshot()::getRepository, highLevelClient().snapshot()::getRepositoryAsync);
    assertThat(1, equalTo(response.repositories().size()));
    DeleteRepositoryRequest deleteRequest = new DeleteRepositoryRequest(repository);
    AcknowledgedResponse deleteResponse = execute(deleteRequest, highLevelClient().snapshot()::deleteRepository, highLevelClient().snapshot()::deleteRepositoryAsync);
    assertTrue(deleteResponse.isAcknowledged());
}
Also used : DeleteRepositoryRequest(org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest) AcknowledgedResponse(org.opensearch.action.support.master.AcknowledgedResponse) GetRepositoriesRequest(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest) GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Example 8 with GetRepositoriesResponse

use of org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse in project OpenSearch by opensearch-project.

the class RepositoryBlocksIT method testGetRepositoryWithBlocks.

public void testGetRepositoryWithBlocks() {
    assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks").setType("fs").setVerify(false).setSettings(Settings.builder().put("location", randomRepoPath())));
    // This test checks that the Get Repository operation is never blocked, even if the cluster is read only.
    try {
        setClusterReadOnly(true);
        GetRepositoriesResponse response = client().admin().cluster().prepareGetRepositories("test-repo-blocks").execute().actionGet();
        assertThat(response.repositories(), hasSize(1));
    } finally {
        setClusterReadOnly(false);
    }
}
Also used : GetRepositoriesResponse(org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)

Aggregations

GetRepositoriesResponse (org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesResponse)8 GetRepositoriesRequest (org.opensearch.action.admin.cluster.repositories.get.GetRepositoriesRequest)5 RepositoryMetadata (org.opensearch.cluster.metadata.RepositoryMetadata)4 Client (org.opensearch.client.Client)2 Path (java.nio.file.Path)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 DeleteRepositoryRequest (org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest)1 VerifyRepositoryResponse (org.opensearch.action.admin.cluster.repositories.verify.VerifyRepositoryResponse)1 ClusterStateResponse (org.opensearch.action.admin.cluster.state.ClusterStateResponse)1 AcknowledgedResponse (org.opensearch.action.support.master.AcknowledgedResponse)1 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)1 NodeClient (org.opensearch.client.node.NodeClient)1 Metadata (org.opensearch.cluster.metadata.Metadata)1 RepositoriesMetadata (org.opensearch.cluster.metadata.RepositoriesMetadata)1 Table (org.opensearch.common.Table)1 Settings (org.opensearch.common.settings.Settings)1 FsRepository (org.opensearch.repositories.fs.FsRepository)1 RestRequest (org.opensearch.rest.RestRequest)1