Package ai.djl.serving.wlm
Class WorkLoadManager
java.lang.Object
ai.djl.serving.wlm.WorkLoadManager
WorkLoadManager is responsible to manage the work load of worker thread. the manage scales
up/down the required amount of worker threads per wpc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close all wpcs related to theWorkloadManager.intgetNumRunningWorkers(WorkerPoolConfig<?, ?> wpc) Returns the number of running workers of a wpc.<I,O> WorkerPool<I, O> getWorkerPool(WorkerPoolConfig<I, O> wpc) Returns theWorkerPoolfor a model.<I,O> WorkerPool<I, O> Returns theWorkerPoolfor a wpc.<I,O> WorkerPool<I, O> registerWorkerPool(WorkerPoolConfig<I, O> wpc) Registers aWorkerPool(model).<I,O> CompletableFuture<O> Adds an inference job to the job queue of the next free worker.voidunregisterWorkerPool(WorkerPoolConfig<?, ?> wpc) Removes a worker pool from management.
-
Constructor Details
-
WorkLoadManager
public WorkLoadManager()Constructs aWorkLoadManagerinstance.
-
-
Method Details
-
registerWorkerPool
Registers aWorkerPool(model).This operation is idempotent and will return the existing workerpool if the wpc was already registered.
- Type Parameters:
I- the wpc input classO- the wpc output class- Parameters:
wpc- the wpc to create the worker pool for- Returns:
- the
WorkerPool
-
unregisterWorkerPool
Removes a worker pool from management.- Parameters:
wpc- the wpc to remove
-
runJob
Adds an inference job to the job queue of the next free worker. scales up worker if necessary.- Type Parameters:
I- the wpc input classO- the wpc output class- Parameters:
job- an inference job to be executed.- Returns:
trueif submit success, false otherwise.
-
getNumRunningWorkers
Returns the number of running workers of a wpc. running workers are workers which are not stopped, in error or scheduled to scale down.- Parameters:
wpc- the wpc we are interested in.- Returns:
- number of running workers.
-
getWorkerPoolById
Returns theWorkerPoolfor a wpc.- Type Parameters:
I- the wpc classO- the wpc class- Parameters:
id- the wpc id- Returns:
- the
WorkerPool
-
getWorkerPool
Returns theWorkerPoolfor a model.- Type Parameters:
I- the wpc input classO- the wpc output class- Parameters:
wpc- the worker type to get the worker pool for- Returns:
- the
WorkerPool
-
close
public void close()Close all wpcs related to theWorkloadManager.
-