Skip to content

Commit

Permalink
Better fix - remove datemath call altogether, we don't need it
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev committed Sep 4, 2024
1 parent 4e1a6b8 commit b6b7d67
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,19 @@ protected Map<String, List<String>> groupClusterIndices(Set<String> remoteCluste
Map<String, List<String>> perClusterIndices = new HashMap<>();
Set<String> clustersToRemove = new HashSet<>();
for (String index : requestIndices) {
boolean negativeIndex = index.charAt(0) == '-';
// ensure that `index` is a remote name and not a datemath expression which includes ':' symbol
// since datemath expression after evaluation should not contain ':' symbol
String realIndexName = negativeIndex ? index.substring(1) : index;
String probe = IndexNameExpressionResolver.resolveDateMathExpression(realIndexName);
int i = probe.indexOf(RemoteClusterService.REMOTE_CLUSTER_INDEX_SEPARATOR);
if (i >= 0) {
boolean isDateMathExpression = (index.charAt(0) == '<' || index.startsWith("-<"));
int i = index.indexOf(RemoteClusterService.REMOTE_CLUSTER_INDEX_SEPARATOR);
if (isDateMathExpression == false && i >= 0) {
if (isRemoteClusterClientEnabled == false) {
assert remoteClusterNames.isEmpty() : remoteClusterNames;
throw new IllegalArgumentException("node [" + nodeName + "] does not have the remote cluster client role enabled");
}
String remoteClusterName = realIndexName.substring(0, i);
int startIdx = index.charAt(0) == '-' ? 1 : 0;
String remoteClusterName = index.substring(startIdx, i);
List<String> clusters = ClusterNameExpressionResolver.resolveClusterNames(remoteClusterNames, remoteClusterName);
String indexName = realIndexName.substring(i + 1);
if (negativeIndex) {
String indexName = index.substring(i + 1);
if (startIdx == 1) {
if (indexName.equals("*") == false) {
throw new IllegalArgumentException(
Strings.format(
Expand Down

0 comments on commit b6b7d67

Please sign in to comment.