Skip to content

Commit c2e953a

Browse files
Remove dead code from IndexNameExpressionResolver (#127227)
Lots of dead code accumulated here cleaning it up.
1 parent ef0a177 commit c2e953a

File tree

1 file changed

+2
-100
lines changed

1 file changed

+2
-100
lines changed

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

Lines changed: 2 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -691,26 +691,6 @@ private static void resolveIndicesForDataStreamRelatedAbstraction(
691691
}
692692
}
693693

694-
private static void resolveWriteIndexForDataStreams(
695-
Context context,
696-
DataStream dataStream,
697-
Set<Index> concreteIndicesResult,
698-
IndexComponentSelector selector
699-
) {
700-
if (shouldIncludeRegularIndices(context.getOptions(), selector)) {
701-
Index writeIndex = dataStream.getWriteIndex();
702-
if (addIndex(writeIndex, null, context)) {
703-
concreteIndicesResult.add(writeIndex);
704-
}
705-
}
706-
if (shouldIncludeFailureIndices(context.getOptions(), selector)) {
707-
Index failureStoreWriteIndex = dataStream.getWriteFailureIndex();
708-
if (failureStoreWriteIndex != null && addIndex(failureStoreWriteIndex, null, context)) {
709-
concreteIndicesResult.add(failureStoreWriteIndex);
710-
}
711-
}
712-
}
713-
714694
public static boolean shouldIncludeRegularIndices(IndicesOptions indicesOptions, IndexComponentSelector expressionSelector) {
715695
if (indicesOptions.allowSelectors()) {
716696
return expressionSelector == null || expressionSelector.shouldIncludeData();
@@ -873,19 +853,6 @@ public Index concreteSingleIndex(ProjectMetadata project, IndicesRequest request
873853
return indices[0];
874854
}
875855

876-
/**
877-
* Utility method that allows to resolve an index expression to its corresponding single write index.
878-
*
879-
* @param state the cluster state containing all the data to resolve to expression to a concrete index
880-
* @param request The request that defines how an alias or an index need to be resolved to a concrete index
881-
* and the expression that can be resolved to an alias or an index name.
882-
* @throws IllegalArgumentException if the index resolution does not lead to an index, or leads to more than one index
883-
* @return the write index obtained as a result of the index resolution
884-
*/
885-
public Index concreteWriteIndex(ClusterState state, IndicesRequest request) {
886-
return concreteWriteIndex(projectResolver.getProjectMetadata(state), request);
887-
}
888-
889856
/**
890857
* Utility method that allows to resolve an index expression to its corresponding single write index.
891858
*
@@ -977,14 +944,6 @@ public Index concreteWriteIndex(
977944
return indices[0];
978945
}
979946

980-
/**
981-
* @return whether the specified index, data stream or alias exists.
982-
* If the data stream, index or alias contains date math then that is resolved too.
983-
*/
984-
public boolean hasIndexAbstraction(String indexAbstraction, ClusterState state) {
985-
return hasIndexAbstraction(indexAbstraction, projectResolver.getProjectMetadata(state));
986-
}
987-
988947
/**
989948
* @return whether the specified index, data stream or alias exists.
990949
* If the data stream, index or alias contains date math then that is resolved too.
@@ -1041,34 +1000,13 @@ public static void assertExpressionHasNullOrDataSelector(String expression) {
10411000
}
10421001
}
10431002

1044-
/**
1045-
* Resolve an array of expressions to the set of indices and aliases that these expressions match.
1046-
*/
1047-
public Set<ResolvedExpression> resolveExpressions(ClusterState state, String... expressions) {
1048-
return resolveExpressions(projectResolver.getProjectMetadata(state), expressions);
1049-
}
1050-
10511003
/**
10521004
* Resolve an array of expressions to the set of indices and aliases that these expressions match.
10531005
*/
10541006
public Set<ResolvedExpression> resolveExpressions(ProjectMetadata project, String... expressions) {
10551007
return resolveExpressions(project, IndicesOptions.lenientExpandOpen(), false, expressions);
10561008
}
10571009

1058-
/**
1059-
* Resolve the expression to the set of indices, aliases, and, optionally, datastreams that the expression matches.
1060-
* If {@param preserveDataStreams} is {@code true}, datastreams that are covered by the wildcards from the
1061-
* {@param expressions} are returned as-is, without expanding them further to their respective backing indices.
1062-
*/
1063-
public Set<ResolvedExpression> resolveExpressions(
1064-
ClusterState state,
1065-
IndicesOptions indicesOptions,
1066-
boolean preserveDataStreams,
1067-
String... expressions
1068-
) {
1069-
return resolveExpressions(projectResolver.getProjectMetadata(state), indicesOptions, preserveDataStreams, expressions);
1070-
}
1071-
10721010
/**
10731011
* Resolve the expression to the set of indices, aliases, and, optionally, datastreams that the expression matches.
10741012
* If {@param preserveDataStreams} is {@code true}, datastreams that are covered by the wildcards from the
@@ -1101,17 +1039,6 @@ public Set<ResolvedExpression> resolveExpressions(
11011039
}
11021040
}
11031041

1104-
/**
1105-
* Iterates through the list of indices and selects the effective list of filtering aliases for the
1106-
* given index.
1107-
* <p>Only aliases with filters are returned. If the indices list contains a non-filtering reference to
1108-
* the index itself - null is returned. Returns {@code null} if no filtering is required.
1109-
* <b>NOTE</b>: The provided expressions must have been resolved already via {@link #resolveExpressionsToResources(Context, String...)}.
1110-
*/
1111-
public String[] filteringAliases(ClusterState state, String index, Set<ResolvedExpression> resolvedExpressions) {
1112-
return filteringAliases(projectResolver.getProjectMetadata(state), index, resolvedExpressions);
1113-
}
1114-
11151042
/**
11161043
* Iterates through the list of indices and selects the effective list of filtering aliases for the
11171044
* given index.
@@ -1140,31 +1067,6 @@ boolean iterateIndexAliases(int indexAliasesSize, int resolvedExpressionsSize) {
11401067
return indexAliasesSize <= resolvedExpressionsSize;
11411068
}
11421069

1143-
/**
1144-
* Iterates through the list of indices and selects the effective list of required aliases for the given index.
1145-
* <p>Only aliases where the given predicate tests successfully are returned. If the indices list contains a non-required reference to
1146-
* the index itself - null is returned. Returns {@code null} if no filtering is required.
1147-
* <p><b>NOTE</b>: the provided expressions must have been resolved already via
1148-
* {@link #resolveExpressionsToResources(Context, String...)}.
1149-
*/
1150-
public String[] indexAliases(
1151-
ClusterState state,
1152-
String index,
1153-
Predicate<AliasMetadata> requiredAlias,
1154-
Predicate<DataStreamAlias> requiredDataStreamAlias,
1155-
boolean skipIdentity,
1156-
Set<ResolvedExpression> resolvedExpressions
1157-
) {
1158-
return indexAliases(
1159-
projectResolver.getProjectMetadata(state),
1160-
index,
1161-
requiredAlias,
1162-
requiredDataStreamAlias,
1163-
skipIdentity,
1164-
resolvedExpressions
1165-
);
1166-
}
1167-
11681070
/**
11691071
* Iterates through the list of indices and selects the effective list of required aliases for the given index.
11701072
* <p>Only aliases where the given predicate tests successfully are returned. If the indices list contains a non-required reference to
@@ -1827,9 +1729,9 @@ private static IndexMetadata.State excludeState(IndicesOptions options) {
18271729
final IndexMetadata.State excludeState;
18281730
if (options.expandWildcardsOpen() && options.expandWildcardsClosed()) {
18291731
excludeState = null;
1830-
} else if (options.expandWildcardsOpen() && options.expandWildcardsClosed() == false) {
1732+
} else if (options.expandWildcardsOpen()) {
18311733
excludeState = IndexMetadata.State.CLOSE;
1832-
} else if (options.expandWildcardsClosed() && options.expandWildcardsOpen() == false) {
1734+
} else if (options.expandWildcardsClosed()) {
18331735
excludeState = IndexMetadata.State.OPEN;
18341736
} else {
18351737
assert false : "this shouldn't get called if wildcards expand to none";

0 commit comments

Comments
 (0)