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


Java CreateSnapshotRequest类代码示例

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


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

示例1: prepareRequest

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    CreateSnapshotRequest createSnapshotRequest = createSnapshotRequest(request.param("repository"), request.param("snapshot"));
    request.applyContentParser(p -> createSnapshotRequest.source(p.mapOrdered()));
    createSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", createSnapshotRequest.masterNodeTimeout()));
    createSnapshotRequest.waitForCompletion(request.paramAsBoolean("wait_for_completion", false));
    return channel -> client.admin().cluster().createSnapshot(createSnapshotRequest, new RestToXContentListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:RestCreateSnapshotAction.java

示例2: handleRequest

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的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

示例3: apply

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
@Override
public void apply(final Task task, final String action,
        @SuppressWarnings("rawtypes") final ActionRequest request,
        @SuppressWarnings("rawtypes") final ActionListener listener,
        final ActionFilterChain chain) {
    if (!CreateSnapshotAction.NAME.equals(action)) {
        chain.proceed(task, action, request, listener);
    } else {
        final CreateSnapshotRequest createSnapshotRequest = (CreateSnapshotRequest) request;
        chain.proceed(task, action, request, new ActionListenerWrapper<>(
                listener, new SnapshotId(
                        createSnapshotRequest.repository(),
                        createSnapshotRequest.snapshot())));
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-dictionary,代码行数:16,代码来源:CreateSnapshotActionFilter.java

示例4: createSnapshot

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
@Override
public ActionFuture<CreateSnapshotResponse> createSnapshot(CreateSnapshotRequest request) {
    return execute(CreateSnapshotAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java

示例5: testCreateSnapshotRequestParsing

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
public void testCreateSnapshotRequestParsing() throws IOException {
    CreateSnapshotRequest request = new CreateSnapshotRequest("test-repo", "test-snap");

    XContentBuilder builder = jsonBuilder().startObject();

    if(randomBoolean()) {
        builder.field("indices", "foo,bar,baz");
    } else {
        builder.startArray("indices");
        builder.value("foo");
        builder.value("bar");
        builder.value("baz");
        builder.endArray();
    }

    IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
    if (indicesOptions.expandWildcardsClosed()) {
        if (indicesOptions.expandWildcardsOpen()) {
            builder.field("expand_wildcards", "all");
        } else {
            builder.field("expand_wildcards", "closed");
        }
    } else {
        if (indicesOptions.expandWildcardsOpen()) {
            builder.field("expand_wildcards", "open");
        } else {
            builder.field("expand_wildcards", "none");
        }
    }
    builder.field("allow_no_indices", indicesOptions.allowNoIndices());
    boolean partial = randomBoolean();
    builder.field("partial", partial);
    builder.startObject("settings").field("set1", "val1").endObject();
    builder.startObject("index_settings").field("set1", "val2").endObject();
    if (randomBoolean()) {
        builder.field("ignore_index_settings", "set2,set3");
    } else {
        builder.startArray("ignore_index_settings");
        builder.value("set2");
        builder.value("set3");
        builder.endArray();
    }

    BytesReference bytes = builder.endObject().bytes();

    request.source(XContentHelper.convertToMap(bytes, true, builder.contentType()).v2());

    assertEquals("test-repo", request.repository());
    assertEquals("test-snap", request.snapshot());
    assertArrayEquals(request.indices(), new String[]{"foo", "bar", "baz"});
    assertEquals(partial, request.partial());
    assertEquals("val1", request.settings().get("set1"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:54,代码来源:SnapshotRequestsTests.java

示例6: testCreateSnapshotRequestDescrptions

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
public void testCreateSnapshotRequestDescrptions() {
    CreateSnapshotRequest createSnapshotRequest = new CreateSnapshotRequest();
    createSnapshotRequest.snapshot("snapshot_name");
    createSnapshotRequest.repository("repo_name");
    assertEquals("snapshot [repo_name:snapshot_name]", createSnapshotRequest.getDescription());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:SnapshotTests.java

示例7: testSnapshot

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
@Test
public void testSnapshot() throws Exception {

    final Settings settings = Settings.builder()
            .putList("path.repo", repositoryPath.getRoot().getAbsolutePath())
            .put("searchguard.enable_snapshot_restore_privilege", true)
            .put("searchguard.check_snapshot_restore_write_privileges", false)
            .build();

    setup(settings);

    try (TransportClient tc = getInternalTransportClient()) {    
        tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
            
        tc.admin().cluster().putRepository(new PutRepositoryRequest("vulcangov").type("fs").settings(Settings.builder().put("location", repositoryPath.getRoot().getAbsolutePath() + "/vulcangov"))).actionGet();
        tc.admin().cluster().createSnapshot(new CreateSnapshotRequest("vulcangov", "vulcangov_1").indices("vulcangov").includeGlobalState(true).waitForCompletion(true)).actionGet();

        tc.admin().cluster().putRepository(new PutRepositoryRequest("searchguard").type("fs").settings(Settings.builder().put("location", repositoryPath.getRoot().getAbsolutePath() + "/searchguard"))).actionGet();
        tc.admin().cluster().createSnapshot(new CreateSnapshotRequest("searchguard", "searchguard_1").indices("searchguard").includeGlobalState(false).waitForCompletion(true)).actionGet();

        tc.admin().cluster().putRepository(new PutRepositoryRequest("all").type("fs").settings(Settings.builder().put("location", repositoryPath.getRoot().getAbsolutePath() + "/all"))).actionGet();
        tc.admin().cluster().createSnapshot(new CreateSnapshotRequest("all", "all_1").indices("*").includeGlobalState(false).waitForCompletion(true)).actionGet();
    }

    RestHelper rh = nonSslRestHelper();
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/vulcangov", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/vulcangov/vulcangov_1", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"restored_index_$1\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"include_global_state\": true, \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"restored_index_with_global_state_$1\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","", encodeBasicHeader("worf", "worf")).getStatusCode());
    // Try to restore vulcangov index as searchguard index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"indices\": \"vulcangov\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());

    // Try to restore searchguard index.
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/searchguard", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/searchguard/searchguard_1", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/searchguard/searchguard_1/_restore?wait_for_completion=true","", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    // Try to restore searchguard index as serchguard_copy index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/searchguard/searchguard_1/_restore?wait_for_completion=true","{ \"indices\": \"searchguard\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard_copy\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());

    // Try to restore all indices.
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/all", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/all/all_1", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/all_1/_restore?wait_for_completion=true","", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    // Try to restore searchguard index as serchguard_copy index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/all_1/_restore?wait_for_completion=true","{ \"indices\": \"vulcangov\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    // Try to restore searchguard index as serchguard_copy index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/all_1/_restore?wait_for_completion=true","{ \"indices\": \"searchguard\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard_copy\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());

    // Try to restore a unknown snapshot
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/unknown-snapshot/_restore?wait_for_completion=true", "", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    // Assert.assertEquals(HttpStatus.SC_FORBIDDEN, executePostRequest("_snapshot/all/unknown-snapshot/_restore?wait_for_completion=true","{ \"indices\": \"the-unknown-index\" }", encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:54,代码来源:IntegrationTests.java

示例8: testSnapshotCheckWritePrivileges

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
@Test
public void testSnapshotCheckWritePrivileges() throws Exception {

    final Settings settings = Settings.builder()
            .putList("path.repo", repositoryPath.getRoot().getAbsolutePath())
            .put("searchguard.enable_snapshot_restore_privilege", true)
            .put("searchguard.check_snapshot_restore_write_privileges", true)
            .build();

    setup(settings);

    try (TransportClient tc = getInternalTransportClient()) {
        tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
        
        tc.admin().cluster().putRepository(new PutRepositoryRequest("vulcangov").type("fs").settings(Settings.builder().put("location", repositoryPath.getRoot().getAbsolutePath() + "/vulcangov"))).actionGet();
        tc.admin().cluster().createSnapshot(new CreateSnapshotRequest("vulcangov", "vulcangov_1").indices("vulcangov").includeGlobalState(true).waitForCompletion(true)).actionGet();

        tc.admin().cluster().putRepository(new PutRepositoryRequest("searchguard").type("fs").settings(Settings.builder().put("location", repositoryPath.getRoot().getAbsolutePath() + "/searchguard"))).actionGet();
        tc.admin().cluster().createSnapshot(new CreateSnapshotRequest("searchguard", "searchguard_1").indices("searchguard").includeGlobalState(false).waitForCompletion(true)).actionGet();

        tc.admin().cluster().putRepository(new PutRepositoryRequest("all").type("fs").settings(Settings.builder().put("location", repositoryPath.getRoot().getAbsolutePath() + "/all"))).actionGet();
        tc.admin().cluster().createSnapshot(new CreateSnapshotRequest("all", "all_1").indices("*").includeGlobalState(false).waitForCompletion(true)).actionGet();

        ConfigUpdateResponse cur = tc.execute(ConfigUpdateAction.INSTANCE, new ConfigUpdateRequest(new String[]{"config","roles","rolesmapping","internalusers","actiongroups"})).actionGet();
        Assert.assertEquals(3, cur.getNodes().size());
        System.out.println(cur.getNodesMap());
    }

    RestHelper rh = nonSslRestHelper();
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/vulcangov", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/vulcangov/vulcangov_1", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"restored_index_$1\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"include_global_state\": true, \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"restored_index_with_global_state_$1\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","", encodeBasicHeader("worf", "worf")).getStatusCode());
    // Try to restore vulcangov index as searchguard index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"indices\": \"vulcangov\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());

    // Try to restore searchguard index.
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/searchguard", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/searchguard/searchguard_1", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/searchguard/searchguard_1/_restore?wait_for_completion=true","", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    // Try to restore searchguard index as serchguard_copy index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/searchguard/searchguard_1/_restore?wait_for_completion=true","{ \"indices\": \"searchguard\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard_copy\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());

    // Try to restore all indices.
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/all", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_snapshot/all/all_1", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/all_1/_restore?wait_for_completion=true","", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    // Try to restore searchguard index as serchguard_copy index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/all_1/_restore?wait_for_completion=true","{ \"indices\": \"vulcangov\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
    // Try to restore searchguard index as serchguard_copy index
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/all_1/_restore?wait_for_completion=true","{ \"indices\": \"searchguard\", \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"searchguard_copy\" }", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());

    // Try to restore a unknown snapshot
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/all/unknown-snapshot/_restore?wait_for_completion=true", "", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());

    // Tests snapshot with write permissions (OK)
    Assert.assertEquals(HttpStatus.SC_OK, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"$1_restore_1\" }", encodeBasicHeader("restoreuser", "restoreuser")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_OK, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"$1_restore_2a\" }", encodeBasicHeader("restoreuser", "restoreuser")).getStatusCode());

    // Test snapshot with write permissions (FAIL)
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"$1_no_restore_1\" }", encodeBasicHeader("restoreuser", "restoreuser")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"$1_no_restore_2\" }", encodeBasicHeader("restoreuser", "restoreuser")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"$1_no_restore_3\" }", encodeBasicHeader("restoreuser", "restoreuser")).getStatusCode());
    Assert.assertEquals(HttpStatus.SC_FORBIDDEN, rh.executePostRequest("_snapshot/vulcangov/vulcangov_1/_restore?wait_for_completion=true","{ \"rename_pattern\": \"(.+)\", \"rename_replacement\": \"$1_no_restore_4\" }", encodeBasicHeader("restoreuser", "restoreuser")).getStatusCode());
}
 
开发者ID:floragunncom,项目名称:search-guard,代码行数:67,代码来源:IntegrationTests.java

示例9: createSnapshot

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
/**
 * Creates a new snapshot.
 */
ActionFuture<CreateSnapshotResponse> createSnapshot(CreateSnapshotRequest request);
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:ClusterAdminClient.java

示例10: createSnapshotRequest

import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; //导入依赖的package包/类
/**
 * Creates new snapshot
 *
 * @param repository repository name
 * @param snapshot   snapshot name
 * @return create snapshot request
 */
public static CreateSnapshotRequest createSnapshotRequest(String repository, String snapshot) {
    return new CreateSnapshotRequest(repository, snapshot);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Requests.java


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