Search in sources :

Example 1 with VertexDef

use of com.hazelcast.jet.impl.execution.init.VertexDef in project hazelcast by hazelcast.

the class ExecutionContext method completeExecution.

/**
 * Complete local execution. If local execution was started, it should be
 * called after execution has completed.
 */
public void completeExecution(Throwable error) {
    assert executionFuture == null || executionFuture.isDone() : "If execution was begun, then completeExecution() should not be called before execution is done.";
    if (!executionCompleted.compareAndSet(false, true)) {
        return;
    }
    for (Tasklet tasklet : tasklets) {
        try {
            tasklet.close();
        } catch (Throwable e) {
            logger.severe(jobNameAndExecutionId() + " encountered an exception in Processor.close(), ignoring it", e);
        }
    }
    JobClassLoaderService jobClassloaderService = jetServiceBackend.getJobClassLoaderService();
    ClassLoader classLoader = jobClassloaderService.getClassLoader(jobId);
    doWithClassLoader(classLoader, () -> {
        for (VertexDef vertex : vertices) {
            try {
                ClassLoader processorCl = isLightJob ? null : jobClassloaderService.getProcessorClassLoader(jobId, vertex.name());
                doWithClassLoader(processorCl, () -> vertex.processorSupplier().close(error));
            } catch (Throwable e) {
                logger.severe(jobNameAndExecutionId() + " encountered an exception in ProcessorSupplier.close(), ignoring it", e);
            }
        }
    });
    tempDirectories.forEach((k, dir) -> {
        try {
            IOUtil.delete(dir);
        } catch (Exception e) {
            logger.warning("Failed to delete temporary directory " + dir);
        }
    });
    if (serializationService != null) {
        serializationService.dispose();
    }
}
Also used : VertexDef(com.hazelcast.jet.impl.execution.init.VertexDef) JobClassLoaderService(com.hazelcast.jet.impl.JobClassLoaderService) Util.doWithClassLoader(com.hazelcast.jet.impl.util.Util.doWithClassLoader) JobTerminateRequestedException(com.hazelcast.jet.impl.exception.JobTerminateRequestedException) TerminatedWithSnapshotException(com.hazelcast.jet.impl.exception.TerminatedWithSnapshotException) CancellationException(java.util.concurrent.CancellationException)

Aggregations

JobClassLoaderService (com.hazelcast.jet.impl.JobClassLoaderService)1 JobTerminateRequestedException (com.hazelcast.jet.impl.exception.JobTerminateRequestedException)1 TerminatedWithSnapshotException (com.hazelcast.jet.impl.exception.TerminatedWithSnapshotException)1 VertexDef (com.hazelcast.jet.impl.execution.init.VertexDef)1 Util.doWithClassLoader (com.hazelcast.jet.impl.util.Util.doWithClassLoader)1 CancellationException (java.util.concurrent.CancellationException)1