本文整理汇总了Java中org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest类的典型用法代码示例。如果您正苦于以下问题:Java RestoreSnapshotRequest类的具体用法?Java RestoreSnapshotRequest怎么用?Java RestoreSnapshotRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RestoreSnapshotRequest类属于org.elasticsearch.action.admin.cluster.snapshots.restore包,在下文中一共展示了RestoreSnapshotRequest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatch
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
public ListenableFuture<Long> dispatch(final RestoreSnapshotAnalyzedStatement analysis) {
final SettableFuture<Long> resultFuture = SettableFuture.create();
boolean waitForCompletion = analysis.settings().getAsBoolean(WAIT_FOR_COMPLETION.settingName(), WAIT_FOR_COMPLETION.defaultValue());
boolean ignoreUnavailable = analysis.settings().getAsBoolean(IGNORE_UNAVAILABLE.settingName(), IGNORE_UNAVAILABLE.defaultValue());
// ignore_unavailable as set by statement
IndicesOptions indicesOptions = IndicesOptions.fromOptions(ignoreUnavailable, true, true, false, IndicesOptions.lenientExpandOpen());
RestoreSnapshotRequest request = new RestoreSnapshotRequest(analysis.repositoryName(), analysis.snapshotName())
.indices(analysis.indices())
.indicesOptions(indicesOptions)
.settings(analysis.settings())
.waitForCompletion(waitForCompletion)
.includeGlobalState(false)
.includeAliases(true);
ActionListener<RestoreSnapshotResponse> listener = ActionListeners.wrap(resultFuture, Functions.constant(1L));
transportActionProvider.transportRestoreSnapshotAction().execute(request, listener);
return resultFuture;
}
示例2: prepareRequest
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
RestoreSnapshotRequest restoreSnapshotRequest = restoreSnapshotRequest(request.param("repository"), request.param("snapshot"));
restoreSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", restoreSnapshotRequest.masterNodeTimeout()));
restoreSnapshotRequest.waitForCompletion(request.paramAsBoolean("wait_for_completion", false));
request.applyContentParser(p -> restoreSnapshotRequest.source(p.mapOrdered()));
return channel -> client.admin().cluster().restoreSnapshot(restoreSnapshotRequest, new RestToXContentListener<>(channel));
}
示例3: handleRequest
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
RestoreSnapshotRequest restoreSnapshotRequest = restoreSnapshotRequest(request.param("repository"), request.param("snapshot"));
restoreSnapshotRequest.masterNodeTimeout(request.paramAsTime("master_timeout", restoreSnapshotRequest.masterNodeTimeout()));
restoreSnapshotRequest.waitForCompletion(request.paramAsBoolean("wait_for_completion", false));
restoreSnapshotRequest.source(request.content().toUtf8());
client.admin().cluster().restoreSnapshot(restoreSnapshotRequest, new RestToXContentListener<RestoreSnapshotResponse>(channel));
}
示例4: apply
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的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 (!RestoreSnapshotAction.NAME.equals(action) || !clusterService.state().nodes().localNodeMaster()) {
chain.proceed(task, action, request, listener);
} else {
final RestoreSnapshotRequest restoreSnapshotRequest = (RestoreSnapshotRequest) request;
dictionaryRestoreService.restoreDictionarySnapshot(
restoreSnapshotRequest.repository(), restoreSnapshotRequest.snapshot(),
restoreSnapshotRequest.indices(), new ActionListener<Void>() {
@Override
public void onResponse(final Void response) {
chain.proceed(task, action, request, listener);
}
@Override
public void onFailure(final Throwable e) {
if (logger.isDebugEnabled()) {
logger.debug(
"Failed to restore dictionaries for {} snapshot in {} repository.",
e, restoreSnapshotRequest.repository(),
restoreSnapshotRequest.snapshot());
}
listener.onFailure(e);
}
});
}
}
示例5: restoreSnapshot
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
@Override
public ActionFuture<RestoreSnapshotResponse> restoreSnapshot(RestoreSnapshotRequest request) {
return execute(RestoreSnapshotAction.INSTANCE, request);
}
示例6: testRestoreSnapshotRequestParsing
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
public void testRestoreSnapshotRequestParsing() throws IOException {
RestoreSnapshotRequest request = new RestoreSnapshotRequest("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());
builder.field("rename_pattern", "rename-from");
builder.field("rename_replacement", "rename-to");
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("rename-from", request.renamePattern());
assertEquals("rename-to", request.renameReplacement());
assertEquals(partial, request.partial());
assertEquals("val1", request.settings().get("set1"));
assertArrayEquals(request.ignoreIndexSettings(), new String[]{"set2", "set3"});
}
示例7: testRestoreSnapshotRequestDescrptions
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
public void testRestoreSnapshotRequestDescrptions() {
RestoreSnapshotRequest restoreSnapshotRequest = new RestoreSnapshotRequest();
restoreSnapshotRequest.snapshot("snapshot_name");
restoreSnapshotRequest.repository("repo_name");
assertEquals("snapshot [repo_name:snapshot_name]", restoreSnapshotRequest.getDescription());
}
示例8: restoreSnapshot
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
/**
* Restores a snapshot.
*/
ActionFuture<RestoreSnapshotResponse> restoreSnapshot(RestoreSnapshotRequest request);
示例9: restoreSnapshotRequest
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest; //导入依赖的package包/类
/**
* Restores new snapshot
*
* @param repository repository name
* @param snapshot snapshot name
* @return snapshot creation request
*/
public static RestoreSnapshotRequest restoreSnapshotRequest(String repository, String snapshot) {
return new RestoreSnapshotRequest(repository, snapshot);
}