Search in sources :

Example 16 with JobStatus

use of com.hazelcast.jet.core.JobStatus in project hazelcast-jet by hazelcast.

the class MasterContext method setJobStatusToStarting.

/**
 * Sets job status to starting.
 * Returns false if the job start process cannot proceed.
 */
private boolean setJobStatusToStarting() {
    JobStatus status = jobStatus();
    if (status == COMPLETED || status == FAILED) {
        logger.severe("Cannot init job " + idToString(jobId) + ": it is already " + status);
        return false;
    }
    if (cancellationToken.isCompleted()) {
        logger.fine("Skipping init job " + idToString(jobId) + ": is already cancelled.");
        finalizeJob(new CancellationException());
        return false;
    }
    if (status == NOT_STARTED) {
        if (!jobStatus.compareAndSet(NOT_STARTED, STARTING)) {
            logger.fine("Cannot init job " + idToString(jobId) + ": someone else is just starting it");
            return false;
        }
        jobStartTime = System.currentTimeMillis();
    }
    status = jobStatus();
    if (!(status == STARTING || status == RESTARTING)) {
        logger.severe("Cannot init job " + idToString(jobId) + ": status is " + status);
        return false;
    }
    return true;
}
Also used : JobStatus(com.hazelcast.jet.core.JobStatus) CancellationException(java.util.concurrent.CancellationException)

Aggregations

JobStatus (com.hazelcast.jet.core.JobStatus)16 CancellationException (java.util.concurrent.CancellationException)7 COMPLETED (com.hazelcast.jet.core.JobStatus.COMPLETED)5 List (java.util.List)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 JobConfig (com.hazelcast.jet.config.JobConfig)4 DAG (com.hazelcast.jet.core.DAG)4 Edge.between (com.hazelcast.jet.core.Edge.between)4 FAILED (com.hazelcast.jet.core.JobStatus.FAILED)4 TopologyChangedException (com.hazelcast.jet.core.TopologyChangedException)4 MemberInfo (com.hazelcast.internal.cluster.MemberInfo)3 MembersView (com.hazelcast.internal.cluster.impl.MembersView)3 Util.idToString (com.hazelcast.jet.Util.idToString)3 ProcessingGuarantee (com.hazelcast.jet.config.ProcessingGuarantee)3 Edge (com.hazelcast.jet.core.Edge)3 RUNNING (com.hazelcast.jet.core.JobStatus.RUNNING)3 Vertex (com.hazelcast.jet.core.Vertex)3 Function (java.util.function.Function)3 ExecutionCallback (com.hazelcast.core.ExecutionCallback)2 LocalMemberResetException (com.hazelcast.core.LocalMemberResetException)2