Class DatabaseBackedClusterService

java.lang.Object
io.github.jchejarla.springbatch.clustering.core.DatabaseBackedClusterService

public class DatabaseBackedClusterService extends Object
  • Constructor Details

    • DatabaseBackedClusterService

      public DatabaseBackedClusterService()
  • Method Details

    • registerNode

      @Transactional public int registerNode()
    • updateNodeHeartbeat

      @Transactional public int updateNodeHeartbeat()
    • recordPhaseEvent

      public void recordPhaseEvent(long jobExecutionId, String phase)
      Appends a coordination phase event (for observability), timestamped with the database clock.
    • markNodesUnreachable

      @Transactional public int markNodesUnreachable()
    • deleteNodesUnreachable

      @Transactional public int deleteNodesUnreachable()
    • saveBatchJobCoordinationInfo

      @Transactional public int saveBatchJobCoordinationInfo(long jobExecutionId, long masterStepExecutionId, String masterStepName)
    • updateBatchJobCoordinationStatus

      @Transactional public int updateBatchJobCoordinationStatus(long jobExecutionId, long masterStepExecutionId, String newStatus)
    • saveBatchPartitions

      @Transactional public int[] saveBatchPartitions(List<Object[]> params)
    • updateBatchPartitionsToReAssignedNodes

      @Transactional public int[] updateBatchPartitionsToReAssignedNodes(List<Object[]> params)
    • getPendingTasksCount

      public Integer getPendingTasksCount(long masterStepExecutionId)
    • getFailedTasksCount

      public Integer getFailedTasksCount(long masterStepExecutionId)
      Number of partitions that ended FAILED for this job, used by the master to fail the step.
    • fetchPartitionAssignedTasks

      public List<PartitionAssignmentTask> fetchPartitionAssignedTasks()
      Returns:
      - assigned tasks for the current node, taking consideration of currently running job_execution_id and step_execution_id and if the master node is still healthy for the job.
    • updatePartitionsStatus

      @Transactional public void updatePartitionsStatus(Collection<PartitionAssignmentTask> partitionAssignmentTasks, String status)
    • updatePartitionsLastUpdatedTime

      @Transactional public void updatePartitionsLastUpdatedTime(Collection<PartitionAssignmentTask> partitionAssignmentTasks)
    • updatePartitionStatus

      @Transactional public void updatePartitionStatus(PartitionAssignmentTask partitionAssignmentTask, String status)
    • checkForOrphanedTasks

      public List<PartitionAssignmentTask> checkForOrphanedTasks(long masterStepExecutionId)
    • findOrphanedMasterJobs

      public List<OrphanedMasterJob> findOrphanedMasterJobs()
      Returns jobs whose master node has left the cluster (coordination row still STARTED, master node no longer registered). These jobs cannot make progress and are candidates for recovery.
    • claimOrphanedMasterJob

      @Transactional public boolean claimOrphanedMasterJob(long jobExecutionId, String lostOwnerNode, String thisNodeId, String recoveringStatus)
      Atomically claims an orphaned job for recovery: transitions its coordination row to recoveringStatus and takes ownership (master_node_id = thisNodeId), guarded by the lost owner's node id. Taking ownership means that if this reaper also dies mid-recovery, the row is re-detected (its owner is now gone too) and re-claimed by another node. Returns true only for the single node that wins the claim, so a stranded job is reaped exactly once.
    • getActiveNodes

      public List<ClusterNode> getActiveNodes()
    • getNodesInCluster

      public List<ClusterNodeInfo> getNodesInCluster()