Skip to content

Commit 7fcf9bb

Browse files
authored
Merge branch 'main' into http-aggregator-removal
2 parents 59c0e23 + adf4d10 commit 7fcf9bb

File tree

36 files changed

+1858
-614
lines changed

36 files changed

+1858
-614
lines changed

docs/changelog/129170.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 129170
2+
summary: Add Support for LIKE (LIST)
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/reference/query-languages/esql/_snippets/operators/detailedDescription/like.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ ROW message = "foo * bar"
1010
```
1111

1212

13+
```esql
14+
ROW message = "foobar"
15+
| WHERE message like ("foo*", "bar?")
16+
```
17+
18+
1319
To reduce the overhead of escaping, we suggest using triple quotes strings `"""`
1420

1521
```esql

docs/reference/query-languages/esql/kibana/definition/operators/like.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/operators/not like.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/operators/like.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/docs/operators/not like.md

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public void testLookAheadTimeSettingHigherThanTimeSeriesPollIntervalSetting() {
118118
updateIndexSettings(indexSettings);
119119
}
120120

121-
private void updateClusterSettings(Settings settings) {
121+
@Override
122+
protected void updateClusterSettings(Settings settings) {
122123
clusterAdmin().updateSettings(
123124
new ClusterUpdateSettingsRequest(TEST_REQUEST_TIMEOUT, TEST_REQUEST_TIMEOUT).persistentSettings(settings)
124125
).actionGet();

server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,33 @@ public void testExpectedShardSizeIsPresent() throws InterruptedException {
264264
public void testHeapUsageEstimateIsPresent() {
265265
InternalClusterInfoService clusterInfoService = (InternalClusterInfoService) getInstanceFromNode(ClusterInfoService.class);
266266
ClusterInfoServiceUtils.refresh(clusterInfoService);
267-
ClusterState state = getInstanceFromNode(ClusterService.class).state();
268267
Map<String, ShardHeapUsage> shardHeapUsages = clusterInfoService.getClusterInfo().getShardHeapUsages();
269268
assertNotNull(shardHeapUsages);
270-
assertEquals(state.nodes().size(), shardHeapUsages.size());
271-
for (DiscoveryNode node : state.nodes()) {
272-
assertTrue(shardHeapUsages.containsKey(node.getId()));
273-
ShardHeapUsage shardHeapUsage = shardHeapUsages.get(node.getId());
274-
assertThat(shardHeapUsage.estimatedFreeBytes(), lessThanOrEqualTo(shardHeapUsage.totalBytes()));
269+
// Not collecting yet because it is disabled
270+
assertTrue(shardHeapUsages.isEmpty());
271+
272+
// Enable collection for shard heap usages
273+
updateClusterSettings(
274+
Settings.builder()
275+
.put(InternalClusterInfoService.CLUSTER_ROUTING_ALLOCATION_SHARD_HEAP_THRESHOLD_DECIDER_ENABLED.getKey(), true)
276+
.build()
277+
);
278+
try {
279+
ClusterInfoServiceUtils.refresh(clusterInfoService);
280+
ClusterState state = getInstanceFromNode(ClusterService.class).state();
281+
shardHeapUsages = clusterInfoService.getClusterInfo().getShardHeapUsages();
282+
assertEquals(state.nodes().size(), shardHeapUsages.size());
283+
for (DiscoveryNode node : state.nodes()) {
284+
assertTrue(shardHeapUsages.containsKey(node.getId()));
285+
ShardHeapUsage shardHeapUsage = shardHeapUsages.get(node.getId());
286+
assertThat(shardHeapUsage.estimatedFreeBytes(), lessThanOrEqualTo(shardHeapUsage.totalBytes()));
287+
}
288+
} finally {
289+
updateClusterSettings(
290+
Settings.builder()
291+
.putNull(InternalClusterInfoService.CLUSTER_ROUTING_ALLOCATION_SHARD_HEAP_THRESHOLD_DECIDER_ENABLED.getKey())
292+
.build()
293+
);
275294
}
276295
}
277296

server/src/main/java/org/elasticsearch/cluster/ClusterInfoSimulator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class ClusterInfoSimulator {
3333
private final CopyOnFirstWriteMap<String, Long> shardSizes;
3434
private final Map<ShardId, Long> shardDataSetSizes;
3535
private final Map<NodeAndShard, String> dataPath;
36+
private final Map<String, ShardHeapUsage> shardHeapUsages;
3637

3738
public ClusterInfoSimulator(RoutingAllocation allocation) {
3839
this.allocation = allocation;
@@ -41,6 +42,7 @@ public ClusterInfoSimulator(RoutingAllocation allocation) {
4142
this.shardSizes = new CopyOnFirstWriteMap<>(allocation.clusterInfo().shardSizes);
4243
this.shardDataSetSizes = Map.copyOf(allocation.clusterInfo().shardDataSetSizes);
4344
this.dataPath = Map.copyOf(allocation.clusterInfo().dataPath);
45+
this.shardHeapUsages = allocation.clusterInfo().getShardHeapUsages();
4446
}
4547

4648
/**
@@ -154,7 +156,7 @@ public ClusterInfo getClusterInfo() {
154156
shardDataSetSizes,
155157
dataPath,
156158
Map.of(),
157-
Map.of()
159+
shardHeapUsages
158160
);
159161
}
160162
}

server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@ public class InternalClusterInfoService implements ClusterInfoService, ClusterSt
8383
Property.NodeScope
8484
);
8585

86+
public static final Setting<Boolean> CLUSTER_ROUTING_ALLOCATION_SHARD_HEAP_THRESHOLD_DECIDER_ENABLED = Setting.boolSetting(
87+
"cluster.routing.allocation.shard_heap.threshold_enabled",
88+
false,
89+
Property.Dynamic,
90+
Property.NodeScope
91+
);
92+
8693
private volatile boolean diskThresholdEnabled;
94+
private volatile boolean shardHeapThresholdEnabled;
8795
private volatile TimeValue updateFrequency;
8896
private volatile TimeValue fetchTimeout;
8997

@@ -130,12 +138,20 @@ public InternalClusterInfoService(
130138
DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING,
131139
this::setDiskThresholdEnabled
132140
);
141+
clusterSettings.initializeAndWatch(
142+
CLUSTER_ROUTING_ALLOCATION_SHARD_HEAP_THRESHOLD_DECIDER_ENABLED,
143+
this::setShardHeapThresholdEnabled
144+
);
133145
}
134146

135147
private void setDiskThresholdEnabled(boolean diskThresholdEnabled) {
136148
this.diskThresholdEnabled = diskThresholdEnabled;
137149
}
138150

151+
private void setShardHeapThresholdEnabled(boolean shardHeapThresholdEnabled) {
152+
this.shardHeapThresholdEnabled = shardHeapThresholdEnabled;
153+
}
154+
139155
private void setFetchTimeout(TimeValue fetchTimeout) {
140156
this.fetchTimeout = fetchTimeout;
141157
}
@@ -185,20 +201,44 @@ void execute() {
185201
logger.trace("starting async refresh");
186202

187203
try (var ignoredRefs = fetchRefs) {
188-
if (diskThresholdEnabled) {
189-
try (var ignored = threadPool.getThreadContext().clearTraceContext()) {
190-
fetchIndicesStats();
191-
}
192-
} else {
193-
logger.trace("skipping collecting disk usage info from cluster, notifying listeners with empty cluster info");
194-
indicesStatsSummary = IndicesStatsSummary.EMPTY;
204+
maybeFetchIndicesStats(diskThresholdEnabled);
205+
maybeFetchNodeStats(diskThresholdEnabled || shardHeapThresholdEnabled);
206+
maybeFetchNodesHeapUsage(shardHeapThresholdEnabled);
207+
}
208+
}
209+
210+
private void maybeFetchIndicesStats(boolean shouldFetch) {
211+
if (shouldFetch) {
212+
try (var ignored = threadPool.getThreadContext().clearTraceContext()) {
213+
fetchIndicesStats();
195214
}
215+
} else {
216+
logger.trace("skipping collecting disk usage info from cluster, notifying listeners with empty indices stats");
217+
indicesStatsSummary = IndicesStatsSummary.EMPTY;
218+
}
219+
}
220+
221+
private void maybeFetchNodeStats(boolean shouldFetch) {
222+
if (shouldFetch) {
196223
try (var ignored = threadPool.getThreadContext().clearTraceContext()) {
197224
fetchNodeStats();
198225
}
226+
} else {
227+
logger.trace("skipping collecting node stats from cluster, notifying listeners with empty node stats");
228+
leastAvailableSpaceUsages = Map.of();
229+
mostAvailableSpaceUsages = Map.of();
230+
maxHeapPerNode = Map.of();
231+
}
232+
}
233+
234+
private void maybeFetchNodesHeapUsage(boolean shouldFetch) {
235+
if (shouldFetch) {
199236
try (var ignored = threadPool.getThreadContext().clearTraceContext()) {
200237
fetchNodesHeapUsage();
201238
}
239+
} else {
240+
logger.trace("skipping collecting shard heap usage from cluster, notifying listeners with empty shard heap usage");
241+
shardHeapUsagePerNode = Map.of();
202242
}
203243
}
204244

0 commit comments

Comments
 (0)