当前位置: 首页>>代码示例>>Java>>正文


Java CreateSnapshotResponse类代码示例

本文整理汇总了Java中org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse的典型用法代码示例。如果您正苦于以下问题:Java CreateSnapshotResponse类的具体用法?Java CreateSnapshotResponse怎么用?Java CreateSnapshotResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CreateSnapshotResponse类属于org.elasticsearch.action.admin.cluster.snapshots.create包,在下文中一共展示了CreateSnapshotResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUnallocatedShards

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testUnallocatedShards() throws Exception {
    Client client = client();

    logger.info("-->  creating repository");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder()
                    .put("location", randomRepoPath())));

    logger.info("-->  creating index that cannot be allocated");
    prepareCreate("test-idx", 2, Settings.builder().put(IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + ".tag", "nowhere").put("index.number_of_shards", 3)).setWaitForActiveShards(ActiveShardCount.NONE).get();

    logger.info("--> snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.FAILED));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(3));
    assertThat(createSnapshotResponse.getSnapshotInfo().reason(), startsWith("Indices don't have primary shards"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:SharedClusterSnapshotRestoreIT.java

示例2: apply

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
@Override
public void apply(final String action, final ActionResponse response,
        @SuppressWarnings("rawtypes") final ActionListener listener,
        final ActionFilterChain chain) {
    if (!CreateSnapshotAction.NAME.equals(action) || !clusterService.state().nodes().localNodeMaster()) {
        chain.proceed(action, response, listener);
    } else {
        final CreateSnapshotResponse createSnapshotResponse = (CreateSnapshotResponse) response;
        final SnapshotInfo snapshotInfo = createSnapshotResponse
                .getSnapshotInfo();
        dictionarySnapshotService.createDictionarySnapshot(
                ((ActionListenerWrapper<?>) listener).getSnapshotId(),
                snapshotInfo, new ActionListener<Void>() {

                    @Override
                    public void onResponse(final Void resp) {
                        chain.proceed(action, response, listener);
                    }

                    @Override
                    public void onFailure(final Throwable e) {
                        listener.onFailure(e);
                    }
                });
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-dictionary,代码行数:27,代码来源:CreateSnapshotActionFilter.java

示例3: testSingleGetAfterRestore

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testSingleGetAfterRestore() throws Exception {
    String indexName = "testindex";
    String repoName = "test-restore-snapshot-repo";
    String snapshotName = "test-restore-snapshot";
    String absolutePath = randomRepoPath().toAbsolutePath().toString();
    logger.info("Path [{}]", absolutePath);
    String restoredIndexName = indexName + "-restored";
    String typeName = "actions";
    String expectedValue = "expected";

    Client client = client();
    // Write a document
    String docId = Integer.toString(randomInt());
    index(indexName, typeName, docId, "value", expectedValue);

    logger.info("-->  creating repository");
    assertAcked(client.admin().cluster().preparePutRepository(repoName)
            .setType("fs").setSettings(Settings.builder()
                    .put("location", absolutePath)
                    ));

    logger.info("--> snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repoName, snapshotName)
            .setWaitForCompletion(true)
            .setIndices(indexName)
            .get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
    assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));

    RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot(repoName, snapshotName)
            .setWaitForCompletion(true)
            .setRenamePattern(indexName)
            .setRenameReplacement(restoredIndexName)
            .get();
    assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));

    assertThat(client.prepareGet(restoredIndexName, typeName, docId).get().isExists(), equalTo(true));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:40,代码来源:SharedClusterSnapshotRestoreIT.java

示例4: testFreshIndexUUID

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testFreshIndexUUID() {
    Client client = client();

    logger.info("-->  creating repository");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder()
                    .put("location", randomRepoPath())
                    .put("compress", randomBoolean())
                    .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)));

    createIndex("test");
    String originalIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
    assertTrue(originalIndexUUID, originalIndexUUID != null);
    assertFalse(originalIndexUUID, originalIndexUUID.equals(IndexMetaData.INDEX_UUID_NA_VALUE));
    ensureGreen();
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
    NumShards numShards = getNumShards("test");

    cluster().wipeIndices("test");
    assertAcked(prepareCreate("test").setSettings(Settings.builder()
            .put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries)));
    ensureGreen();
    String newIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
    assertTrue(newIndexUUID, newIndexUUID != null);
    assertFalse(newIndexUUID, newIndexUUID.equals(IndexMetaData.INDEX_UUID_NA_VALUE));
    assertFalse(newIndexUUID, newIndexUUID.equals(originalIndexUUID));
    logger.info("--> close index");
    client.admin().indices().prepareClose("test").get();

    logger.info("--> restore all indices from the snapshot");
    RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
    assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));

    ensureGreen();
    String newAfterRestoreIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
    assertTrue("UUID has changed after restore: " + newIndexUUID + " vs. " + newAfterRestoreIndexUUID, newIndexUUID.equals(newAfterRestoreIndexUUID));

    logger.info("--> restore indices with different names");
    restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
            .setRenamePattern("(.+)").setRenameReplacement("$1-copy").setWaitForCompletion(true).execute().actionGet();
    assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));

    String copyRestoreUUID = client().admin().indices().prepareGetSettings("test-copy").get().getSetting("test-copy", IndexMetaData.SETTING_INDEX_UUID);
    assertFalse("UUID has been reused on restore: " + copyRestoreUUID + " vs. " + originalIndexUUID, copyRestoreUUID.equals(originalIndexUUID));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:48,代码来源:SharedClusterSnapshotRestoreIT.java

示例5: testEmptySnapshot

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testEmptySnapshot() throws Exception {
    Client client = client();

    logger.info("-->  creating repository");
    PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));

    logger.info("--> snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).get();
    assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));

    assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:SharedClusterSnapshotRestoreIT.java

示例6: testDataFileFailureDuringRestore

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testDataFileFailureDuringRestore() throws Exception {
    Path repositoryLocation = randomRepoPath();
    Client client = client();
    logger.info("-->  creating repository");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));

    prepareCreate("test-idx").setSettings(Settings.builder().put("index.allocation.max_retries", Integer.MAX_VALUE)).get();
    ensureGreen();

    logger.info("--> indexing some data");
    for (int i = 0; i < 100; i++) {
        index("test-idx", "doc", Integer.toString(i), "foo", "bar" + i);
    }
    refresh();
    assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));

    logger.info("--> snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
    assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));

    logger.info("-->  update repository with mock version");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("mock").setSettings(
                    Settings.builder()
                            .put("location", repositoryLocation)
                            .put("random", randomAsciiOfLength(10))
                            .put("random_data_file_io_exception_rate", 0.3)));

    // Test restore after index deletion
    logger.info("--> delete index");
    cluster().wipeIndices("test-idx");
    logger.info("--> restore index after deletion");
    RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
    assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
    SearchResponse countResponse = client.prepareSearch("test-idx").setSize(0).get();
    assertThat(countResponse.getHits().getTotalHits(), equalTo(100L));
    logger.info("--> total number of simulated failures during restore: [{}]", getFailureCount("test-repo"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:SharedClusterSnapshotRestoreIT.java

示例7: testDataFileCorruptionDuringRestore

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testDataFileCorruptionDuringRestore() throws Exception {
    Path repositoryLocation = randomRepoPath();
    Client client = client();
    logger.info("-->  creating repository");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
        .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));

    createIndex("test-idx");
    ensureGreen();

    logger.info("--> indexing some data");
    for (int i = 0; i < 100; i++) {
        index("test-idx", "doc", Integer.toString(i), "foo", "bar" + i);
    }
    refresh();
    assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));

    logger.info("--> snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
    assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));

    logger.info("-->  update repository with mock version");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
        .setType("mock").setSettings(
            Settings.builder()
                .put("location", repositoryLocation)
                .put("random", randomAsciiOfLength(10))
                .put("use_lucene_corruption", true)
                .put("max_failure_number", 10000000L)
                .put("random_data_file_io_exception_rate", 1.0)));

    // Test restore after index deletion
    logger.info("--> delete index");
    cluster().wipeIndices("test-idx");
    logger.info("--> restore corrupt index");
    RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
    assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
    assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:41,代码来源:SharedClusterSnapshotRestoreIT.java

示例8: testDeleteSnapshotWithMissingIndexAndShardMetadata

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testDeleteSnapshotWithMissingIndexAndShardMetadata() throws Exception {
    Client client = client();

    Path repo = randomRepoPath();
    logger.info("-->  creating repository at {}", repo.toAbsolutePath());
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder()
                    .put("location", repo)
                    .put("compress", false)
                    .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)));

    createIndex("test-idx-1", "test-idx-2");
    logger.info("--> indexing some data");
    indexRandom(true,
            client().prepareIndex("test-idx-1", "doc").setSource("foo", "bar"),
            client().prepareIndex("test-idx-2", "doc").setSource("foo", "bar"));

    logger.info("--> creating snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));

    logger.info("--> delete index metadata and shard metadata");
    Path indices = repo.resolve("indices");
    Path testIndex1 = indices.resolve("test-idx-1");
    Path testIndex2 = indices.resolve("test-idx-2");
    Path testIndex2Shard0 = testIndex2.resolve("0");
    IOUtils.deleteFilesIgnoringExceptions(testIndex1.resolve("snapshot-test-snap-1"));
    IOUtils.deleteFilesIgnoringExceptions(testIndex2Shard0.resolve("snapshot-test-snap-1"));

    logger.info("--> delete snapshot");
    client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get();

    logger.info("--> make sure snapshot doesn't exist");
    assertThrows(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap-1"), SnapshotMissingException.class);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:SharedClusterSnapshotRestoreIT.java

示例9: testDeleteSnapshotWithMissingMetadata

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testDeleteSnapshotWithMissingMetadata() throws Exception {
    Client client = client();

    Path repo = randomRepoPath();
    logger.info("-->  creating repository at {}", repo.toAbsolutePath());
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder()
                    .put("location", repo)
                    .put("compress", false)
                    .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)));

    createIndex("test-idx-1", "test-idx-2");
    logger.info("--> indexing some data");
    indexRandom(true,
            client().prepareIndex("test-idx-1", "doc").setSource("foo", "bar"),
            client().prepareIndex("test-idx-2", "doc").setSource("foo", "bar"));

    logger.info("--> creating snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));

    logger.info("--> delete index metadata and shard metadata");
    Path metadata = repo.resolve("meta-" + createSnapshotResponse.getSnapshotInfo().snapshotId().getUUID() + ".dat");
    Files.delete(metadata);

    logger.info("--> delete snapshot");
    client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get();

    logger.info("--> make sure snapshot doesn't exist");
    assertThrows(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap-1"), SnapshotMissingException.class);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:33,代码来源:SharedClusterSnapshotRestoreIT.java

示例10: testDeleteSnapshotWithCorruptedSnapshotFile

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testDeleteSnapshotWithCorruptedSnapshotFile() throws Exception {
    Client client = client();

    Path repo = randomRepoPath();
    logger.info("-->  creating repository at {}", repo.toAbsolutePath());
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder()
                    .put("location", repo)
                    .put("compress", false)
                    .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)));

    createIndex("test-idx-1", "test-idx-2");
    logger.info("--> indexing some data");
    indexRandom(true,
            client().prepareIndex("test-idx-1", "doc").setSource("foo", "bar"),
            client().prepareIndex("test-idx-2", "doc").setSource("foo", "bar"));

    logger.info("--> creating snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));

    logger.info("--> truncate snapshot file to make it unreadable");
    Path snapshotPath = repo.resolve("snap-" + createSnapshotResponse.getSnapshotInfo().snapshotId().getUUID() + ".dat");
    try(SeekableByteChannel outChan = Files.newByteChannel(snapshotPath, StandardOpenOption.WRITE)) {
        outChan.truncate(randomInt(10));
    }
    logger.info("--> delete snapshot");
    client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get();

    logger.info("--> make sure snapshot doesn't exist");
    assertThrows(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap-1"), SnapshotMissingException.class);

    logger.info("--> make sure that we can create the snapshot again");
    createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:39,代码来源:SharedClusterSnapshotRestoreIT.java

示例11: testSnapshotWithMissingShardLevelIndexFile

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testSnapshotWithMissingShardLevelIndexFile() throws Exception {
    Path repo = randomRepoPath();
    logger.info("-->  creating repository at {}", repo.toAbsolutePath());
    assertAcked(client().admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(
        Settings.builder().put("location", repo).put("compress", false)));

    createIndex("test-idx-1", "test-idx-2");
    logger.info("--> indexing some data");
    indexRandom(true,
        client().prepareIndex("test-idx-1", "doc").setSource("foo", "bar"),
        client().prepareIndex("test-idx-2", "doc").setSource("foo", "bar"));

    logger.info("--> creating snapshot");
    client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1")
        .setWaitForCompletion(true).setIndices("test-idx-*").get();

    logger.info("--> deleting shard level index file");
    try (Stream<Path> files = Files.list(repo.resolve("indices"))) {
        files.forEach(indexPath ->
            IOUtils.deleteFilesIgnoringExceptions(indexPath.resolve("0").resolve("index-0"))
        );
    }

    logger.info("--> creating another snapshot");
    CreateSnapshotResponse createSnapshotResponse =
        client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-2")
            .setWaitForCompletion(true).setIndices("test-idx-1").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertEquals(createSnapshotResponse.getSnapshotInfo().successfulShards(), createSnapshotResponse.getSnapshotInfo().totalShards());

    logger.info("--> restoring the first snapshot, the repository should not have lost any shard data despite deleting index-N, " +
                    "because it should have iterated over the snap-*.data files as backup");
    client().admin().indices().prepareDelete("test-idx-1", "test-idx-2").get();
    RestoreSnapshotResponse restoreSnapshotResponse =
        client().admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).get();
    assertEquals(0, restoreSnapshotResponse.getRestoreInfo().failedShards());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:38,代码来源:SharedClusterSnapshotRestoreIT.java

示例12: testSnapshotClosedIndex

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testSnapshotClosedIndex() throws Exception {
    Client client = client();

    logger.info("-->  creating repository");
    assertAcked(client.admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder()
                    .put("location", randomRepoPath())));

    createIndex("test-idx", "test-idx-closed");
    ensureGreen();
    logger.info("-->  closing index test-idx-closed");
    assertAcked(client.admin().indices().prepareClose("test-idx-closed"));
    ClusterStateResponse stateResponse = client.admin().cluster().prepareState().get();
    assertThat(stateResponse.getState().metaData().index("test-idx-closed").getState(), equalTo(IndexMetaData.State.CLOSE));
    assertThat(stateResponse.getState().routingTable().index("test-idx-closed"), nullValue());

    logger.info("--> snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx*").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().indices().size(), equalTo(1));
    assertThat(createSnapshotResponse.getSnapshotInfo().shardFailures().size(), equalTo(0));

    logger.info("-->  deleting snapshot");
    client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap").get();

    logger.info("--> snapshot with closed index");
    assertBlocked(client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx", "test-idx-closed"), MetaDataIndexStateService.INDEX_CLOSED_BLOCK);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:28,代码来源:SharedClusterSnapshotRestoreIT.java

示例13: setUpRepository

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
@Before
protected void setUpRepository() throws Exception {
    createIndex(INDEX_NAME, OTHER_INDEX_NAME);

    int docs = between(10, 100);
    for (int i = 0; i < docs; i++) {
        client().prepareIndex(INDEX_NAME, "type").setSource("test", "init").execute().actionGet();
    }
    docs = between(10, 100);
    for (int i = 0; i < docs; i++) {
        client().prepareIndex(OTHER_INDEX_NAME, "type").setSource("test", "init").execute().actionGet();
    }


    logger.info("--> register a repository");
    assertAcked(client().admin().cluster().preparePutRepository(REPOSITORY_NAME)
            .setType("fs")
            .setSettings(Settings.builder().put("location",  randomRepoPath())));

    logger.info("--> verify the repository");
    VerifyRepositoryResponse verifyResponse = client().admin().cluster().prepareVerifyRepository(REPOSITORY_NAME).get();
    assertThat(verifyResponse.getNodes().length, equalTo(cluster().numDataAndMasterNodes()));

    logger.info("--> create a snapshot");
    CreateSnapshotResponse snapshotResponse = client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, SNAPSHOT_NAME)
                                                                        .setIncludeGlobalState(true)
                                                                        .setWaitForCompletion(true)
                                                                        .execute().actionGet();
    assertThat(snapshotResponse.status(), equalTo(RestStatus.OK));
    ensureSearchable();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:SnapshotBlocksIT.java

示例14: testCreateSnapshotWithBlocks

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void testCreateSnapshotWithBlocks() {
    logger.info("-->  creating a snapshot is allowed when the cluster is read only");
    try {
        setClusterReadOnly(true);
        assertThat(client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-1").setWaitForCompletion(true).get().status(), equalTo(RestStatus.OK));
    } finally {
        setClusterReadOnly(false);
    }

    logger.info("-->  creating a snapshot is allowed when the cluster is not read only");
    CreateSnapshotResponse response = client().admin().cluster().prepareCreateSnapshot(REPOSITORY_NAME, "snapshot-2")
            .setWaitForCompletion(true)
            .execute().actionGet();
    assertThat(response.status(), equalTo(RestStatus.OK));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:SnapshotBlocksIT.java

示例15: assertRepositoryIsOperational

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
private void assertRepositoryIsOperational(Client client, String repository) {
    createIndex("test-idx-1");
    ensureGreen();

    logger.info("--> indexing some data");
    for (int i = 0; i < 100; i++) {
        index("test-idx-1", "doc", Integer.toString(i), "foo", "bar" + i);
    }
    refresh();
    assertThat(client.prepareSearch("test-idx-1").setSize(0).get().getHits().getTotalHits(), equalTo(100L));

    logger.info("--> snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repository, "test-snap").setWaitForCompletion(true).setIndices("test-idx-*").get();
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
    assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));

    assertThat(client.admin().cluster().prepareGetSnapshots(repository).setSnapshots("test-snap").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));

    logger.info("--> delete some data");
    for (int i = 0; i < 50; i++) {
        client.prepareDelete("test-idx-1", "doc", Integer.toString(i)).get();
    }
    refresh();
    assertThat(client.prepareSearch("test-idx-1").setSize(0).get().getHits().getTotalHits(), equalTo(50L));

    logger.info("--> close indices");
    client.admin().indices().prepareClose("test-idx-1").get();

    logger.info("--> restore all indices from the snapshot");
    RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot(repository, "test-snap").setWaitForCompletion(true).execute().actionGet();
    assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));

    ensureGreen();
    assertThat(client.prepareSearch("test-idx-1").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:AbstractS3SnapshotRestoreTest.java


注:本文中的org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。