Skip to content

Commit 238b279

Browse files
authored
Fix cluster and node name in driver (#123601)
1 parent a776263 commit 238b279

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ public LocalExecutionPlan plan(String taskDescription, FoldContext foldCtx, Phys
198198
new DriverFactory(
199199
new DriverSupplier(
200200
taskDescription,
201-
Node.NODE_NAME_SETTING.get(settings),
202201
ClusterName.CLUSTER_NAME_SETTING.get(settings).value(),
202+
Node.NODE_NAME_SETTING.get(settings),
203203
context.bigArrays,
204204
context.blockFactory,
205205
physicalOperation,

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/planner/LocalExecutionPlannerTests.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.apache.lucene.search.IndexSearcher;
1818
import org.apache.lucene.store.Directory;
1919
import org.apache.lucene.tests.index.RandomIndexWriter;
20+
import org.elasticsearch.cluster.ClusterName;
2021
import org.elasticsearch.common.settings.Settings;
2122
import org.elasticsearch.common.util.BigArrays;
2223
import org.elasticsearch.compute.lucene.LuceneSourceOperator;
@@ -29,6 +30,7 @@
2930
import org.elasticsearch.index.IndexMode;
3031
import org.elasticsearch.index.cache.query.TrivialQueryCachingPolicy;
3132
import org.elasticsearch.index.mapper.MapperServiceTestCase;
33+
import org.elasticsearch.node.Node;
3234
import org.elasticsearch.search.internal.AliasFilter;
3335
import org.elasticsearch.search.internal.ContextIndexSearcher;
3436
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
@@ -159,6 +161,29 @@ public void testLuceneTopNSourceOperatorDistanceSort() throws IOException {
159161
assertThat(factory.limit(), equalTo(10));
160162
}
161163

164+
public void testDriverClusterAndNodeName() throws IOException {
165+
int estimatedRowSize = randomEstimatedRowSize(estimatedRowSizeIsHuge);
166+
LocalExecutionPlanner.LocalExecutionPlan plan = planner().plan(
167+
"test",
168+
FoldContext.small(),
169+
new EsQueryExec(
170+
Source.EMPTY,
171+
index().name(),
172+
IndexMode.STANDARD,
173+
index().indexNameWithModes(),
174+
List.of(),
175+
null,
176+
null,
177+
null,
178+
estimatedRowSize
179+
)
180+
);
181+
assertThat(plan.driverFactories.size(), lessThanOrEqualTo(pragmas.taskConcurrency()));
182+
LocalExecutionPlanner.DriverSupplier supplier = plan.driverFactories.get(0).driverSupplier();
183+
assertThat(supplier.clusterName(), equalTo("dev-cluster"));
184+
assertThat(supplier.nodeName(), equalTo("node-1"));
185+
}
186+
162187
private int randomEstimatedRowSize(boolean huge) {
163188
int hugeBoundary = SourceOperator.MIN_TARGET_PAGE_SIZE * 10;
164189
return huge ? between(hugeBoundary, Integer.MAX_VALUE) : between(1, hugeBoundary);
@@ -179,7 +204,10 @@ private LocalExecutionPlanner planner() throws IOException {
179204
null,
180205
BigArrays.NON_RECYCLING_INSTANCE,
181206
TestBlockFactory.getNonBreakingInstance(),
182-
Settings.EMPTY,
207+
Settings.builder()
208+
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), "dev-cluster")
209+
.put(Node.NODE_NAME_SETTING.getKey(), "node-1")
210+
.build(),
183211
config(),
184212
null,
185213
null,

0 commit comments

Comments
 (0)