15
15
import org .elasticsearch .common .Strings ;
16
16
import org .elasticsearch .common .io .stream .NamedWriteableRegistry ;
17
17
import org .elasticsearch .common .settings .Setting ;
18
+ import org .elasticsearch .common .settings .Settings ;
19
+ import org .elasticsearch .common .util .concurrent .EsExecutors ;
18
20
import org .elasticsearch .plugins .ActionPlugin ;
19
21
import org .elasticsearch .plugins .Plugin ;
20
22
import org .elasticsearch .tasks .Task ;
23
+ import org .elasticsearch .threadpool .ExecutorBuilder ;
24
+ import org .elasticsearch .threadpool .FixedExecutorBuilder ;
21
25
import org .elasticsearch .xpack .core .ml .packageloader .action .GetTrainedModelPackageConfigAction ;
22
26
import org .elasticsearch .xpack .core .ml .packageloader .action .LoadTrainedModelPackageAction ;
23
27
import org .elasticsearch .xpack .ml .packageloader .action .ModelDownloadTask ;
28
+ import org .elasticsearch .xpack .ml .packageloader .action .ModelImporter ;
24
29
import org .elasticsearch .xpack .ml .packageloader .action .TransportGetTrainedModelPackageConfigAction ;
25
30
import org .elasticsearch .xpack .ml .packageloader .action .TransportLoadTrainedModelPackage ;
26
31
@@ -44,16 +49,15 @@ public class MachineLearningPackageLoader extends Plugin implements ActionPlugin
44
49
Setting .Property .Dynamic
45
50
);
46
51
47
- // re-using thread pool setup by the ml plugin
48
- public static final String UTILITY_THREAD_POOL_NAME = "ml_utility" ;
49
-
50
52
// This link will be invalid for serverless, but serverless will never be
51
53
// air-gapped, so this message should never be needed.
52
54
private static final String MODEL_REPOSITORY_DOCUMENTATION_LINK = format (
53
55
"https://www.elastic.co/guide/en/machine-learning/%s/ml-nlp-elser.html#air-gapped-install" ,
54
56
Build .current ().version ().replaceFirst ("^(\\ d+\\ .\\ d+).*" , "$1" )
55
57
);
56
58
59
+ public static final String MODEL_DOWNLOAD_THREADPOOL_NAME = "model_download" ;
60
+
57
61
public MachineLearningPackageLoader () {}
58
62
59
63
@ Override
@@ -81,6 +85,24 @@ public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
81
85
);
82
86
}
83
87
88
+ @ Override
89
+ public List <ExecutorBuilder <?>> getExecutorBuilders (Settings settings ) {
90
+ return List .of (modelDownloadExecutor (settings ));
91
+ }
92
+
93
+ public static FixedExecutorBuilder modelDownloadExecutor (Settings settings ) {
94
+ // Threadpool with a fixed number of threads for
95
+ // downloading the model definition files
96
+ return new FixedExecutorBuilder (
97
+ settings ,
98
+ MODEL_DOWNLOAD_THREADPOOL_NAME ,
99
+ ModelImporter .NUMBER_OF_STREAMS ,
100
+ -1 , // unbounded queue size
101
+ "xpack.ml.model_download_thread_pool" ,
102
+ EsExecutors .TaskTrackingConfig .DO_NOT_TRACK
103
+ );
104
+ }
105
+
84
106
@ Override
85
107
public List <BootstrapCheck > getBootstrapChecks () {
86
108
return List .of (new BootstrapCheck () {
0 commit comments