Skip to content

Apply ignore_throttled also to concrete indices #35335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public boolean ignoreAliases() {

/**
*
* @return whether indices that are marked as throttled should be ignored when resolving a wildcard or alias
* @return whether indices that are marked as throttled should be ignored
*/
public boolean ignoreThrottled() {
return options.contains(Option.IGNORE_THROTTLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
if (indexExpressions == null || indexExpressions.length == 0) {
indexExpressions = new String[]{MetaData.ALL};
}
Set<String> originalIndexExpression = Sets.newHashSet(indexExpressions);
MetaData metaData = context.getState().metaData();
IndicesOptions options = context.getOptions();
final boolean failClosed = options.forbidClosedIndices() && options.ignoreUnavailable() == false;
Expand Down Expand Up @@ -197,7 +196,7 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
" The write index may be explicitly disabled using is_write_index=false or the alias points to multiple" +
" indices without one being designated as a write index");
}
if (addIndex(writeIndex, context, originalIndexExpression)) {
if (addIndex(writeIndex, context)) {
concreteIndices.add(writeIndex.getIndex());
}
} else {
Expand All @@ -216,12 +215,12 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
if (failClosed) {
throw new IndexClosedException(index.getIndex());
} else {
if (options.forbidClosedIndices() == false && addIndex(index, context, originalIndexExpression)) {
if (options.forbidClosedIndices() == false && addIndex(index, context)) {
concreteIndices.add(index.getIndex());
}
}
} else if (index.getState() == IndexMetaData.State.OPEN) {
if (addIndex(index, context, originalIndexExpression)) {
if (addIndex(index, context)) {
concreteIndices.add(index.getIndex());
}
} else {
Expand All @@ -239,13 +238,8 @@ Index[] concreteIndices(Context context, String... indexExpressions) {
return concreteIndices.toArray(new Index[concreteIndices.size()]);
}

private static boolean addIndex(IndexMetaData metaData, Context context, Set<String> originalIndices) {
if (context.options.ignoreThrottled()) {
if (originalIndices.contains(metaData.getIndex().getName()) == false) {
return IndexSettings.INDEX_SEARCH_THROTTLED.get(metaData.getSettings()) == false;
}
}
return true;
private static boolean addIndex(IndexMetaData metaData, Context context) {
return (context.options.ignoreThrottled() && IndexSettings.INDEX_SEARCH_THROTTLED.get(metaData.getSettings())) == false;
}

private static IllegalArgumentException aliasesNotSupportedException(String expression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1357,21 +1357,19 @@ public void testIgnoreThrottled() {
{
Index[] indices = indexNameExpressionResolver.concreteIndices(state,
IndicesOptions.STRICT_EXPAND_OPEN_FORBID_CLOSED_IGNORE_THROTTLED, "ind*", "test-index");
assertEquals(2, indices.length);
assertEquals(1, indices.length);
Arrays.sort(indices, Comparator.comparing(Index::getName));
assertEquals("index", indices[0].getName());
assertEquals("test-index", indices[1].getName());
}

{
Index[] indices = indexNameExpressionResolver.concreteIndices(state,
new IndicesOptions(EnumSet.of(IndicesOptions.Option.ALLOW_NO_INDICES,
IndicesOptions.Option.IGNORE_THROTTLED),
EnumSet.of(IndicesOptions.WildcardStates.OPEN)), "ind*", "test-index");
assertEquals(2, indices.length);
assertEquals(1, indices.length);
Arrays.sort(indices, Comparator.comparing(Index::getName));
assertEquals("index", indices[0].getName());
assertEquals("test-index", indices[1].getName());
}
{
Index[] indices = indexNameExpressionResolver.concreteIndices(state,
Expand Down