Skip to content

Commit

Permalink
ES-6566: Collect data tiers usage stats efficiently (#100230) (#102140)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarouli committed Nov 15, 2023
1 parent 5f66c18 commit 184d993
Show file tree
Hide file tree
Showing 20 changed files with 1,508 additions and 1,054 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/102140.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 102140
summary: Collect data tiers usage stats more efficiently
area: ILM+SLM
type: bug
issues:
- 100230
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import org.elasticsearch.core.Nullable;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.xpack.core.DataTiersFeatureSetUsage;
import org.elasticsearch.xpack.core.action.XPackUsageRequestBuilder;
import org.elasticsearch.xpack.core.action.XPackUsageResponse;
import org.elasticsearch.xpack.core.datatiers.DataTiersFeatureSetUsage;
import org.junit.Before;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package org.elasticsearch.xpack.core.rest.action;

import org.apache.http.client.methods.HttpGet;
import org.elasticsearch.action.admin.cluster.node.stats.TransportNodesStatsAction;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.ActionTestUtils;
import org.elasticsearch.action.support.PlainActionFuture;
Expand All @@ -35,6 +34,7 @@
import org.elasticsearch.xpack.core.action.XPackUsageAction;
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction;
import org.elasticsearch.xpack.core.action.XPackUsageResponse;
import org.elasticsearch.xpack.core.datatiers.NodesDataTiersUsageTransportAction;

import java.nio.file.Path;
import java.util.Arrays;
Expand Down Expand Up @@ -76,7 +76,7 @@ public void testCancellation() throws Exception {
final SubscribableListener<Void> nodeStatsRequestsReleaseListener = new SubscribableListener<>();
for (TransportService transportService : internalCluster().getInstances(TransportService.class)) {
((MockTransportService) transportService).addRequestHandlingBehavior(
TransportNodesStatsAction.TYPE.name() + "[n]",
NodesDataTiersUsageTransportAction.TYPE.name() + "[n]",
(handler, request, channel, task) -> {
tasksBlockedLatch.countDown();
nodeStatsRequestsReleaseListener.addListener(
Expand All @@ -94,14 +94,13 @@ public void testCancellation() throws Exception {
safeAwait(tasksBlockedLatch); // must wait for the node-level tasks to start to avoid cancelling being handled earlier
cancellable.cancel();

// NB this test works by blocking node-level stats requests; when #100230 is addressed this will need to target a different action.
assertAllCancellableTasksAreCancelled(TransportNodesStatsAction.TYPE.name());
assertAllCancellableTasksAreCancelled(NodesDataTiersUsageTransportAction.TYPE.name());
assertAllCancellableTasksAreCancelled(XPackUsageAction.NAME);

nodeStatsRequestsReleaseListener.onResponse(null);
expectThrows(CancellationException.class, future::actionGet);

assertAllTasksHaveFinished(TransportNodesStatsAction.TYPE.name());
assertAllTasksHaveFinished(NodesDataTiersUsageTransportAction.TYPE.name());
assertAllTasksHaveFinished(XPackUsageAction.NAME);
}

Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugin/core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
exports org.elasticsearch.xpack.core.common.validation;
exports org.elasticsearch.xpack.core.common;
exports org.elasticsearch.xpack.core.datastreams;
exports org.elasticsearch.xpack.core.datatiers;
exports org.elasticsearch.xpack.core.deprecation;
exports org.elasticsearch.xpack.core.downsample;
exports org.elasticsearch.xpack.core.enrich.action;
Expand Down Expand Up @@ -226,4 +227,6 @@
with
org.elasticsearch.xpack.core.ml.MlConfigVersionComponent,
org.elasticsearch.xpack.core.transform.TransformConfigVersionComponent;

provides org.elasticsearch.features.FeatureSpecification with org.elasticsearch.xpack.core.XPackFeatures;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
import org.elasticsearch.xpack.core.datastreams.DataStreamFeatureSetUsage;
import org.elasticsearch.xpack.core.datastreams.DataStreamLifecycleFeatureSetUsage;
import org.elasticsearch.xpack.core.datatiers.DataTiersFeatureSetUsage;
import org.elasticsearch.xpack.core.downsample.DownsampleShardStatus;
import org.elasticsearch.xpack.core.enrich.EnrichFeatureSetUsage;
import org.elasticsearch.xpack.core.enrich.action.ExecuteEnrichPolicyStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.core;

import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.xpack.core.datatiers.NodesDataTiersUsageTransportAction;

import java.util.Set;

/**
* Provides the XPack features that this version of the code supports
*/
public class XPackFeatures implements FeatureSpecification {

@Override
public Set<NodeFeature> getFeatures() {
return Set.of(
NodesDataTiersUsageTransportAction.LOCALLY_PRECALCULATED_STATS_FEATURE // Added in 8.12
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
import org.elasticsearch.xpack.core.action.XPackUsageResponse;
import org.elasticsearch.xpack.core.async.DeleteAsyncResultAction;
import org.elasticsearch.xpack.core.async.TransportDeleteAsyncResultAction;
import org.elasticsearch.xpack.core.datatiers.DataTiersInfoTransportAction;
import org.elasticsearch.xpack.core.datatiers.DataTiersUsageTransportAction;
import org.elasticsearch.xpack.core.datatiers.NodesDataTiersUsageTransportAction;
import org.elasticsearch.xpack.core.ml.MlMetadata;
import org.elasticsearch.xpack.core.rest.action.RestXPackInfoAction;
import org.elasticsearch.xpack.core.rest.action.RestXPackUsageAction;
Expand Down Expand Up @@ -362,6 +365,7 @@ public Collection<?> createComponents(PluginServices services) {
actions.add(new ActionHandler<>(XPackUsageFeatureAction.DATA_STREAM_LIFECYCLE, DataStreamLifecycleUsageTransportAction.class));
actions.add(new ActionHandler<>(XPackUsageFeatureAction.HEALTH, HealthApiUsageTransportAction.class));
actions.add(new ActionHandler<>(XPackUsageFeatureAction.REMOTE_CLUSTERS, RemoteClusterUsageTransportAction.class));
actions.add(new ActionHandler<>(NodesDataTiersUsageTransportAction.TYPE, NodesDataTiersUsageTransportAction.class));
return actions;
}

Expand Down

0 comments on commit 184d993

Please sign in to comment.