55
55
import org .opensearch .env .Environment ;
56
56
import org .opensearch .env .NodeEnvironment ;
57
57
import org .opensearch .indices .SystemIndexDescriptor ;
58
+ import org .opensearch .jobscheduler .spi .JobSchedulerExtension ;
59
+ import org .opensearch .jobscheduler .spi .ScheduledJobParser ;
60
+ import org .opensearch .jobscheduler .spi .ScheduledJobRunner ;
58
61
import org .opensearch .ml .action .agents .DeleteAgentTransportAction ;
59
62
import org .opensearch .ml .action .agents .GetAgentTransportAction ;
60
63
import org .opensearch .ml .action .agents .TransportRegisterAgentAction ;
111
114
import org .opensearch .ml .cluster .DiscoveryNodeHelper ;
112
115
import org .opensearch .ml .cluster .MLCommonsClusterEventListener ;
113
116
import org .opensearch .ml .cluster .MLCommonsClusterManagerEventListener ;
117
+ import org .opensearch .ml .common .CommonValue ;
114
118
import org .opensearch .ml .common .FunctionName ;
115
119
import org .opensearch .ml .common .input .execute .anomalylocalization .AnomalyLocalizationInput ;
116
120
import org .opensearch .ml .common .input .execute .metricscorrelation .MetricsCorrelationInput ;
199
203
import org .opensearch .ml .engine .utils .AgentModelsSearcher ;
200
204
import org .opensearch .ml .helper .ConnectorAccessControlHelper ;
201
205
import org .opensearch .ml .helper .ModelAccessControlHelper ;
202
- import org .opensearch .ml .jobs .MLBatchTaskUpdateJobRunner ;
206
+ import org .opensearch .ml .jobs .MLJobParameter ;
207
+ import org .opensearch .ml .jobs .MLJobRunner ;
203
208
import org .opensearch .ml .memory .ConversationalMemoryHandler ;
204
209
import org .opensearch .ml .memory .action .conversation .CreateConversationAction ;
205
210
import org .opensearch .ml .memory .action .conversation .CreateConversationTransportAction ;
293
298
import org .opensearch .ml .stats .MLNodeLevelStat ;
294
299
import org .opensearch .ml .stats .MLStat ;
295
300
import org .opensearch .ml .stats .MLStats ;
301
+ import org .opensearch .ml .stats .otel .counters .MLOperationalMetricsCounter ;
296
302
import org .opensearch .ml .stats .suppliers .CounterSupplier ;
297
303
import org .opensearch .ml .stats .suppliers .IndexStatusSupplier ;
298
304
import org .opensearch .ml .task .MLExecuteTaskRunner ;
313
319
import org .opensearch .plugins .SearchPipelinePlugin ;
314
320
import org .opensearch .plugins .SearchPlugin ;
315
321
import org .opensearch .plugins .SystemIndexPlugin ;
322
+ import org .opensearch .plugins .TelemetryAwarePlugin ;
316
323
import org .opensearch .remote .metadata .client .SdkClient ;
317
324
import org .opensearch .remote .metadata .client .impl .SdkClientFactory ;
318
325
import org .opensearch .repositories .RepositoriesService ;
326
333
import org .opensearch .searchpipelines .questionanswering .generative .GenerativeQARequestProcessor ;
327
334
import org .opensearch .searchpipelines .questionanswering .generative .GenerativeQAResponseProcessor ;
328
335
import org .opensearch .searchpipelines .questionanswering .generative .ext .GenerativeQAParamExtBuilder ;
336
+ import org .opensearch .telemetry .metrics .MetricsRegistry ;
337
+ import org .opensearch .telemetry .tracing .Tracer ;
329
338
import org .opensearch .threadpool .ExecutorBuilder ;
330
339
import org .opensearch .threadpool .FixedExecutorBuilder ;
331
340
import org .opensearch .threadpool .ThreadPool ;
@@ -343,7 +352,9 @@ public class MachineLearningPlugin extends Plugin
343
352
SearchPipelinePlugin ,
344
353
ExtensiblePlugin ,
345
354
IngestPlugin ,
346
- SystemIndexPlugin {
355
+ SystemIndexPlugin ,
356
+ TelemetryAwarePlugin ,
357
+ JobSchedulerExtension {
347
358
public static final String ML_THREAD_POOL_PREFIX = "thread_pool.ml_commons." ;
348
359
public static final String GENERAL_THREAD_POOL = "opensearch_ml_general" ;
349
360
public static final String SDK_CLIENT_THREAD_POOL = "opensearch_ml_sdkclient" ;
@@ -356,6 +367,8 @@ public class MachineLearningPlugin extends Plugin
356
367
public static final String DEPLOY_THREAD_POOL = "opensearch_ml_deploy" ;
357
368
public static final String ML_BASE_URI = "/_plugins/_ml" ;
358
369
370
+ public static final String ML_COMMONS_JOBS_TYPE = "opensearch_ml_commons_jobs" ;
371
+
359
372
private MLStats mlStats ;
360
373
private MLModelCacheHelper modelCacheHelper ;
361
374
private MLTaskManager mlTaskManager ;
@@ -398,11 +411,13 @@ public class MachineLearningPlugin extends Plugin
398
411
private ScriptService scriptService ;
399
412
private Encryptor encryptor ;
400
413
401
- public MachineLearningPlugin (Settings settings ) {
402
- // Handle this here as this feature is tied to Search/Query API, not to a ml-common API
403
- // and as such, it can't be lazy-loaded when a ml-commons API is invoked.
404
- this .ragSearchPipelineEnabled = MLCommonsSettings .ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED .get (settings );
405
- }
414
+ // public MachineLearningPlugin(Settings settings) {
415
+ // // Handle this here as this feature is tied to Search/Query API, not to a ml-common API
416
+ // // and as such, it can't be lazy-loaded when a ml-commons API is invoked.
417
+ // this.ragSearchPipelineEnabled = MLCommonsSettings.ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED.get(settings);
418
+ // }
419
+
420
+ public MachineLearningPlugin () {}
406
421
407
422
@ Override
408
423
public List <ActionHandler <? extends ActionRequest , ? extends ActionResponse >> getActions () {
@@ -485,7 +500,9 @@ public Collection<Object> createComponents(
485
500
NodeEnvironment nodeEnvironment ,
486
501
NamedWriteableRegistry namedWriteableRegistry ,
487
502
IndexNameExpressionResolver indexNameExpressionResolver ,
488
- Supplier <RepositoriesService > repositoriesServiceSupplier
503
+ Supplier <RepositoriesService > repositoriesServiceSupplier ,
504
+ Tracer tracer ,
505
+ MetricsRegistry metricsRegistry
489
506
) {
490
507
this .indexUtils = new IndexUtils (client , clusterService );
491
508
this .client = client ;
@@ -723,7 +740,11 @@ public Collection<Object> createComponents(
723
740
.getClusterSettings ()
724
741
.addSettingsUpdateConsumer (MLCommonsSettings .ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED , it -> ragSearchPipelineEnabled = it );
725
742
726
- MLBatchTaskUpdateJobRunner .getJobRunnerInstance ().initialize (clusterService , threadPool , client );
743
+ MLJobRunner .getInstance ().initialize (clusterService , threadPool , client );
744
+
745
+ // todo: add setting
746
+ MLOperationalMetricsCounter .initialize (clusterService .getClusterName ().toString (), metricsRegistry );
747
+ // MLAdoptionMetricsCounter.initialize(clusterService.getClusterName().toString(), metricsRegistry);
727
748
728
749
return ImmutableList
729
750
.of (
@@ -1174,4 +1195,24 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
1174
1195
systemIndexDescriptors .add (new SystemIndexDescriptor (ML_STOP_WORDS_INDEX , "ML Commons Stop Words Index" ));
1175
1196
return systemIndexDescriptors ;
1176
1197
}
1198
+
1199
+ @ Override
1200
+ public String getJobType () {
1201
+ return ML_COMMONS_JOBS_TYPE ;
1202
+ }
1203
+
1204
+ @ Override
1205
+ public String getJobIndex () {
1206
+ return CommonValue .ML_JOBS_INDEX ;
1207
+ }
1208
+
1209
+ @ Override
1210
+ public ScheduledJobRunner getJobRunner () {
1211
+ return MLJobRunner .getInstance ();
1212
+ }
1213
+
1214
+ @ Override
1215
+ public ScheduledJobParser getJobParser () {
1216
+ return (parser , id , jobDocVersion ) -> MLJobParameter .parse (parser );
1217
+ }
1177
1218
}
0 commit comments