• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CreateSnapshotResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: handleRequest

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    CreateSnapshotRequest createSnapshotRequest = createSnapshotRequest(request.param("repository"), request.param("snapshot"));
    createSnapshotRequest.source(request.content().toUtf8());
    createSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", createSnapshotRequest.masterNodeTimeout()));
    createSnapshotRequest.waitForCompletion(request.paramAsBoolean("wait_for_completion", false));
    client.admin().cluster().createSnapshot(createSnapshotRequest, new RestToXContentListener<CreateSnapshotResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:RestCreateSnapshotAction.java


示例17: postSnapshot

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
@Post("")
@Post("/")
public Payload postSnapshot(Context context) {

	checkSnapshotAllOrSuperdog();
	ElasticSnapshot snapshot = ElasticSnapshot.prepareSnapshot();

	// TODO rename correctly the snapshot repository
	CreateSnapshotResponse response = elastic().cluster()//
			.prepareCreateSnapshot(snapshot.repositoryId(), snapshot.id())//
			.setIndicesOptions(IndicesOptions.fromOptions(true, true, true, true))//
			.setWaitForCompletion(context.query().getBoolean(PARAM_WAIT_FOR_COMPLETION, false))//
			.setIncludeGlobalState(true)//
			.setPartial(false)//
			.get();

	int status = response.status().getStatus();

	// fix elastic small incoherence in snapshot creation status
	if (status == 200)
		status = 201;

	JsonBuilder<ObjectNode> payload = JsonPayload.builder(status)//
			.put("id", snapshot.id())//
			.put("location", spaceUrl(Backends.rootApi(), "/1", //
					"snapshot", snapshot.id()).toString());

	if (response.getSnapshotInfo() != null) {
		snapshot.info(response.getSnapshotInfo());
		payload.node("snapshot", snapshot.toJson());
	}

	return JsonPayload.json(payload, status);
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:35,代码来源:SnapshotResource.java


示例18: createNewSnapshot

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
private void createNewSnapshot() {
	logger.info("Started snapshot for index(es): {} ", this.snapshotSettings.getIndices());
	String snapshotName = DATE_FORMAT.format(new Date());
	CreateSnapshotRequestBuilder createBuilder = getCreateSnapshotBuilder(snapshotName);
	CreateSnapshotResponse createResp = createBuilder.get();
	if (createResp.getSnapshotInfo() != null && (createResp.getSnapshotInfo().state() == SnapshotState.SUCCESS)) {
		logger.info("Snapshot [{}] created.", snapshotName);
	} else {
		// TODO: Is this the right way to do this?
		throw ExceptionsHelper.convertToElastic(new Exception("Unable to create snapshot " + snapshotName));
	}
}
 
开发者ID:garmin,项目名称:elasticsearch-river-snapshot,代码行数:13,代码来源:SnapshotsExecutor.java


示例19: runSnapshotBackup

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse; //导入依赖的package包/类
public void runSnapshotBackup() throws Exception {
    // Create or Get Repository
    String repositoryName = repository.createOrGetSnapshotRepository();

    // StartBackup
    String snapshotName = getSnapshotName(config.getCommaSeparatedIndicesToBackup(), config.includeIndexNameInSnapshot());
    logger.info("Repository Name : <" + repositoryName + "> Snapshot Name : <" + snapshotName + "> Indices : <" + config.getCommaSeparatedIndicesToBackup() + "> \nRunning Snapshot now ... ");

    Client esTransportClient = ElasticsearchTransportClient.instance(config).getTransportClient();

    Stopwatch snapshotTimer = snapshotDuration.start();
    //This is a blocking call. It'll wait until Snapshot is finished.
    CreateSnapshotResponse createSnapshotResponse = getCreateSnapshotResponse(esTransportClient, repositoryName, snapshotName);

    logger.info("Snapshot Status = " + createSnapshotResponse.status().toString());
    if (createSnapshotResponse.status() == RestStatus.OK) {
        //TODO Add Servo Monitoring so that it can be verified from dashboard
        printSnapshotDetails(createSnapshotResponse);
        snapshotSuccess.incrementAndGet();
    } else if (createSnapshotResponse.status() == RestStatus.INTERNAL_SERVER_ERROR) {
        //TODO Add Servo Monitoring so that it can be verified from dashboard
        logger.info("Snapshot Completely Failed");
        snapshotFailure.incrementAndGet();
    }
    //Stop the timer
    snapshotTimer.stop();
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:28,代码来源:SnapshotBackupManager.java


示例20: printSnapshotDetails

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExecUtil类代码示例发布时间:2022-05-22
下一篇:
Java FastTaxonomyFacetCounts类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap