Search in sources :

Example 11 with PutRepositoryResponse

use of org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse in project elasticsearch by elastic.

the class AzureSnapshotRestoreTests method checkContainerName.

/**
     * Create repository with wrong or correct container name
     * @param container Container name we want to create
     * @param correct Is this container name correct
     */
private void checkContainerName(final String container, final boolean correct) throws Exception {
    logger.info("-->  creating azure repository with container name [{}]", container);
    // It could happen that we just removed from a previous test the same container so
    // we can not create it yet.
    assertBusy(() -> {
        try {
            PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo").setType("azure").setSettings(Settings.builder().put(Repository.CONTAINER_SETTING.getKey(), container).put(Repository.BASE_PATH_SETTING.getKey(), getRepositoryPath()).put(Repository.CHUNK_SIZE_SETTING.getKey(), randomIntBetween(1000, 10000), ByteSizeUnit.BYTES)).get();
            client().admin().cluster().prepareDeleteRepository("test-repo").get();
            try {
                logger.info("--> remove container [{}]", container);
                cleanRepositoryFiles(container);
            } catch (StorageException | URISyntaxException e) {
            // We can ignore that as we just try to clean after the test
            }
            assertTrue(putRepositoryResponse.isAcknowledged() == correct);
        } catch (RepositoryVerificationException e) {
            if (correct) {
                logger.debug(" -> container is being removed. Let's wait a bit...");
                fail();
            }
        }
    }, 5, TimeUnit.MINUTES);
}
Also used : RepositoryVerificationException(org.elasticsearch.repositories.RepositoryVerificationException) PutRepositoryResponse(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse) URISyntaxException(java.net.URISyntaxException) StorageException(com.microsoft.azure.storage.StorageException)

Example 12 with PutRepositoryResponse

use of org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse in project elasticsearch by elastic.

the class IndicesOptionsIntegrationIT method testWildcardBehaviourSnapshotRestore.

public void testWildcardBehaviourSnapshotRestore() throws Exception {
    createIndex("foobar");
    ensureGreen("foobar");
    waitForRelocation();
    PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("dummy-repo").setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
    client().admin().cluster().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get();
    IndicesOptions options = IndicesOptions.fromOptions(false, false, true, false);
    verify(snapshot("snap2", "foo*", "bar*").setIndicesOptions(options), true);
    verify(restore("snap1", "foo*", "bar*").setIndicesOptions(options), true);
    options = IndicesOptions.strictExpandOpen();
    verify(snapshot("snap2", "foo*", "bar*").setIndicesOptions(options), false);
    verify(restore("snap2", "foo*", "bar*").setIndicesOptions(options), false);
    assertAcked(prepareCreate("barbaz"));
    //TODO: temporary work-around for #5531
    ensureGreen("barbaz");
    waitForRelocation();
    options = IndicesOptions.fromOptions(false, false, true, false);
    verify(snapshot("snap3", "foo*", "bar*").setIndicesOptions(options), false);
    verify(restore("snap3", "foo*", "bar*").setIndicesOptions(options), false);
    options = IndicesOptions.fromOptions(false, false, true, false);
    verify(snapshot("snap4", "foo*", "baz*").setIndicesOptions(options), true);
    verify(restore("snap3", "foo*", "baz*").setIndicesOptions(options), true);
}
Also used : PutRepositoryResponse(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse) IndicesOptions(org.elasticsearch.action.support.IndicesOptions)

Example 13 with PutRepositoryResponse

use of org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse in project elasticsearch by elastic.

the class BlobStoreRepositoryTests method setupRepo.

private BlobStoreRepository setupRepo() {
    final Client client = client();
    final Path location = ESIntegTestCase.randomRepoPath(node().settings());
    final String repositoryName = "test-repo";
    PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository(repositoryName).setType("fs").setSettings(Settings.builder().put(node().settings()).put("location", location)).get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
    final RepositoriesService repositoriesService = getInstanceFromNode(RepositoriesService.class);
    @SuppressWarnings("unchecked") final BlobStoreRepository repository = (BlobStoreRepository) repositoriesService.repository(repositoryName);
    return repository;
}
Also used : Path(java.nio.file.Path) RepositoriesService(org.elasticsearch.repositories.RepositoriesService) PutRepositoryResponse(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse) Client(org.elasticsearch.client.Client)

Example 14 with PutRepositoryResponse

use of org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse in project crate by crate.

the class SysSnapshotsTest method createRepository.

private void createRepository(String name) {
    PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository(name).setType("fs").setSettings(Settings.settingsBuilder().put("location", new File(TEMP_FOLDER.getRoot(), "backup").getAbsolutePath()).put("chunk_size", "5k").put("compress", false)).get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
}
Also used : PutRepositoryResponse(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse) File(java.io.File)

Example 15 with PutRepositoryResponse

use of org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse in project crate by crate.

the class SysRepositoriesServiceTest method createRepository.

private void createRepository(String name) {
    PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository(name).setType("fs").setSettings(Settings.settingsBuilder().put("location", new File(TEMP_FOLDER.getRoot(), "backup").getAbsolutePath()).put("chunk_size", "5k").put("compress", false)).get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
    repositories.add(name);
}
Also used : PutRepositoryResponse(org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse) File(java.io.File)

Aggregations

PutRepositoryResponse (org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse)36 Client (org.elasticsearch.client.Client)23 ClusterAdminClient (org.elasticsearch.client.ClusterAdminClient)14 CreateSnapshotResponse (org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse)12 RestoreSnapshotResponse (org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse)8 Settings (org.elasticsearch.common.settings.Settings)8 Path (java.nio.file.Path)7 ClusterState (org.elasticsearch.cluster.ClusterState)7 Matchers.containsString (org.hamcrest.Matchers.containsString)7 NodeClient (org.elasticsearch.client.node.NodeClient)4 ArrayList (java.util.ArrayList)3 SnapshotMissingException (org.elasticsearch.snapshots.SnapshotMissingException)3 File (java.io.File)2 IOException (java.io.IOException)2 List (java.util.List)2 GetSnapshotsResponse (org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse)2 SnapshotStatus (org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus)2 SnapshotsStatusResponse (org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse)2 IndicesOptions (org.elasticsearch.action.support.IndicesOptions)2 MetaData (org.elasticsearch.cluster.metadata.MetaData)2