Class StatefulTaskProgressSink

java.lang.Object
com.atlassian.jira.task.StatefulTaskProgressSink
All Implemented Interfaces:
TaskProgressSink
Direct Known Subclasses:
TimeBasedLogSink

public class StatefulTaskProgressSink extends Object implements TaskProgressSink
A simple TaskProgressSink thats keeps track of progress. It keeps track of the last progress stored sent. The actual reporting of progress will be made through another sink.
Since:
v3.13
  • Constructor Details

    • StatefulTaskProgressSink

      public StatefulTaskProgressSink(long minProgress, long maxProgress, long currentProgress, TaskProgressSink delegateSink)
      Create the sink.
      Parameters:
      minProgress - the smallest task progress that the sink can report.
      maxProgress - the largest task progress that the sink can report.
      currentProgress - the initial task progress stored within the sink.
      delegateSink - the sink that will be used for reporting.
    • StatefulTaskProgressSink

      public StatefulTaskProgressSink(long minProgress, long maxProgress, TaskProgressSink delegateSink)
      Create the sink. The initial current progress stored in the sink will be set to its configured minimum.
      Parameters:
      minProgress - the smallest task progress that the sink can report.
      maxProgress - the largest task progress that the sink can report.
      delegateSink - the sink that will be used for reporting.
  • Method Details

    • makeProgress

      public void makeProgress(long taskProgress, String currentSubTask, String message)
      This method can be called to indicate that progress is being made by a task.
      Specified by:
      makeProgress in interface TaskProgressSink
      Parameters:
      taskProgress - the current status of the task. This value will be clamped between the minimum and maximum progress specified when the object is constructed.
      currentSubTask - the name of the current sub task or null if there isn't one
      message - an optional message about the progress or null
    • makeProgressIncrement

      public void makeProgressIncrement(long increment, String currentSubTask, String message)
      This method can be called to indicate that progress is being made by a task. The current status is incremented by the passed amount.
      Parameters:
      increment - the amount to increment the current progress by.
      currentSubTask - the name of the current sub task or null if there isn't one
      message - an optional message about the progress or null
    • makeProgress

      public void makeProgress(String currentSubTask, String message)
      Send a new progress message without changing the current task progress.
      Parameters:
      currentSubTask - the name of the current sub task or null if there isn't one
      message - an optional message about the progress or null
    • createStepSinkView

      public StepTaskProgressSink createStepSinkView(long startProgress, long length, int numberOfActions)
      Create a StepTaskProgressSink that maps its progress onto a specific range of this sink. This can be used to keep track of a part of a task that is divided into a number of smaller steps.
      Parameters:
      startProgress - the start of the range on this sink to map back to.
      length - the length of the range on this sink the view will map back to.
      numberOfActions - to number of steps the returned sink should work for.
      Returns:
      a StepTaskProgressSink that will publish its results in the specified range of this sink.
    • createStepSinkView

      public StepTaskProgressSink createStepSinkView(long length, int numberOfActions)
      Create a StepTaskProgressSink that maps its progress onto a specific range of this sink. This can be used to keep track of a part of a task that is divided into a number of smaller steps. The start of the range is taken to be the current progress stored in this project.
      Parameters:
      length - the length of the range on this sink the view will map back to.
      numberOfActions - to number of steps the returned sink should work for.
      Returns:
      a StepTaskProgressSink that will publish its results in the specified range of this sink.
    • createPercentageSinksForRange

      public static Collection<StatefulTaskProgressSink> createPercentageSinksForRange(long startRange, long endRange, int numberOfDivisions, TaskProgressSink sink)
      Return a collection of sinks that allows progress to be reported across the specified ragnge. Each sink will service a small section of that range. This is commonly used when a task can be divided up into a number of steps that each need to process their progress independently. For example:

        Collection projects = ...;
        Iterator sinkIterator = StatefulTaskProgressSink.createPercentageSinksForRange(0, 100, projects.size(), ...);
        for (project : projects)
        {
            migrateProject(projects, sinkIterator.next());
        }
       
      Parameters:
      startRange - start of the progress range to divide.
      endRange - end of the progress range to divide.
      numberOfDivisions - the number of intervals in the range.
      sink - the sink used to report progress.
      Returns:
      a Collection of StateTaskProgressSink that divides the interval as specified.
    • getProgress

      public long getProgress()
      Returns:
      the progress recorded in this object. It is the last progress sent.
    • setProgress

      public void setProgress(long currentProgress)
      Set the progress stored in the sink.
      Parameters:
      currentProgress - the progress to store in sink.
    • getMaxProgress

      public long getMaxProgress()
      Returns:
      the largest progress allowed.
    • getMinProgress

      public long getMinProgress()
      Returns:
      the smallest progess allowed.