use of com.hazelcast.jet.impl.deployment.JetDelegatingClassLoader in project hazelcast by hazelcast.
the class JobExecutionService method completeExecution.
/**
* Completes and cleans up execution of the given job
*/
public void completeExecution(@Nonnull ExecutionContext executionContext, Throwable error) {
ExecutionContext removed = executionContexts.remove(executionContext.executionId());
if (removed != null) {
if (error != null) {
failedJobs.put(executionContext.executionId(), System.nanoTime() + FAILED_EXECUTION_EXPIRY_NS);
}
JetDelegatingClassLoader jobClassLoader = jobClassloaderService.getClassLoader(executionContext.jobId());
try {
doWithClassLoader(jobClassLoader, () -> executionContext.completeExecution(error));
} finally {
if (!executionContext.isLightJob()) {
jobClassloaderService.tryRemoveClassloadersForJob(executionContext.jobId(), EXECUTION);
}
executionCompleted.inc();
executionContextJobIds.remove(executionContext.jobId());
logger.fine("Completed execution of " + executionContext.jobNameAndExecutionId());
}
}
}
use of com.hazelcast.jet.impl.deployment.JetDelegatingClassLoader in project hazelcast by hazelcast.
the class MasterJobContext method completeVertices.
private void completeVertices(@Nullable Throwable failure) {
if (vertices != null) {
JobClassLoaderService classLoaderService = mc.getJetServiceBackend().getJobClassLoaderService();
JetDelegatingClassLoader jobCl = classLoaderService.getClassLoader(mc.jobId());
doWithClassLoader(jobCl, () -> {
for (Vertex v : vertices) {
try {
ClassLoader processorCl = classLoaderService.getProcessorClassLoader(mc.jobId(), v.getName());
doWithClassLoader(processorCl, () -> v.getMetaSupplier().close(failure));
} catch (Throwable e) {
logger.severe(mc.jobIdString() + " encountered an exception in ProcessorMetaSupplier.close(), ignoring it", e);
}
}
});
}
}
use of com.hazelcast.jet.impl.deployment.JetDelegatingClassLoader in project hazelcast by hazelcast.
the class JobClassLoaderService method tryRemoveClassloadersForJob.
/**
* Try to remove and close/shutdown job classloader and any processor
* classloaders for given job
* <p>
* We keep track of phases where the classloader is used and remove
* the classloader only if there are no more phases left.
*/
public void tryRemoveClassloadersForJob(long jobId, JobPhase phase) {
logFinest(logger, "Try remove classloaders for jobId=%s, phase=%s", idToString(jobId), phase);
classLoaders.compute(jobId, (k, jobClassLoaders) -> {
if (jobClassLoaders == null) {
logger.warning("JobClassLoaders for jobId=" + idToString(jobId) + " already removed");
return null;
}
int phaseCount = jobClassLoaders.removePhase(phase);
if (phaseCount == 0) {
logFinest(logger, "JobClassLoaders phaseCount = 0, removing classloaders for jobId=%s", idToString(jobId));
Map<String, ClassLoader> processorCls = jobClassLoaders.processorCls();
if (processorCls != null) {
for (ClassLoader cl : processorCls.values()) {
try {
((ChildFirstClassLoader) cl).close();
} catch (IOException e) {
logger.warning("Exception when closing processor classloader", e);
}
}
}
// the class loader might not have been initialized if the job failed before that
JetDelegatingClassLoader jobClassLoader = jobClassLoaders.jobClassLoader();
jobClassLoader.shutdown();
logFine(logger, "Finish JobClassLoaders phaseCount = 0," + " removing classloaders for jobId=%s", idToString(jobId));
// Removes the item from the map
return null;
} else {
logFinest(logger, "JobClassLoaders refCount > 0, NOT removing classloaders for jobId=%s", idToString(jobId));
return jobClassLoaders;
}
});
}
Aggregations