本文整理汇总了Java中org.elasticsearch.action.support.IndicesOptions.fromOptions方法的典型用法代码示例。如果您正苦于以下问题:Java IndicesOptions.fromOptions方法的具体用法?Java IndicesOptions.fromOptions怎么用?Java IndicesOptions.fromOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.support.IndicesOptions
的用法示例。
在下文中一共展示了IndicesOptions.fromOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSerialization
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testSerialization() throws Exception {
int iterations = randomIntBetween(5, 20);
for (int i = 0; i < iterations; i++) {
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
ClusterStateRequest clusterStateRequest = new ClusterStateRequest().routingTable(randomBoolean()).metaData(randomBoolean())
.nodes(randomBoolean()).blocks(randomBoolean()).indices("testindex", "testindex2").indicesOptions(indicesOptions);
Version testVersion = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
BytesStreamOutput output = new BytesStreamOutput();
output.setVersion(testVersion);
clusterStateRequest.writeTo(output);
StreamInput streamInput = output.bytes().streamInput();
streamInput.setVersion(testVersion);
ClusterStateRequest deserializedCSRequest = new ClusterStateRequest();
deserializedCSRequest.readFrom(streamInput);
assertThat(deserializedCSRequest.routingTable(), equalTo(clusterStateRequest.routingTable()));
assertThat(deserializedCSRequest.metaData(), equalTo(clusterStateRequest.metaData()));
assertThat(deserializedCSRequest.nodes(), equalTo(clusterStateRequest.nodes()));
assertThat(deserializedCSRequest.blocks(), equalTo(clusterStateRequest.blocks()));
assertThat(deserializedCSRequest.indices(), equalTo(clusterStateRequest.indices()));
assertOptionsMatch(deserializedCSRequest.indicesOptions(), clusterStateRequest.indicesOptions());
}
}
示例2: dispatch
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的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;
}
示例3: testUpdateByQueryRequestImplementsIndicesRequestReplaceable
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testUpdateByQueryRequestImplementsIndicesRequestReplaceable() {
int numIndices = between(1, 100);
String[] indices = new String[numIndices];
for (int i = 0; i < numIndices; i++) {
indices[i] = randomSimpleString(random(), 1, 30);
}
SearchRequest searchRequest = new SearchRequest(indices);
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
searchRequest.indicesOptions(indicesOptions);
UpdateByQueryRequest request = new UpdateByQueryRequest(searchRequest);
for (int i = 0; i < numIndices; i++) {
assertEquals(indices[i], request.indices()[i]);
}
assertSame(indicesOptions, request.indicesOptions());
assertSame(request.indicesOptions(), request.getSearchRequest().indicesOptions());
int numNewIndices = between(1, 100);
String[] newIndices = new String[numNewIndices];
for (int i = 0; i < numNewIndices; i++) {
newIndices[i] = randomSimpleString(random(), 1, 30);
}
request.indices(newIndices);
for (int i = 0; i < numNewIndices; i++) {;
assertEquals(newIndices[i], request.indices()[i]);
}
for (int i = 0; i < numNewIndices; i++) {;
assertEquals(newIndices[i], request.getSearchRequest().indices()[i]);
}
}
示例4: checkBlock
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
@Override
protected ClusterBlockException checkBlock(RolloverRequest request, ClusterState state) {
IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true,
request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed());
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_WRITE,
indexNameExpressionResolver.concreteIndexNames(state, indicesOptions, request.indices()));
}
示例5: testWildcardBehaviourSnapshotRestore
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testWildcardBehaviourSnapshotRestore() throws Exception {
createIndex("foobar");
ensureGreen("foobar");
waitForRelocation();
PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("dummy-repo")
.setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).get();
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
client().admin().cluster().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get();
IndicesOptions options = IndicesOptions.fromOptions(false, false, true, false);
verify(snapshot("snap2", "foo*", "bar*").setIndicesOptions(options), true);
verify(restore("snap1", "foo*", "bar*").setIndicesOptions(options), true);
options = IndicesOptions.strictExpandOpen();
verify(snapshot("snap2", "foo*", "bar*").setIndicesOptions(options), false);
verify(restore("snap2", "foo*", "bar*").setIndicesOptions(options), false);
assertAcked(prepareCreate("barbaz"));
//TODO: temporary work-around for #5531
ensureGreen("barbaz");
waitForRelocation();
options = IndicesOptions.fromOptions(false, false, true, false);
verify(snapshot("snap3", "foo*", "bar*").setIndicesOptions(options), false);
verify(restore("snap3", "foo*", "bar*").setIndicesOptions(options), false);
options = IndicesOptions.fromOptions(false, false, true, false);
verify(snapshot("snap4", "foo*", "baz*").setIndicesOptions(options), true);
verify(restore("snap3", "foo*", "baz*").setIndicesOptions(options), true);
}
示例6: testCloseApiSpecifiedIndices
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testCloseApiSpecifiedIndices() throws Exception {
createIndex("test1", "test2");
ensureGreen();
verify(search("test1", "test2"), false);
assertAcked(client().admin().indices().prepareClose("test2").get());
verify(search("test1", "test2"), true);
IndicesOptions options = IndicesOptions.fromOptions(true, true, true, false, IndicesOptions.strictExpandOpenAndForbidClosed());
verify(search("test1", "test2").setIndicesOptions(options), false);
verify(search(), false);
verify(search("t*"), false);
}
示例7: testIndicesOptions
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testIndicesOptions() throws Exception {
ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("f*")
.get();
assertThat(clusterStateResponse.getState().metaData().indices().size(), is(2));
// close one index
client().admin().indices().close(Requests.closeIndexRequest("fuu")).get();
clusterStateResponse = client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("f*").get();
assertThat(clusterStateResponse.getState().metaData().indices().size(), is(1));
assertThat(clusterStateResponse.getState().metaData().index("foo").getState(), equalTo(IndexMetaData.State.OPEN));
// expand_wildcards_closed should toggle return only closed index fuu
IndicesOptions expandCloseOptions = IndicesOptions.fromOptions(false, true, false, true);
clusterStateResponse = client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("f*")
.setIndicesOptions(expandCloseOptions).get();
assertThat(clusterStateResponse.getState().metaData().indices().size(), is(1));
assertThat(clusterStateResponse.getState().metaData().index("fuu").getState(), equalTo(IndexMetaData.State.CLOSE));
// ignore_unavailable set to true should not raise exception on fzzbzz
IndicesOptions ignoreUnavailabe = IndicesOptions.fromOptions(true, true, true, false);
clusterStateResponse = client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz")
.setIndicesOptions(ignoreUnavailabe).get();
assertThat(clusterStateResponse.getState().metaData().indices().isEmpty(), is(true));
// empty wildcard expansion result should work when allowNoIndices is
// turned on
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
clusterStateResponse = client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("a*")
.setIndicesOptions(allowNoIndices).get();
assertThat(clusterStateResponse.getState().metaData().indices().isEmpty(), is(true));
}
示例8: testIndicesOptionsOnAllowNoIndicesFalse
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testIndicesOptionsOnAllowNoIndicesFalse() throws Exception {
// empty wildcard expansion throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, false, true, false);
try {
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("a*").setIndicesOptions(allowNoIndices).get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index"));
}
}
示例9: testIndicesIgnoreUnavailableFalse
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testIndicesIgnoreUnavailableFalse() throws Exception {
// ignore_unavailable set to false throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
try {
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index"));
}
}
示例10: testRequestOnClosedIndexIgnoreUnavailable
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
/**
* setting the "ignoreUnavailable" option prevents IndexClosedException
*/
public void testRequestOnClosedIndexIgnoreUnavailable() {
client().admin().indices().prepareClose("test").get();
IndicesOptions defaultOptions = new IndicesSegmentsRequest().indicesOptions();
IndicesOptions testOptions = IndicesOptions.fromOptions(true, true, true, false, defaultOptions);
IndicesSegmentResponse rsp = client().admin().indices().prepareSegments("test").setIndicesOptions(testOptions).get();
assertEquals(0, rsp.getIndices().size());
}
示例11: testDeleteteByQueryRequestImplementsIndicesRequestReplaceable
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testDeleteteByQueryRequestImplementsIndicesRequestReplaceable() {
int numIndices = between(1, 100);
String[] indices = new String[numIndices];
for (int i = 0; i < numIndices; i++) {
indices[i] = randomSimpleString(random(), 1, 30);
}
SearchRequest searchRequest = new SearchRequest(indices);
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
searchRequest.indicesOptions(indicesOptions);
DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest);
for (int i = 0; i < numIndices; i++) {
assertEquals(indices[i], request.indices()[i]);
}
assertSame(indicesOptions, request.indicesOptions());
assertSame(request.indicesOptions(), request.getSearchRequest().indicesOptions());
int numNewIndices = between(1, 100);
String[] newIndices = new String[numNewIndices];
for (int i = 0; i < numNewIndices; i++) {
newIndices[i] = randomSimpleString(random(), 1, 30);
}
request.indices(newIndices);
for (int i = 0; i < numNewIndices; i++) {;
assertEquals(newIndices[i], request.indices()[i]);
}
for (int i = 0; i < numNewIndices; i++) {;
assertEquals(newIndices[i], request.getSearchRequest().indices()[i]);
}
}
示例12: expandWilcardsOpen
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public IndicesExistsRequest expandWilcardsOpen(boolean expandWildcardsOpen) {
this.indicesOptions = IndicesOptions.fromOptions(indicesOptions.ignoreUnavailable(), indicesOptions.allowNoIndices(),
expandWildcardsOpen, indicesOptions.expandWildcardsClosed());
return this;
}
示例13: expandWilcardsClosed
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public IndicesExistsRequest expandWilcardsClosed(boolean expandWildcardsClosed) {
this.indicesOptions = IndicesOptions.fromOptions(indicesOptions.ignoreUnavailable(), indicesOptions.allowNoIndices(),
indicesOptions.expandWildcardsOpen(), expandWildcardsClosed);
return this;
}
示例14: checkBlock
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
@Override
protected ClusterBlockException checkBlock(IndicesExistsRequest request, ClusterState state) {
//make sure through indices options that the concrete indices call never throws IndexMissingException
IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true, request.indicesOptions().expandWildcardsOpen(), request.indicesOptions().expandWildcardsClosed());
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, indexNameExpressionResolver.concreteIndexNames(state, indicesOptions, request.indices()));
}
示例15: testSpecifiedIndexUnavailableSingleIndexThatIsClosed
import org.elasticsearch.action.support.IndicesOptions; //导入方法依赖的package包/类
public void testSpecifiedIndexUnavailableSingleIndexThatIsClosed() throws Exception {
assertAcked(prepareCreate("test1"));
// we need to wait until all shards are allocated since recovery from
// gateway will fail unless the majority of the replicas was allocated
// pre-closing. with lots of replicas this will fail.
ensureGreen();
assertAcked(client().admin().indices().prepareClose("test1"));
IndicesOptions options = IndicesOptions.strictExpandOpenAndForbidClosed();
verify(search("test1").setIndicesOptions(options), true);
verify(msearch(options, "test1"), true);
verify(clearCache("test1").setIndicesOptions(options), true);
verify(_flush("test1").setIndicesOptions(options),true);
verify(segments("test1").setIndicesOptions(options), true);
verify(stats("test1").setIndicesOptions(options), true);
verify(forceMerge("test1").setIndicesOptions(options), true);
verify(refreshBuilder("test1").setIndicesOptions(options), true);
verify(validateQuery("test1").setIndicesOptions(options), true);
verify(aliasExists("test1").setIndicesOptions(options), true);
verify(typesExists("test1").setIndicesOptions(options), true);
verify(getAliases("test1").setIndicesOptions(options), true);
verify(getFieldMapping("test1").setIndicesOptions(options), true);
verify(getMapping("test1").setIndicesOptions(options), true);
verify(getSettings("test1").setIndicesOptions(options), true);
options = IndicesOptions.fromOptions(true, options.allowNoIndices(), options.expandWildcardsOpen(), options.expandWildcardsClosed(), options);
verify(search("test1").setIndicesOptions(options), false);
verify(msearch(options, "test1"), false);
verify(clearCache("test1").setIndicesOptions(options), false);
verify(_flush("test1").setIndicesOptions(options),false);
verify(segments("test1").setIndicesOptions(options), false);
verify(stats("test1").setIndicesOptions(options), false);
verify(forceMerge("test1").setIndicesOptions(options), false);
verify(refreshBuilder("test1").setIndicesOptions(options), false);
verify(validateQuery("test1").setIndicesOptions(options), false);
verify(aliasExists("test1").setIndicesOptions(options), false);
verify(typesExists("test1").setIndicesOptions(options), false);
verify(getAliases("test1").setIndicesOptions(options), false);
verify(getFieldMapping("test1").setIndicesOptions(options), false);
verify(getMapping("test1").setIndicesOptions(options), false);
verify(getSettings("test1").setIndicesOptions(options), false);
assertAcked(client().admin().indices().prepareOpen("test1"));
ensureYellow();
options = IndicesOptions.strictExpandOpenAndForbidClosed();
verify(search("test1").setIndicesOptions(options), false);
verify(msearch(options, "test1"), false);
verify(clearCache("test1").setIndicesOptions(options), false);
verify(_flush("test1").setIndicesOptions(options),false);
verify(segments("test1").setIndicesOptions(options), false);
verify(stats("test1").setIndicesOptions(options), false);
verify(forceMerge("test1").setIndicesOptions(options), false);
verify(refreshBuilder("test1").setIndicesOptions(options), false);
verify(validateQuery("test1").setIndicesOptions(options), false);
verify(aliasExists("test1").setIndicesOptions(options), false);
verify(typesExists("test1").setIndicesOptions(options), false);
verify(getAliases("test1").setIndicesOptions(options), false);
verify(getFieldMapping("test1").setIndicesOptions(options), false);
verify(getMapping("test1").setIndicesOptions(options), false);
verify(getSettings("test1").setIndicesOptions(options), false);
}