77
88package org .elasticsearch .xpack .ml .action ;
99
10+ import org .elasticsearch .action .ActionListener ;
1011import org .elasticsearch .action .FailedNodeException ;
1112import org .elasticsearch .action .support .ActionFilters ;
1213import org .elasticsearch .action .support .nodes .TransportNodesAction ;
1314import org .elasticsearch .cluster .node .DiscoveryNode ;
1415import org .elasticsearch .cluster .service .ClusterService ;
1516import org .elasticsearch .common .io .stream .StreamInput ;
17+ import org .elasticsearch .features .FeatureService ;
1618import org .elasticsearch .injection .guice .Inject ;
1719import org .elasticsearch .tasks .Task ;
1820import org .elasticsearch .threadpool .ThreadPool ;
1921import org .elasticsearch .transport .TransportService ;
2022import org .elasticsearch .xpack .core .ml .action .ResetMlComponentsAction ;
23+ import org .elasticsearch .xpack .ml .MachineLearningFeatures ;
2124import org .elasticsearch .xpack .ml .inference .TrainedModelStatsService ;
2225import org .elasticsearch .xpack .ml .notifications .AnomalyDetectionAuditor ;
2326import org .elasticsearch .xpack .ml .notifications .DataFrameAnalyticsAuditor ;
@@ -37,6 +40,7 @@ public class TransportResetMlComponentsAction extends TransportNodesAction<
3740 private final DataFrameAnalyticsAuditor dfaAuditor ;
3841 private final InferenceAuditor inferenceAuditor ;
3942 private final TrainedModelStatsService trainedModelStatsService ;
43+ private final FeatureService featureService ;
4044
4145 @ Inject
4246 public TransportResetMlComponentsAction (
@@ -47,7 +51,8 @@ public TransportResetMlComponentsAction(
4751 AnomalyDetectionAuditor anomalyDetectionAuditor ,
4852 DataFrameAnalyticsAuditor dfaAuditor ,
4953 InferenceAuditor inferenceAuditor ,
50- TrainedModelStatsService trainedModelStatsService
54+ TrainedModelStatsService trainedModelStatsService ,
55+ FeatureService featureService
5156 ) {
5257 super (
5358 ResetMlComponentsAction .NAME ,
@@ -61,6 +66,20 @@ public TransportResetMlComponentsAction(
6166 this .dfaAuditor = dfaAuditor ;
6267 this .inferenceAuditor = inferenceAuditor ;
6368 this .trainedModelStatsService = trainedModelStatsService ;
69+ this .featureService = featureService ;
70+ }
71+
72+ @ Override
73+ protected void doExecute (
74+ Task task ,
75+ ResetMlComponentsAction .Request request ,
76+ ActionListener <ResetMlComponentsAction .Response > listener
77+ ) {
78+ if (featureService .clusterHasFeature (clusterService .state (), MachineLearningFeatures .COMPONENTS_RESET_ACTION ) == false ) {
79+ listener .onResponse (new ResetMlComponentsAction .Response (clusterService .getClusterName (), List .of (), List .of ()));
80+ } else {
81+ super .doExecute (task , request , listener );
82+ }
6483 }
6584
6685 @ Override
0 commit comments