Interface OpChainScheduler
-
@ThreadSafe public interface OpChainSchedulerAn interface that defines different scheduling strategies to work with theOpChainSchedulerService.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidderegister(OpChain operatorChain)When the OpChain is finished, error or otherwise, deregister is called for it so the scheduler can do any required cleanup.OpChainnext(long time, TimeUnit timeUnit)Returns an OpChain that is ready to be run byOpChainSchedulerService, waiting for the given time if there are no such OpChains ready yet.voidonDataAvailable(OpChainId opChainId)A callback called whenever data is received for the given opChain.voidregister(OpChain operatorChain)Registers a new OpChain with the scheduler.voidshutdownNow()TODO: Figure out shutdown flow in context of graceful shutdown.intsize()voidyield(OpChain opChain)Used byOpChainSchedulerServiceto indicate that a given OpChain can be suspended until it receives some data.
-
-
-
Method Detail
-
register
void register(OpChain operatorChain)
Registers a new OpChain with the scheduler.- Parameters:
operatorChain- the operator chain to register
-
deregister
void deregister(OpChain operatorChain)
When the OpChain is finished, error or otherwise, deregister is called for it so the scheduler can do any required cleanup. After an OpChain is de-registered, the scheduler service will never call any other method for it. However, theonDataAvailable(org.apache.pinot.query.runtime.operator.OpChainId)callback may be called even after an OpChain is de-registered, and the scheduler should handle that scenario.- Parameters:
operatorChain- an operator chain that is finished (error or otherwise).
-
yield
void yield(OpChain opChain)
Used byOpChainSchedulerServiceto indicate that a given OpChain can be suspended until it receives some data. Note that this method is only used by the scheduler service to "indicate" that an OpChain can be suspended. The decision on whether to actually suspend or not can be taken by the scheduler.
-
onDataAvailable
void onDataAvailable(OpChainId opChainId)
A callback called whenever data is received for the given opChain. This can be used by the scheduler implementations to re-scheduled suspended OpChains. This method may be called for an OpChain that has not yet been scheduled, or an OpChain that has already been de-registered.- Parameters:
opChainId- theOpChainID
-
next
@Nullable OpChain next(long time, TimeUnit timeUnit) throws InterruptedException
Returns an OpChain that is ready to be run byOpChainSchedulerService, waiting for the given time if there are no such OpChains ready yet. Will return null if there's no ready OpChains even after the specified time.- Parameters:
time- non-negative value that determines the time the scheduler will wait for new OpChains to be ready.timeUnit- TimeUnit for the await time.- Returns:
- a non-null OpChain that's ready to be run, or null if there's no OpChain ready even after waiting for the given time.
- Throws:
InterruptedException- if the wait for a ready OpChain was interrupted.
-
size
int size()
- Returns:
- the number of operator chains registered with the scheduler
-
shutdownNow
void shutdownNow()
TODO: Figure out shutdown flow in context of graceful shutdown.
-
-