Class ComputeJobAdapter

    • Constructor Detail

      • ComputeJobAdapter

        protected ComputeJobAdapter()
        No-arg constructor.
      • ComputeJobAdapter

        protected ComputeJobAdapter​(@Nullable
                                    @Nullable Object arg)
        Creates job with one arguments. This constructor exists for better backward compatibility with internal Ignite 2.x code.
        Parameters:
        arg - Job argument.
      • ComputeJobAdapter

        protected ComputeJobAdapter​(@Nullable
                                    @Nullable Object... args)
        Creates job with specified arguments.
        Parameters:
        args - Optional job arguments.
    • Method Detail

      • setArguments

        public void setArguments​(@Nullable
                                 @Nullable Object... args)
        Sets given arguments.
        Parameters:
        args - Optional job arguments to set.
      • cancel

        public void cancel()
        This method is called when system detects that completion of this job can no longer alter the overall outcome (for example, when parent task has already reduced the results). Job is also cancelled when IgniteFuture.cancel() is called.

        Note that job cancellation is only a hint, and just like with Thread.interrupt() method, it is really up to the actual job instance to gracefully finish execution and exit.

        Specified by:
        cancel in interface ComputeJob
      • isCancelled

        protected final boolean isCancelled()
        This method tests whether or not this job was cancelled. This method is thread-safe and can be called without extra synchronization.

        This method can be periodically called in ComputeJob.execute() method implementation to check whether or not this job cancelled. Note that system calls cancel() method only as a hint and this is a responsibility of the implementation of the job to properly cancel its execution.

        Returns:
        true if this job was cancelled, false otherwise.
      • argument

        @Nullable
        public <T> T argument​(int idx)
        Gets job argument.
        Type Parameters:
        T - Type of the argument to return.
        Parameters:
        idx - Index of the argument.
        Returns:
        Job argument.
        Throws:
        NullPointerException - Thrown in case when there no arguments set.
        IllegalArgumentException - Thrown if index is invalid.
      • arguments

        @Nullable
        protected @Nullable Object[] arguments()
        Gets array of job arguments. Note that changes to this array may affect job execution.
        Returns:
        Array of job arguments.