Skip to content

Commit 6235795

Browse files
Two speedups to IndexNameExpressionResolver (#112486)
Two obvious speedups to the IndexNameExpressionResolver where we can defer an expensive lookup from either the indices lookup or the thread context to if and when we actually need it.
1 parent 213322a commit 6235795

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,14 @@ private static boolean shouldTrackConcreteIndex(Context context, IndicesOptions
567567
// Exclude this one as it's a net-new system index, and we explicitly don't want those.
568568
return false;
569569
}
570-
if (DataStream.isFailureStoreFeatureFlagEnabled()) {
571-
IndexAbstraction indexAbstraction = context.getState().metadata().getIndicesLookup().get(index.getName());
572-
if (context.options.allowFailureIndices() == false) {
573-
DataStream parentDataStream = indexAbstraction.getParentDataStream();
574-
if (parentDataStream != null && parentDataStream.isFailureStoreEnabled()) {
575-
if (parentDataStream.isFailureStoreIndex(index.getName())) {
576-
if (options.ignoreUnavailable()) {
577-
return false;
578-
} else {
579-
throw new FailureIndexNotSupportedException(index);
580-
}
570+
if (DataStream.isFailureStoreFeatureFlagEnabled() && context.options.allowFailureIndices() == false) {
571+
DataStream parentDataStream = context.getState().metadata().getIndicesLookup().get(index.getName()).getParentDataStream();
572+
if (parentDataStream != null && parentDataStream.isFailureStoreEnabled()) {
573+
if (parentDataStream.isFailureStoreIndex(index.getName())) {
574+
if (options.ignoreUnavailable()) {
575+
return false;
576+
} else {
577+
throw new FailureIndexNotSupportedException(index);
581578
}
582579
}
583580
}

server/src/main/java/org/elasticsearch/indices/SystemIndices.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,10 @@ public static SystemIndexAccessLevel getSystemIndexAccessLevel(ThreadContext thr
562562
// This method intentionally cannot return BACKWARDS_COMPATIBLE_ONLY - that access level should only be used manually
563563
// in known special cases.
564564
final String headerValue = threadContext.getHeader(SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY);
565-
final String productHeaderValue = threadContext.getHeader(EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY);
566565

567566
final boolean allowed = Booleans.parseBoolean(headerValue, true);
568567
if (allowed) {
569-
if (productHeaderValue != null) {
568+
if (threadContext.getHeader(EXTERNAL_SYSTEM_INDEX_ACCESS_CONTROL_HEADER_KEY) != null) {
570569
return SystemIndexAccessLevel.RESTRICTED;
571570
} else {
572571
return SystemIndexAccessLevel.ALL;

0 commit comments

Comments
 (0)