Package ai.djl.serving.wlm
Class WorkLoadManager.WorkerPool
- java.lang.Object
-
- ai.djl.serving.wlm.WorkLoadManager.WorkerPool
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Enclosing class:
- WorkLoadManager
public final class WorkLoadManager.WorkerPool extends java.lang.Object implements java.lang.AutoCloseableManages the work load for a single model.
-
-
Constructor Summary
Constructors Constructor Description WorkerPool(ModelInfo model)Construct and initial data structure.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanup()removes all stopped workers and workers in state error from the pool.voidclose()java.util.concurrent.LinkedBlockingDeque<WorkerJob>getJobQueue()Returns theJobQueuefor this model.intgetMaxWorkers()Returns the maximum number of workers for a model.intgetMinWorkers()Returns the minimum number of workers for a model.java.util.List<WorkerThread>getWorkers()Returns a list of worker thread.voidlog()Logs the current state of thisWorkerPoolwhen level "Debug" is enabled.WorkLoadManager.WorkerPoolscaleWorkers(java.lang.String deviceName, int newMinWorkers, int newMaxWorkers)Sets new worker capcities for this model.
-
-
-
Constructor Detail
-
WorkerPool
public WorkerPool(ModelInfo model)
Construct and initial data structure.- Parameters:
model- the model this WorkerPool belongs to.
-
-
Method Detail
-
getWorkers
public java.util.List<WorkerThread> getWorkers()
Returns a list of worker thread.- Returns:
- the workers
-
getJobQueue
public java.util.concurrent.LinkedBlockingDeque<WorkerJob> getJobQueue()
Returns theJobQueuefor this model.- Returns:
- the jobQueue
-
getMinWorkers
public int getMinWorkers()
Returns the minimum number of workers for a model.- Returns:
- the minimum number of workers for a model
-
getMaxWorkers
public int getMaxWorkers()
Returns the maximum number of workers for a model.- Returns:
- the maximum number of workers for a model
-
scaleWorkers
public WorkLoadManager.WorkerPool scaleWorkers(java.lang.String deviceName, int newMinWorkers, int newMaxWorkers)
Sets new worker capcities for this model.- Parameters:
deviceName- the device for the modelnewMinWorkers- minimum amount of workers.newMaxWorkers- maximum amount of workers.- Returns:
- this
ModelInfo
-
log
public void log()
Logs the current state of thisWorkerPoolwhen level "Debug" is enabled.Logs all thread-ids in the pool.
-
cleanup
public void cleanup()
removes all stopped workers and workers in state error from the pool.
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
-