Class GridWorker

    • Field Detail

      • isCancelled

        protected final AtomicBoolean isCancelled
        Whether or not this runnable is cancelled.
    • Constructor Detail

      • GridWorker

        protected GridWorker​(String igniteInstanceName,
                             String name,
                             IgniteLogger log,
                             @Nullable
                             @Nullable GridWorkerListener lsnr)
        Creates new grid worker with given parameters.
        Parameters:
        igniteInstanceName - Name of the Ignite instance this runnable is used in.
        name - Worker name. Note that in general thread name and worker (runnable) name are two different things. The same worker can be executed by multiple threads and therefore for logging and debugging purposes we separate the two.
        log - Grid logger to be used.
        lsnr - Listener for life-cycle events.
      • GridWorker

        protected GridWorker​(@Nullable
                             @Nullable String igniteInstanceName,
                             String name,
                             IgniteLogger log)
        Creates new grid worker with given parameters.
        Parameters:
        igniteInstanceName - Name of the Ignite instance this runnable is used in.
        name - Worker name. Note that in general thread name and worker (runnable) name are two different things. The same worker can be executed by multiple threads and therefore for logging and debugging purposes we separate the two.
        log - Grid logger to be used.
    • Method Detail

      • run

        public final void run()
        Specified by:
        run in interface Runnable
      • cleanup

        protected void cleanup()
        Optional method that will be called after runnable is finished. Default implementation is no-op.
      • runner

        @Nullable
        public @Nullable Thread runner()
        Returns:
        Runner thread, null if the worker has not yet started executing.
      • igniteInstanceName

        public String igniteInstanceName()
        Gets name of the Ignite instance this runnable belongs to.
        Returns:
        Name of the Ignite instance this runnable belongs to.
      • name

        public String name()
        Gets this runnable name.
        Returns:
        This runnable name.
      • cancel

        public void cancel()
        Cancels this runnable.
      • isCancelled

        public boolean isCancelled()
        Tests whether or not this runnable is cancelled.
        Returns:
        true if this runnable is cancelled - false otherwise.
        See Also:
        Future.isCancelled()
      • isDone

        public boolean isDone()
        Tests whether or not this runnable is finished.
        Returns:
        true if this runnable is finished - false otherwise.
      • updateHeartbeat

        public void updateHeartbeat()
        Notifying dispatcher that work is in progress and thread didn't freeze.
        Specified by:
        updateHeartbeat in interface WorkProgressDispatcher
      • onIdle

        protected void onIdle()
        Can be called from runner() thread to perform idleness handling.
      • onCancel

        protected void onCancel​(boolean firstCancelRequest)
        Callback on runner cancellation.
        Parameters:
        firstCancelRequest - Flag indicating that worker cancellation was requested for the first time.
      • onCancelledBeforeWorkerScheduled

        protected void onCancelledBeforeWorkerScheduled()
        Callback on special case, when task is cancelled before is has been scheduled.