1212import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_CONTROLLER_ENABLED ;
1313import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_LOCAL_MODEL_ENABLED ;
1414import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_MCP_SERVER_ENABLED ;
15+ import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_METRIC_COLLECTION_ENABLED ;
1516import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_MULTI_TENANCY_ENABLED ;
1617import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED ;
1718import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_OFFLINE_BATCH_INGESTION_ENABLED ;
19+ import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED ;
1820import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_REMOTE_INFERENCE_ENABLED ;
21+ import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_STATIC_METRIC_COLLECTION_ENABLED ;
1922
2023import java .util .ArrayList ;
2124import java .util .List ;
@@ -43,6 +46,11 @@ public class MLFeatureEnabledSetting {
4346
4447 private volatile Boolean isMcpServerEnabled ;
4548
49+ private volatile Boolean isRagSearchPipelineEnabled ;
50+
51+ private volatile Boolean isMetricCollectionEnabled ;
52+ private volatile Boolean isStaticMetricCollectionEnabled ;
53+
4654 private final List <SettingsChangeListener > listeners = new ArrayList <>();
4755
4856 public MLFeatureEnabledSetting (ClusterService clusterService , Settings settings ) {
@@ -55,6 +63,9 @@ public MLFeatureEnabledSetting(ClusterService clusterService, Settings settings)
5563 isBatchInferenceEnabled = ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED .get (settings );
5664 isMultiTenancyEnabled = ML_COMMONS_MULTI_TENANCY_ENABLED .get (settings );
5765 isMcpServerEnabled = ML_COMMONS_MCP_SERVER_ENABLED .get (settings );
66+ isRagSearchPipelineEnabled = ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED .get (settings );
67+ isMetricCollectionEnabled = ML_COMMONS_METRIC_COLLECTION_ENABLED .get (settings );
68+ isStaticMetricCollectionEnabled = ML_COMMONS_STATIC_METRIC_COLLECTION_ENABLED .get (settings );
5869
5970 clusterService
6071 .getClusterSettings ()
@@ -74,6 +85,15 @@ public MLFeatureEnabledSetting(ClusterService clusterService, Settings settings)
7485 .getClusterSettings ()
7586 .addSettingsUpdateConsumer (ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED , it -> isBatchInferenceEnabled = it );
7687 clusterService .getClusterSettings ().addSettingsUpdateConsumer (ML_COMMONS_MCP_SERVER_ENABLED , it -> isMcpServerEnabled = it );
88+ clusterService
89+ .getClusterSettings ()
90+ .addSettingsUpdateConsumer (MLCommonsSettings .ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED , it -> isRagSearchPipelineEnabled = it );
91+ clusterService
92+ .getClusterSettings ()
93+ .addSettingsUpdateConsumer (ML_COMMONS_METRIC_COLLECTION_ENABLED , it -> isMetricCollectionEnabled = it );
94+ clusterService
95+ .getClusterSettings ()
96+ .addSettingsUpdateConsumer (ML_COMMONS_STATIC_METRIC_COLLECTION_ENABLED , it -> isStaticMetricCollectionEnabled = it );
7797 }
7898
7999 /**
@@ -148,6 +168,22 @@ public void addListener(SettingsChangeListener listener) {
148168 listeners .add (listener );
149169 }
150170
171+ /**
172+ * Whether the rag search pipeline feature is enabled. If disabled, APIs in ml-commons will block rag search pipeline.
173+ * @return whether the feature is enabled.
174+ */
175+ public boolean isRagSearchPipelineEnabled () {
176+ return isRagSearchPipelineEnabled ;
177+ }
178+
179+ public boolean isMetricCollectionEnabled () {
180+ return isMetricCollectionEnabled ;
181+ }
182+
183+ public boolean isStaticMetricCollectionEnabled () {
184+ return isStaticMetricCollectionEnabled ;
185+ }
186+
151187 @ VisibleForTesting
152188 public void notifyMultiTenancyListeners (boolean isEnabled ) {
153189 for (SettingsChangeListener listener : listeners ) {
0 commit comments