-
Notifications
You must be signed in to change notification settings - Fork 58
/
WlmConfigManager.java
154 lines (136 loc) · 4.16 KB
/
WlmConfigManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package ai.djl.serving.wlm.util;
/** This manages some configurations used by the {@link ai.djl.serving.wlm.WorkLoadManager}. */
public final class WlmConfigManager {
private int jobQueueSize = 1000;
private int maxIdleSeconds = 60;
private int batchSize = 1;
private int maxBatchDelayMillis = 100;
private int reservedMemoryMb = 500;
private String loadOnDevices;
private static final WlmConfigManager INSTANCE = new WlmConfigManager();
private WlmConfigManager() {}
/**
* Returns the singleton {@code ConfigManager} instance.
*
* @return the singleton {@code ConfigManager} instance
*/
public static WlmConfigManager getInstance() {
return INSTANCE;
}
/**
* Returns if debug is enabled.
*
* @return {@code true} if debug is enabled
*/
public boolean isDebug() {
return Boolean.getBoolean("ai.djl.serving.debug");
}
/**
* Returns the default job queue size.
*
* @return the default job queue size
*/
public int getJobQueueSize() {
return jobQueueSize;
}
/**
* Sets the default job queue size.
*
* @param jobQueueSize the new default job queue size
*/
public void setJobQueueSize(int jobQueueSize) {
this.jobQueueSize = jobQueueSize;
}
/**
* Returns the default max idle time for workers.
*
* @return the default max idle time
*/
public int getMaxIdleSeconds() {
return maxIdleSeconds;
}
/**
* Sets the default max idle time in seconds for workers.
*
* @param maxIdleSeconds the new default max idle time in seconds
*/
public void setMaxIdleSeconds(int maxIdleSeconds) {
this.maxIdleSeconds = maxIdleSeconds;
}
/**
* Returns the default batchSize for workers.
*
* @return the default max idle time
*/
public int getBatchSize() {
return batchSize;
}
/**
* Sets the default batchSize for workers.
*
* @param batchSize the new default batchSize
*/
public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}
/**
* Returns the default max batch delay in milliseconds for the working queue.
*
* @return the default max batch delay in milliseconds
*/
public int getMaxBatchDelayMillis() {
return maxBatchDelayMillis;
}
/**
* Sets the default max batch delay in milliseconds for the working queue.
*
* @param maxBatchDelayMillis the new default max batch delay in milliseconds
*/
public void setMaxBatchDelayMillis(int maxBatchDelayMillis) {
this.maxBatchDelayMillis = maxBatchDelayMillis;
}
/**
* Returns the default reserved memory in MB.
*
* @return the default reserved memory in MB
*/
public int getReservedMemoryMb() {
return reservedMemoryMb;
}
/**
* Sets the reserved memory in MB.
*
* @param reservedMemoryMb the reserved memory in MB
*/
public void setReservedMemoryMb(int reservedMemoryMb) {
this.reservedMemoryMb = reservedMemoryMb;
}
/**
* Returns the devices the model will be loaded on at startup.
*
* @return the devices the model will be loaded on at startup
*/
public String getLoadOnDevices() {
return loadOnDevices;
}
/**
* Sets the devices the model will be loaded on at startup.
*
* @param loadOnDevices thes the default model will be loaded on at startup
*/
public void setLoadOnDevices(String loadOnDevices) {
this.loadOnDevices = loadOnDevices;
}
}