Package ai.djl.serving.wlm
Class PermanentBatchAggregator<I,O>
- java.lang.Object
-
- ai.djl.serving.wlm.PermanentBatchAggregator<I,O>
-
public class PermanentBatchAggregator<I,O> extends java.lang.Objecta batch aggregator that never terminates by itself. the surrounding thread has to be interrupted by sending an interrupt signal.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddrainTo(java.util.List<WorkerJob<I,O>> list, int maxDelay)java.util.List<I>getRequest()Poll the queue and return a list of Input Objects for the model.booleanisFinished()Checks if thisBatchAggregatorand the thread can be shutdown or if this aggregator waits for more data.protected java.util.List<WorkerJob<I,O>>pollBatch()Fills in the list with a batch of jobs.voidsendError(java.lang.Throwable error)Completes the job with an error.voidsendResponse(java.util.List<O> outputs)Sends to response to all waiting clients.
-
-
-
Method Detail
-
pollBatch
protected java.util.List<WorkerJob<I,O>> pollBatch() throws java.lang.InterruptedException
Fills in the list with a batch of jobs.- Returns:
- a list of jobs read by this batch interation.
- Throws:
java.lang.InterruptedException- if interrupted
-
isFinished
public boolean isFinished()
Checks if thisBatchAggregatorand the thread can be shutdown or if this aggregator waits for more data.- Returns:
- true if we can shutdown the thread. for example when max idle time exceeded in temporary batch aggregator.
-
getRequest
public java.util.List<I> getRequest() throws java.lang.InterruptedExceptionPoll the queue and return a list of Input Objects for the model.- Returns:
- list of input objects to pass to the model.
- Throws:
java.lang.InterruptedException- if thread gets interrupted while waiting for new data in the queue.
-
sendResponse
public void sendResponse(java.util.List<O> outputs)
Sends to response to all waiting clients.- Parameters:
outputs- list of model-outputs in same order as the input objects.
-
sendError
public void sendError(java.lang.Throwable error)
Completes the job with an error.- Parameters:
error- the exception
-
drainTo
protected void drainTo(java.util.List<WorkerJob<I,O>> list, int maxDelay) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
-