Class HistoryCleanupCmd

All Implemented Interfaces:

public class HistoryCleanupCmd extends Object implements Command<Job>
Svetlana Dorokhova
  • Field Details


      public static final JobDeclaration HISTORY_CLEANUP_JOB_DECLARATION

      public static final int MAX_THREADS_NUMBER
      See Also:
  • Constructor Details

    • HistoryCleanupCmd

      public HistoryCleanupCmd(boolean immediatelyDue)
  • Method Details

    • execute

      public Job execute(CommandContext context)
      Specified by:
      execute in interface Command<Job>
    • getHistoryCleanupJobs

      protected List<Job> getHistoryCleanupJobs()
    • shouldCreateJobs

      protected boolean shouldCreateJobs(List<Job> jobs)
    • shouldReconfigureJobs

      protected boolean shouldReconfigureJobs(List<Job> jobs)
    • shouldSuspendJobs

      protected boolean shouldSuspendJobs(List<Job> jobs)
    • willBeScheduled

      protected boolean willBeScheduled()
    • createJobs

      protected List<Job> createJobs(int[][] minuteChunks)
    • reconfigureJobs

      protected List<Job> reconfigureJobs(List<Job> historyCleanupJobs, int degreeOfParallelism, int[][] minuteChunks)
    • suspendJobs

      protected void suspendJobs(List<Job> jobs)
    • createJob

      protected JobEntity createJob(int[] minuteChunk, int maxRetries)
    • createCleanupContext

      protected HistoryCleanupContext createCleanupContext(int[] minuteChunk, int maxRetries)
    • writeUserOperationLog

      protected void writeUserOperationLog(CommandContext commandContext)
    • acquireExclusiveLock

      protected void acquireExclusiveLock(CommandContext commandContext)
    • isRetryable

      public boolean isRetryable()
      When CockroachDB is used, this command may be retried multiple times until it is successful, or the retries are exhausted. CockroachDB uses a stricter, SERIALIZABLE transaction isolation which ensures a serialized manner of transaction execution. A concurrent transaction that attempts to modify the same data as another transaction is required to abort, rollback and retry. This also makes our use-case of pessimistic locks redundant since we only use them as synchronization barriers, and not to lock actual data which would protect it from concurrent modifications. The History Cleanup command only executes internal code, so we are certain that a retry of a failed reconfiguraton will not impact user data, and may be performed multiple times.
      Specified by:
      isRetryable in interface Command<Job>
      true if the CrdbTransactionRetryInterceptor can make a transparent retry of this command upon failure with a CrdbTransactionRetryException (only used when running on CockroachDB).