Package ai.djl.serving.wlm
Class WorkLoadManager
- java.lang.Object
-
- ai.djl.serving.wlm.WorkLoadManager
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class WorkLoadManager extends java.lang.Object implements java.lang.AutoCloseableWorkLoadManager is responsible to manage the work load of worker thread. the manage scales up/down the required amount of worker threads per model.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classWorkLoadManager.WorkerPoolManages the work load for a single model.
-
Constructor Summary
Constructors Constructor Description WorkLoadManager()Constructs aWorkLoadManagerinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intgetNumRunningWorkers(ModelInfo modelInfo)Returns the number of running workers of a model.intgetQueueLength(ModelInfo modelInfo)Returns the current number of request in the queue.WorkLoadManager.WorkerPoolgetWorkerPoolForModel(ModelInfo modelInfo)Returns theWorkLoadManager.WorkerPoolfor a model.java.util.List<WorkerThread>getWorkers(ModelInfo modelInfo)Returns the workers for the specific model.java.util.concurrent.CompletableFuture<ai.djl.modality.Output>runJob(Job job)Adds an inference job to the job queue of the next free worker.voidunregisterModel(ModelInfo model)Removes a model from management.
-
-
-
Constructor Detail
-
WorkLoadManager
public WorkLoadManager()
Constructs aWorkLoadManagerinstance.
-
-
Method Detail
-
getWorkers
public java.util.List<WorkerThread> getWorkers(ModelInfo modelInfo)
Returns the workers for the specific model.- Parameters:
modelInfo- the name of the model we are looking for.- Returns:
- the list of workers responsible to handle predictions for this model.
-
unregisterModel
public void unregisterModel(ModelInfo model)
Removes a model from management.- Parameters:
model- the model to remove
-
runJob
public java.util.concurrent.CompletableFuture<ai.djl.modality.Output> runJob(Job job)
Adds an inference job to the job queue of the next free worker. scales up worker if necessary.- Parameters:
job- an inference job to be executed.- Returns:
trueif submit success, false otherwise.
-
getNumRunningWorkers
public int getNumRunningWorkers(ModelInfo modelInfo)
Returns the number of running workers of a model. running workers are workers which are not stopped, in error or scheduled to scale down.- Parameters:
modelInfo- the model we are interested in.- Returns:
- number of running workers.
-
getQueueLength
public int getQueueLength(ModelInfo modelInfo)
Returns the current number of request in the queue.- Parameters:
modelInfo- the model- Returns:
- the current number of request in the queue
-
getWorkerPoolForModel
public WorkLoadManager.WorkerPool getWorkerPoolForModel(ModelInfo modelInfo)
Returns theWorkLoadManager.WorkerPoolfor a model.- Parameters:
modelInfo- the model to get the worker pool for- Returns:
- the
WorkLoadManager.WorkerPool
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-