use of org.apache.flink.runtime.execution.librarycache.TestingClassLoaderLease in project flink by apache.
the class TaskAsyncCallTest method createTask.
private Task createTask(Class<? extends AbstractInvokable> invokableClass) throws Exception {
final TestingClassLoaderLease classLoaderHandle = TestingClassLoaderLease.newBuilder().setGetOrResolveClassLoaderFunction((permanentBlobKeys, urls) -> TestingUserCodeClassLoader.newBuilder().setClassLoader(new TestUserCodeClassLoader()).build()).build();
ResultPartitionConsumableNotifier consumableNotifier = new NoOpResultPartitionConsumableNotifier();
PartitionProducerStateChecker partitionProducerStateChecker = mock(PartitionProducerStateChecker.class);
Executor executor = mock(Executor.class);
TaskMetricGroup taskMetricGroup = UnregisteredMetricGroups.createUnregisteredTaskMetricGroup();
JobInformation jobInformation = new JobInformation(new JobID(), "Job Name", new SerializedValue<>(new ExecutionConfig()), new Configuration(), Collections.emptyList(), Collections.emptyList());
TaskInformation taskInformation = new TaskInformation(new JobVertexID(), "Test Task", 1, 1, invokableClass.getName(), new Configuration());
return new Task(jobInformation, taskInformation, new ExecutionAttemptID(), new AllocationID(), 0, 0, Collections.<ResultPartitionDeploymentDescriptor>emptyList(), Collections.<InputGateDeploymentDescriptor>emptyList(), mock(MemoryManager.class), mock(IOManager.class), shuffleEnvironment, new KvStateService(new KvStateRegistry(), null, null), mock(BroadcastVariableManager.class), new TaskEventDispatcher(), ExternalResourceInfoProvider.NO_EXTERNAL_RESOURCES, new TestTaskStateManager(), mock(TaskManagerActions.class), mock(InputSplitProvider.class), mock(CheckpointResponder.class), new NoOpTaskOperatorEventGateway(), new TestGlobalAggregateManager(), classLoaderHandle, mock(FileCache.class), new TestingTaskManagerRuntimeInfo(), taskMetricGroup, consumableNotifier, partitionProducerStateChecker, executor);
}
use of org.apache.flink.runtime.execution.librarycache.TestingClassLoaderLease in project flink by apache.
the class JobMasterServiceLeadershipRunnerTest method testCloseReleasesClassLoaderLease.
@Test
public void testCloseReleasesClassLoaderLease() throws Exception {
final OneShotLatch closeClassLoaderLeaseLatch = new OneShotLatch();
final TestingClassLoaderLease classLoaderLease = TestingClassLoaderLease.newBuilder().setCloseRunnable(closeClassLoaderLeaseLatch::trigger).build();
try (JobManagerRunner jobManagerRunner = newJobMasterServiceLeadershipRunnerBuilder().setClassLoaderLease(classLoaderLease).build()) {
jobManagerRunner.start();
jobManagerRunner.close();
closeClassLoaderLeaseLatch.await();
}
}
use of org.apache.flink.runtime.execution.librarycache.TestingClassLoaderLease in project flink by apache.
the class TaskExecutorTest method taskExecutorJobServicesCloseClassLoaderLeaseUponClosing.
@Test
public void taskExecutorJobServicesCloseClassLoaderLeaseUponClosing() throws InterruptedException {
final OneShotLatch leaseReleaseLatch = new OneShotLatch();
final OneShotLatch closeHookLatch = new OneShotLatch();
final TestingClassLoaderLease classLoaderLease = TestingClassLoaderLease.newBuilder().setCloseRunnable(leaseReleaseLatch::trigger).build();
final TaskExecutor.TaskExecutorJobServices taskExecutorJobServices = TaskExecutor.TaskExecutorJobServices.create(classLoaderLease, closeHookLatch::trigger);
taskExecutorJobServices.close();
leaseReleaseLatch.await();
closeHookLatch.await();
}
Aggregations