28
28
import org .opensearch .common .xcontent .NamedXContentRegistry ;
29
29
import org .opensearch .env .Environment ;
30
30
import org .opensearch .env .NodeEnvironment ;
31
+ import org .opensearch .ml .action .prediction .MLPredictionTaskExecutionAction ;
32
+ import org .opensearch .ml .action .prediction .MLPredictionTaskExecutionTransportAction ;
33
+ import org .opensearch .ml .action .prediction .TransportPredictionTaskAction ;
31
34
import org .opensearch .ml .action .stats .MLStatsNodesAction ;
32
35
import org .opensearch .ml .action .stats .MLStatsNodesTransportAction ;
36
+ import org .opensearch .ml .action .training .MLTrainingTaskExecutionAction ;
37
+ import org .opensearch .ml .action .training .MLTrainingTaskExecutionTransportAction ;
38
+ import org .opensearch .ml .action .training .TransportTrainingTaskAction ;
39
+ import org .opensearch .ml .common .transport .prediction .MLPredictionTaskAction ;
40
+ import org .opensearch .ml .common .transport .training .MLTrainingTaskAction ;
33
41
import org .opensearch .ml .rest .RestStatsMLAction ;
34
42
import org .opensearch .ml .stats .MLStat ;
35
43
import org .opensearch .ml .stats .MLStats ;
44
52
import org .opensearch .rest .RestController ;
45
53
import org .opensearch .rest .RestHandler ;
46
54
import org .opensearch .script .ScriptService ;
55
+ import org .opensearch .threadpool .ExecutorBuilder ;
56
+ import org .opensearch .threadpool .FixedExecutorBuilder ;
47
57
import org .opensearch .threadpool .ThreadPool ;
48
58
import org .opensearch .watcher .ResourceWatcherService ;
49
59
50
60
import java .util .Collection ;
61
+ import java .util .Collections ;
51
62
import java .util .List ;
52
63
import java .util .Map ;
53
64
import java .util .function .Supplier ;
54
65
55
66
public class MachineLearningPlugin extends Plugin implements ActionPlugin {
67
+ public static final String TASK_THREAD_POOL = "OPENSEARCH_ML_TASK_THREAD_POOL" ;
56
68
public static final String ML_BASE_URI = "/_opensearch/_ml" ;
57
69
58
70
private MLStats mlStats ;
@@ -72,7 +84,12 @@ public Setting<Boolean> legacySetting() {
72
84
public List <ActionHandler <? extends ActionRequest , ? extends ActionResponse >> getActions () {
73
85
return ImmutableList .of (
74
86
new ActionHandler <>(MLStatsNodesAction .INSTANCE ,
75
- MLStatsNodesTransportAction .class )
87
+ MLStatsNodesTransportAction .class ),
88
+ new ActionHandler <>(MLPredictionTaskAction .INSTANCE , TransportPredictionTaskAction .class ),
89
+ new ActionHandler <>(MLTrainingTaskAction .INSTANCE , TransportTrainingTaskAction .class ),
90
+ new ActionHandler <>(MLPredictionTaskExecutionAction .INSTANCE ,
91
+ MLPredictionTaskExecutionTransportAction .class ),
92
+ new ActionHandler <>(MLTrainingTaskExecutionAction .INSTANCE , MLTrainingTaskExecutionTransportAction .class )
76
93
);
77
94
}
78
95
@@ -109,4 +126,18 @@ public List<RestHandler> getRestHandlers(
109
126
restStatsMLAction
110
127
);
111
128
}
129
+
130
+ @ Override
131
+ public List <ExecutorBuilder <?>> getExecutorBuilders (Settings settings ) {
132
+ FixedExecutorBuilder ml = new FixedExecutorBuilder (
133
+ settings ,
134
+ TASK_THREAD_POOL ,
135
+ 4 ,
136
+ 4 ,
137
+ "ml.task_thread_pool" ,
138
+ false
139
+ );
140
+
141
+ return Collections .singletonList (ml );
142
+ }
112
143
}
0 commit comments