Skip to content

Commit fde3d9f

Browse files
committed
Move the cluster set out of execution info
1 parent def9a98 commit fde3d9f

File tree

4 files changed

+26
-37
lines changed

4 files changed

+26
-37
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlExecutionInfo.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public class EsqlExecutionInfo implements ChunkedToXContentObject, Writeable {
7777
private transient TimeValue planningTookTime; // time elapsed since start of query to calling ComputeService.execute
7878
private volatile boolean isPartial; // Does this request have partial results?
7979
private transient volatile boolean isStopped; // Have we received stop command?
80-
private transient Set<String> configuredClusters; // Set of configured remote clusters
8180

8281
public EsqlExecutionInfo(boolean includeCCSMetadata) {
8382
this(Predicates.always(), includeCCSMetadata); // default all clusters to skip_unavailable=true
@@ -355,14 +354,6 @@ public boolean isStopped() {
355354
return isStopped;
356355
}
357356

358-
public Set<String> getConfiguredClusters() {
359-
return configuredClusters;
360-
}
361-
362-
public void setConfiguredClusters(Set<String> configuredClusters) {
363-
this.configuredClusters = configuredClusters;
364-
}
365-
366357
/**
367358
* Represents the search metadata about a particular cluster involved in a cross-cluster search.
368359
* The Cluster object can represent either the local cluster or a remote cluster.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,13 @@ public static void checkForCcsLicense(
278278
EsqlExecutionInfo executionInfo,
279279
List<TableInfo> indices,
280280
IndicesExpressionGrouper indicesGrouper,
281+
Set<String> configuredClusters,
281282
XPackLicenseState licenseState
282283
) {
283284
for (TableInfo tableInfo : indices) {
284285
Map<String, OriginalIndices> groupedIndices;
285286
try {
286-
groupedIndices = indicesGrouper.groupIndices(
287-
executionInfo.getConfiguredClusters(),
288-
IndicesOptions.DEFAULT,
289-
tableInfo.id().indexPattern()
290-
);
287+
groupedIndices = indicesGrouper.groupIndices(configuredClusters, IndicesOptions.DEFAULT, tableInfo.id().indexPattern());
291288
} catch (NoSuchRemoteClusterException e) {
292289
if (EsqlLicenseChecker.isCcsAllowed(licenseState)) {
293290
throw e;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlSession.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public interface PlanRunner {
120120
private final PhysicalPlanOptimizer physicalPlanOptimizer;
121121
private final PlanTelemetry planTelemetry;
122122
private final IndicesExpressionGrouper indicesExpressionGrouper;
123+
private Set<String> configuredClusters;
123124

124125
public EsqlSession(
125126
String sessionId,
@@ -344,7 +345,7 @@ public void analyzedPlan(
344345
return plan;
345346
};
346347
// Capture configured remotes list to ensure consistency throughout the session
347-
executionInfo.setConfiguredClusters(Set.copyOf(indicesExpressionGrouper.getConfiguredClusters()));
348+
configuredClusters = Set.copyOf(indicesExpressionGrouper.getConfiguredClusters());
348349

349350
PreAnalyzer.PreAnalysis preAnalysis = preAnalyzer.preAnalyze(parsed);
350351
var unresolvedPolicies = preAnalysis.enriches.stream()
@@ -357,10 +358,10 @@ public void analyzedPlan(
357358
.collect(Collectors.toSet());
358359
final List<TableInfo> indices = preAnalysis.indices;
359360

360-
EsqlCCSUtils.checkForCcsLicense(executionInfo, indices, indicesExpressionGrouper, verifier.licenseState());
361+
EsqlCCSUtils.checkForCcsLicense(executionInfo, indices, indicesExpressionGrouper, configuredClusters, verifier.licenseState());
361362

362363
final Set<String> targetClusters = enrichPolicyResolver.groupIndicesPerCluster(
363-
executionInfo.getConfiguredClusters(),
364+
configuredClusters,
364365
indices.stream()
365366
.flatMap(t -> Arrays.stream(Strings.commaDelimitedListToStringArray(t.id().indexPattern())))
366367
.toArray(String[]::new)
@@ -445,7 +446,7 @@ private void preAnalyzeIndices(
445446
IndexPattern table = tableInfo.id();
446447

447448
Map<String, OriginalIndices> clusterIndices = indicesExpressionGrouper.groupIndices(
448-
executionInfo.getConfiguredClusters(),
449+
configuredClusters,
449450
IndicesOptions.DEFAULT,
450451
table.indexPattern()
451452
);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtilsTests.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -712,22 +712,22 @@ public void testCheckForCcsLicense() {
712712
List<TableInfo> indices = new ArrayList<>();
713713
indices.add(new TableInfo(new IndexPattern(EMPTY, randomFrom("idx", "idx1,idx2*"))));
714714

715-
checkForCcsLicense(executionInfo, indices, indicesGrouper, enterpriseLicenseValid);
716-
checkForCcsLicense(executionInfo, indices, indicesGrouper, platinumLicenseValid);
717-
checkForCcsLicense(executionInfo, indices, indicesGrouper, goldLicenseValid);
718-
checkForCcsLicense(executionInfo, indices, indicesGrouper, trialLicenseValid);
719-
checkForCcsLicense(executionInfo, indices, indicesGrouper, basicLicenseValid);
720-
checkForCcsLicense(executionInfo, indices, indicesGrouper, standardLicenseValid);
721-
checkForCcsLicense(executionInfo, indices, indicesGrouper, missingLicense);
722-
checkForCcsLicense(executionInfo, indices, indicesGrouper, nullLicense);
723-
724-
checkForCcsLicense(executionInfo, indices, indicesGrouper, enterpriseLicenseInactive);
725-
checkForCcsLicense(executionInfo, indices, indicesGrouper, platinumLicenseInactive);
726-
checkForCcsLicense(executionInfo, indices, indicesGrouper, goldLicenseInactive);
727-
checkForCcsLicense(executionInfo, indices, indicesGrouper, trialLicenseInactive);
728-
checkForCcsLicense(executionInfo, indices, indicesGrouper, basicLicenseInactive);
729-
checkForCcsLicense(executionInfo, indices, indicesGrouper, standardLicenseInactive);
730-
checkForCcsLicense(executionInfo, indices, indicesGrouper, missingLicenseInactive);
715+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), enterpriseLicenseValid);
716+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), platinumLicenseValid);
717+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), goldLicenseValid);
718+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), trialLicenseValid);
719+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), basicLicenseValid);
720+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), standardLicenseValid);
721+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), missingLicense);
722+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), nullLicense);
723+
724+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), enterpriseLicenseInactive);
725+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), platinumLicenseInactive);
726+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), goldLicenseInactive);
727+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), trialLicenseInactive);
728+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), basicLicenseInactive);
729+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), standardLicenseInactive);
730+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), missingLicenseInactive);
731731
}
732732

733733
// cross-cluster search requires a valid (active, non-expired) enterprise license OR a valid trial license
@@ -742,8 +742,8 @@ public void testCheckForCcsLicense() {
742742
}
743743

744744
// licenses that work
745-
checkForCcsLicense(executionInfo, indices, indicesGrouper, enterpriseLicenseValid);
746-
checkForCcsLicense(executionInfo, indices, indicesGrouper, trialLicenseValid);
745+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), enterpriseLicenseValid);
746+
checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), trialLicenseValid);
747747

748748
// all others fail ---
749749

@@ -812,7 +812,7 @@ private void assertLicenseCheckFails(
812812
EsqlExecutionInfo executionInfo = new EsqlExecutionInfo(true);
813813
ElasticsearchStatusException e = expectThrows(
814814
ElasticsearchStatusException.class,
815-
() -> checkForCcsLicense(executionInfo, indices, indicesGrouper, licenseState)
815+
() -> checkForCcsLicense(executionInfo, indices, indicesGrouper, Set.of(), licenseState)
816816
);
817817
assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
818818
assertThat(

0 commit comments

Comments
 (0)