Package ai.djl.serving.wlm
Class WorkerThread
- java.lang.Object
-
- ai.djl.serving.wlm.WorkerThread
-
- All Implemented Interfaces:
java.lang.Runnable
public final class WorkerThread extends java.lang.Object implements java.lang.RunnableTheWorkerThreadis the worker managed by theWorkLoadManager.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWorkerThread.BuilderA Builder to construct aWorkerThread.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static WorkerThread.Builderbuilder()Creates a builder to build aWorkerThread.intgetGpuId()Returns the gpu id used by the thread.longgetStartTime()Returns the thread start time.WorkerStategetState()Returns the worker state.intgetWorkerId()Returns the worker thread ID.booleanisFixPoolThread()check if this worker is instantiate is one of the fix threads of a pool.booleanisRunning()Returns true if the worker thread is running.voidrun()voidshutdown(WorkerState state)Shuts down the worker thread.
-
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
getWorkerId
public int getWorkerId()
Returns the worker thread ID.- Returns:
- the worker thread ID
-
isRunning
public boolean isRunning()
Returns true if the worker thread is running.- Returns:
- true if the worker thread is running
-
getGpuId
public int getGpuId()
Returns the gpu id used by the thread.- Returns:
- the gpu id used by the thread
-
getStartTime
public long getStartTime()
Returns the thread start time.- Returns:
- the thread start time
-
getState
public WorkerState getState()
Returns the worker state.- Returns:
- the worker state
-
shutdown
public void shutdown(WorkerState state)
Shuts down the worker thread.- Parameters:
state- the state to set the thread to
-
isFixPoolThread
public boolean isFixPoolThread()
check if this worker is instantiate is one of the fix threads of a pool. fix threads are not automatically scales down, so they are candidate for down scaling when minWorker/maxWorker size of a model changes.- Returns:
- the fixPoolThread
-
builder
public static WorkerThread.Builder builder()
Creates a builder to build aWorkerThread.- Returns:
- a new builder
-
-