Java Code Examples for org.apache.flink.runtime.execution.librarycache.LibraryCacheManager#ClassLoaderLease

The following examples show how to use org.apache.flink.runtime.execution.librarycache.LibraryCacheManager#ClassLoaderLease . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobManagerRunnerImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Exceptions that occur while creating the JobManager or JobManagerRunnerImpl are directly
 * thrown and not reported to the given {@code FatalErrorHandler}.
 *
 * @throws Exception Thrown if the runner cannot be set up, because either one of the
 *                   required services could not be started, or the Job could not be initialized.
 */
public JobManagerRunnerImpl(
		final JobGraph jobGraph,
		final JobMasterServiceFactory jobMasterFactory,
		final HighAvailabilityServices haServices,
		final LibraryCacheManager.ClassLoaderLease classLoaderLease,
		final Executor executor,
		final FatalErrorHandler fatalErrorHandler) throws Exception {

	this.resultFuture = new CompletableFuture<>();
	this.terminationFuture = new CompletableFuture<>();
	this.leadershipOperation = CompletableFuture.completedFuture(null);

	this.jobGraph = checkNotNull(jobGraph);
	this.classLoaderLease = checkNotNull(classLoaderLease);
	this.executor = checkNotNull(executor);
	this.fatalErrorHandler = checkNotNull(fatalErrorHandler);

	checkArgument(jobGraph.getNumberOfVertices() > 0, "The given job is empty");

	// libraries and class loader first
	final ClassLoader userCodeLoader;
	try {
		userCodeLoader = classLoaderLease.getOrResolveClassLoader(
			jobGraph.getUserJarBlobKeys(),
			jobGraph.getClasspaths());
	} catch (IOException e) {
		throw new Exception("Cannot set up the user code libraries: " + e.getMessage(), e);
	}

	// high availability services next
	this.runningJobsRegistry = haServices.getRunningJobsRegistry();
	this.leaderElectionService = haServices.getJobManagerLeaderElectionService(jobGraph.getJobID());

	this.leaderGatewayFuture = new CompletableFuture<>();

	// now start the JobManager
	this.jobMasterService = jobMasterFactory.createJobMasterService(jobGraph, this, userCodeLoader);
}
 
Example 2
Source File: TaskExecutor.java    From flink with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static TaskExecutorJobServices create(
	LibraryCacheManager.ClassLoaderLease classLoaderLease,
	Runnable closeHook) {
	return new TaskExecutorJobServices(
		classLoaderLease,
		closeHook);
}
 
Example 3
Source File: JobManagerRunnerImplTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nonnull
private JobManagerRunnerImpl createJobManagerRunner(JobMasterServiceFactory jobMasterServiceFactory, LibraryCacheManager.ClassLoaderLease classLoaderLease) throws Exception{
	return new JobManagerRunnerImpl(
		jobGraph,
		jobMasterServiceFactory,
		haServices,
		classLoaderLease,
		TestingUtils.defaultExecutor(),
		fatalErrorHandler);
}
 
Example 4
Source File: TaskExecutor.java    From flink with Apache License 2.0 4 votes vote down vote up
private TaskExecutorJobServices(
	LibraryCacheManager.ClassLoaderLease classLoaderLease,
	Runnable closeHook) {
	this.classLoaderLease = classLoaderLease;
	this.closeHook = closeHook;
}
 
Example 5
Source File: JobManagerRunnerImplTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Nonnull
private JobManagerRunner createJobManagerRunner(LibraryCacheManager.ClassLoaderLease classLoaderLease) throws Exception {
	return createJobManagerRunner(defaultJobMasterServiceFactory, classLoaderLease);
}