Interface OpChainScheduler


  • @ThreadSafe
    public interface OpChainScheduler
    An interface that defines different scheduling strategies to work with the OpChainSchedulerService.
    • 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, the onDataAvailable(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 by OpChainSchedulerService to 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 - the OpChain ID
      • next

        @Nullable
        OpChain next​(long time,
                     TimeUnit timeUnit)
              throws InterruptedException
        Returns an OpChain that is ready to be run by OpChainSchedulerService, 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.