Class DatabaseBackedClusterService
java.lang.Object
io.github.jchejarla.springbatch.clustering.core.DatabaseBackedClusterService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckForOrphanedTasks(long masterStepExecutionId) booleanclaimOrphanedMasterJob(long jobExecutionId, String lostOwnerNode, String thisNodeId, String recoveringStatus) Atomically claims an orphaned job for recovery: transitions its coordination row torecoveringStatusand takes ownership (master_node_id = thisNodeId), guarded by the lost owner's node id.intReturns jobs whose master node has left the cluster (coordination row stillSTARTED, master node no longer registered).getFailedTasksCount(long masterStepExecutionId) Number of partitions that ended FAILED for this job, used by the master to fail the step.getPendingTasksCount(long masterStepExecutionId) intvoidrecordPhaseEvent(long jobExecutionId, String phase) Appends a coordination phase event (for observability), timestamped with the database clock.intintsaveBatchJobCoordinationInfo(long jobExecutionId, long masterStepExecutionId, String masterStepName) int[]saveBatchPartitions(List<Object[]> params) intupdateBatchJobCoordinationStatus(long jobExecutionId, long masterStepExecutionId, String newStatus) int[]updateBatchPartitionsToReAssignedNodes(List<Object[]> params) intvoidupdatePartitionsLastUpdatedTime(Collection<PartitionAssignmentTask> partitionAssignmentTasks) voidupdatePartitionsStatus(Collection<PartitionAssignmentTask> partitionAssignmentTasks, String status) voidupdatePartitionStatus(PartitionAssignmentTask partitionAssignmentTask, String status)
-
Constructor Details
-
DatabaseBackedClusterService
public DatabaseBackedClusterService()
-
-
Method Details
-
registerNode
@Transactional public int registerNode() -
updateNodeHeartbeat
@Transactional public int updateNodeHeartbeat() -
recordPhaseEvent
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
-
updateBatchPartitionsToReAssignedNodes
-
getPendingTasksCount
-
getFailedTasksCount
Number of partitions that ended FAILED for this job, used by the master to fail the step. -
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
-
findOrphanedMasterJobs
Returns jobs whose master node has left the cluster (coordination row stillSTARTED, 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 torecoveringStatusand 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. Returnstrueonly for the single node that wins the claim, so a stranded job is reaped exactly once. -
getActiveNodes
-
getNodesInCluster
-