use of org.opensearch.ml.stats.MLStats in project ml-commons by opensearch-project.
the class MachineLearningPlugin method createComponents.
@Override
public Collection<Object> createComponents(Client client, ClusterService clusterService, ThreadPool threadPool, ResourceWatcherService resourceWatcherService, ScriptService scriptService, NamedXContentRegistry xContentRegistry, Environment environment, NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, IndexNameExpressionResolver indexNameExpressionResolver, Supplier<RepositoriesService> repositoriesServiceSupplier) {
this.client = client;
this.threadPool = threadPool;
this.clusterService = clusterService;
Settings settings = environment.settings();
JvmService jvmService = new JvmService(environment.settings());
MLCircuitBreakerService mlCircuitBreakerService = new MLCircuitBreakerService(jvmService).init();
Map<String, MLStat<?>> stats = new ConcurrentHashMap<>();
stats.put(StatNames.ML_EXECUTING_TASK_COUNT, new MLStat<>(false, new CounterSupplier()));
stats.put(StatNames.ML_TOTAL_REQUEST_COUNT, new MLStat<>(false, new CounterSupplier()));
stats.put(StatNames.ML_TOTAL_FAILURE_COUNT, new MLStat<>(false, new CounterSupplier()));
stats.put(StatNames.ML_TOTAL_MODEL_COUNT, new MLStat<>(false, new CounterSupplier()));
this.mlStats = new MLStats(stats);
mlIndicesHandler = new MLIndicesHandler(clusterService, client);
mlTaskManager = new MLTaskManager(client, mlIndicesHandler);
mlInputDatasetHandler = new MLInputDatasetHandler(client);
MLTaskDispatcher mlTaskDispatcher = new MLTaskDispatcher(clusterService, client);
mlTrainingTaskRunner = new MLTrainingTaskRunner(threadPool, clusterService, client, mlTaskManager, mlStats, mlIndicesHandler, mlInputDatasetHandler, mlTaskDispatcher, mlCircuitBreakerService);
mlPredictTaskRunner = new MLPredictTaskRunner(threadPool, clusterService, client, mlTaskManager, mlStats, mlInputDatasetHandler, mlTaskDispatcher, mlCircuitBreakerService);
mlTrainAndPredictTaskRunner = new MLTrainAndPredictTaskRunner(threadPool, clusterService, client, mlTaskManager, mlStats, mlInputDatasetHandler, mlTaskDispatcher, mlCircuitBreakerService);
mlExecuteTaskRunner = new MLExecuteTaskRunner(threadPool, clusterService, client, mlTaskManager, mlStats, mlInputDatasetHandler, mlTaskDispatcher, mlCircuitBreakerService);
// Register thread-safe ML objects here.
LocalSampleCalculator localSampleCalculator = new LocalSampleCalculator(client, settings);
MLEngineClassLoader.register(FunctionName.LOCAL_SAMPLE_CALCULATOR, localSampleCalculator);
AnomalyLocalizerImpl anomalyLocalizer = new AnomalyLocalizerImpl(client, settings);
MLEngineClassLoader.register(FunctionName.ANOMALY_LOCALIZATION, anomalyLocalizer);
MLSearchHandler mlSearchHandler = new MLSearchHandler(client, xContentRegistry);
return ImmutableList.of(mlStats, mlTaskManager, mlIndicesHandler, mlInputDatasetHandler, mlTrainingTaskRunner, mlPredictTaskRunner, mlTrainAndPredictTaskRunner, mlExecuteTaskRunner, mlSearchHandler);
}
use of org.opensearch.ml.stats.MLStats in project ml-commons by opensearch-project.
the class MLStatsNodesTransportActionTests method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
clusterStatName1 = "clusterStat1";
nodeStatName1 = "nodeStat1";
statsMap = new HashMap<String, MLStat<?>>() {
{
put(nodeStatName1, new MLStat<>(false, new CounterSupplier()));
put(clusterStatName1, new MLStat<>(true, new CounterSupplier()));
put(InternalStatNames.JVM_HEAP_USAGE.getName(), new MLStat<>(true, new SettableSupplier()));
}
};
mlStats = new MLStats(statsMap);
Environment environment = mock(Environment.class);
Settings settings = Settings.builder().build();
when(environment.settings()).thenReturn(settings);
action = new MLStatsNodesTransportAction(client().threadPool(), clusterService(), mock(TransportService.class), mock(ActionFilters.class), mlStats, environment);
}
use of org.opensearch.ml.stats.MLStats in project ml-commons by opensearch-project.
the class RestStatsMLActionTests method setup.
@Before
public void setup() {
Map<String, MLStat<?>> statMap = ImmutableMap.<String, MLStat<?>>builder().put(StatNames.ML_EXECUTING_TASK_COUNT, new MLStat<>(false, new CounterSupplier())).build();
mlStats = new MLStats(statMap);
restAction = new RestStatsMLAction(mlStats);
}
Aggregations