Package ai.djl.serving.wlm
Class WorkLoadManager.WorkerPool<I,O>
- java.lang.Object
-
- ai.djl.serving.wlm.WorkLoadManager.WorkerPool<I,O>
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Enclosing class:
- WorkLoadManager
public final class WorkLoadManager.WorkerPool<I,O> extends java.lang.Object implements java.lang.AutoCloseableManages the work load for a single model.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classWorkLoadManager.WorkerPool.WorkerPoolDeviceTheWorkLoadManager.WorkerPool.WorkerPoolDevicemanages theWorkLoadManager.WorkerPoolfor a particularDevice.
-
Constructor Summary
Constructors Constructor Description WorkerPool(ModelInfo<I,O> 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()WorkLoadManager.WorkerPool.WorkerPoolDeviceforDevice(ai.djl.Device device)Returns theWorkLoadManager.WorkerPool.WorkerPoolDevicefor a particularDevice.java.util.concurrent.LinkedBlockingDeque<WorkerJob<I,O>>getJobQueue()Returns theJobQueuefor this model.intgetMaxWorkers()Returns the maximum number of workers for a model across all devices.intgetMinWorkers()Returns the minimum number of workers for a model across all devices.java.util.List<WorkerThread<I,O>>getWorkers()Returns a list of worker thread.voidlog()Logs the current state of thisWorkerPoolwhen level "Debug" is enabled.WorkLoadManager.WorkerPool<I,O>scaleWorkers(ai.djl.Device device, int newMinWorkers, int newMaxWorkers)Sets new worker capcities for this model.
-
-
-
Method Detail
-
getWorkers
public java.util.List<WorkerThread<I,O>> getWorkers()
Returns a list of worker thread.- Returns:
- the workers
-
getJobQueue
public java.util.concurrent.LinkedBlockingDeque<WorkerJob<I,O>> getJobQueue()
Returns theJobQueuefor this model.- Returns:
- the jobQueue
-
getMinWorkers
public int getMinWorkers()
Returns the minimum number of workers for a model across all devices.- Returns:
- the minimum number of workers for a model across all devices
-
getMaxWorkers
public int getMaxWorkers()
Returns the maximum number of workers for a model across all devices.- Returns:
- the maximum number of workers for a model across all devices
-
scaleWorkers
public WorkLoadManager.WorkerPool<I,O> scaleWorkers(ai.djl.Device device, int newMinWorkers, int newMaxWorkers)
Sets new worker capcities for this model.- Parameters:
device- the device for the model or cpu if nullnewMinWorkers- minimum amount of workers.newMaxWorkers- maximum amount of workers.- Returns:
- this
ModelInfo
-
forDevice
public WorkLoadManager.WorkerPool.WorkerPoolDevice forDevice(ai.djl.Device device)
Returns theWorkLoadManager.WorkerPool.WorkerPoolDevicefor a particularDevice.- Parameters:
device- the device for a worker pool- Returns:
- the
WorkLoadManager.WorkerPool.WorkerPoolDeviceor null if device is not used
-
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
-
-