Search in sources :

Example 6 with CreateSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest in project crate by crate.

the class SnapshotRestoreAnalyzerTest method testCreateSnapshotAll.

@Test
public void testCreateSnapshotAll() throws Exception {
    CreateSnapshotRequest request = analyze(e, "CREATE SNAPSHOT my_repo.my_snapshot ALL WITH (wait_for_completion=true)");
    assertThat(request.indices(), arrayContainingInAnyOrder(AnalyzedCreateSnapshot.ALL_INDICES.toArray()));
    assertThat(request.repository(), is("my_repo"));
    assertThat(request.snapshot(), is("my_snapshot"));
    assertThat(request.settings().getAsStructuredMap(), hasEntry("wait_for_completion", "true"));
}
Also used : CreateSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 7 with CreateSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest in project elasticsearch by elastic.

the class RestCreateSnapshotAction method prepareRequest.

@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));
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Requests.createSnapshotRequest(org.elasticsearch.client.Requests.createSnapshotRequest) POST(org.elasticsearch.rest.RestRequest.Method.POST) Settings(org.elasticsearch.common.settings.Settings) RestToXContentListener(org.elasticsearch.rest.action.RestToXContentListener) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) CreateSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest) PUT(org.elasticsearch.rest.RestRequest.Method.PUT) CreateSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest)

Example 8 with CreateSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest in project crate by crate.

the class SnapshotRestoreAnalyzerTest method testCreateSnapshotUnknownTableIgnore.

@Test
public void testCreateSnapshotUnknownTableIgnore() throws Exception {
    CreateSnapshotRequest request = analyze(e, "CREATE SNAPSHOT my_repo.my_snapshot TABLE users, t2 WITH (ignore_unavailable=true)");
    assertThat(request.indices(), arrayContaining("users"));
    assertThat(request.indicesOptions().ignoreUnavailable(), is(true));
}
Also used : CreateSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 9 with CreateSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest in project crate by crate.

the class SnapshotRestoreAnalyzerTest method testCreateSnapshotListTablesTwice.

@Test
public void testCreateSnapshotListTablesTwice() throws Exception {
    CreateSnapshotRequest request = analyze(e, "CREATE SNAPSHOT my_repo.my_snapshot TABLE users, locations, users");
    assertThat(request.indices(), arrayContainingInAnyOrder("users", "locations"));
}
Also used : CreateSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 10 with CreateSnapshotRequest

use of org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest in project crate by crate.

the class SnapshotRestoreAnalyzerTest method testCreateSnapshotListPartitionsAndPartitionedTable.

@Test
public void testCreateSnapshotListPartitionsAndPartitionedTable() throws Exception {
    CreateSnapshotRequest request = analyze(e, "CREATE SNAPSHOT my_repo.my_snapshot TABLE parted, parted PARTITION (date=1395961200000)");
    assertThat(request.indices(), arrayContainingInAnyOrder(".partitioned.parted.04732cpp6ks3ed1o60o30c1g", ".partitioned.parted.0400", ".partitioned.parted.04732cpp6ksjcc9i60o30c1g"));
    assertThat(request.includeGlobalState(), is(false));
    assertThat(request.templates(), arrayContainingInAnyOrder(".partitioned.parted."));
}
Also used : CreateSnapshotRequest(org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Aggregations

CreateSnapshotRequest (org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest)12 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)6 Test (org.junit.Test)6 IndicesOptions (org.elasticsearch.action.support.IndicesOptions)4 CreateSnapshotException (io.crate.exceptions.CreateSnapshotException)3 Settings (org.elasticsearch.common.settings.Settings)3 AnalyzedCreateSnapshot (io.crate.analyze.AnalyzedCreateSnapshot)2 GenericPropertiesConverter (io.crate.analyze.GenericPropertiesConverter)2 PartitionPropertiesAnalyzer.toPartitionName (io.crate.analyze.PartitionPropertiesAnalyzer.toPartitionName)2 SnapshotSettings (io.crate.analyze.SnapshotSettings)2 IGNORE_UNAVAILABLE (io.crate.analyze.SnapshotSettings.IGNORE_UNAVAILABLE)2 WAIT_FOR_COMPLETION (io.crate.analyze.SnapshotSettings.WAIT_FOR_COMPLETION)2 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)2 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)2 Lists2 (io.crate.common.collections.Lists2)2 Row (io.crate.data.Row)2 Row1 (io.crate.data.Row1)2 RowConsumer (io.crate.data.RowConsumer)2 PartitionUnknownException (io.crate.exceptions.PartitionUnknownException)2 ResourceUnknownException (io.crate.exceptions.ResourceUnknownException)2