Search in sources :

Example 1 with SnapshotStatus

use of com.hazelcast.jet.impl.execution.SnapshotRecord.SnapshotStatus in project hazelcast-jet by hazelcast.

the class JobCoordinationService method completeSnapshot.

void completeSnapshot(long jobId, long executionId, long snapshotId, boolean isSuccess) {
    MasterContext masterContext = masterContexts.get(jobId);
    if (masterContext != null) {
        try {
            SnapshotStatus status = isSuccess ? SUCCESSFUL : FAILED;
            long elapsed = snapshotRepository.setSnapshotStatus(jobId, snapshotId, status);
            logger.info(String.format("Snapshot %s for job %s completed with status %s in %dms", snapshotId, idToString(jobId), status, elapsed));
        } catch (Exception e) {
            logger.warning("Cannot update snapshot status for " + jobAndExecutionId(jobId, executionId) + " snapshot " + snapshotId + " isSuccess: " + isSuccess);
            return;
        }
        try {
            if (isSuccess) {
                snapshotRepository.deleteAllSnapshotsExceptOne(jobId, snapshotId);
            } else {
                snapshotRepository.deleteSingleSnapshot(jobId, snapshotId);
            }
        } catch (Exception e) {
            logger.warning("Cannot delete old snapshots for " + jobAndExecutionId(jobId, executionId));
        }
        scheduleSnapshot(jobId, executionId);
    } else {
        logger.warning("MasterContext not found to finalize snapshot of " + jobAndExecutionId(jobId, executionId) + " with result: " + isSuccess);
    }
}
Also used : SnapshotStatus(com.hazelcast.jet.impl.execution.SnapshotRecord.SnapshotStatus) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) JetException(com.hazelcast.jet.JetException) JobNotFoundException(com.hazelcast.jet.core.JobNotFoundException) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) TopologyChangedException(com.hazelcast.jet.core.TopologyChangedException)

Aggregations

HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 JetException (com.hazelcast.jet.JetException)1 JobNotFoundException (com.hazelcast.jet.core.JobNotFoundException)1 TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)1 SnapshotStatus (com.hazelcast.jet.impl.execution.SnapshotRecord.SnapshotStatus)1 RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)1