use of org.apache.flink.runtime.taskmanager.LocalUnresolvedTaskManagerLocation in project flink by apache.
the class JobMasterTest method testRestoringFromSavepoint.
/**
* Tests that a JobMaster will restore the given JobGraph from its savepoint upon initial
* submission.
*/
@Test
public void testRestoringFromSavepoint() throws Exception {
// create savepoint data
final long savepointId = 42L;
final File savepointFile = createSavepoint(savepointId);
// set savepoint settings
final SavepointRestoreSettings savepointRestoreSettings = SavepointRestoreSettings.forPath(savepointFile.getAbsolutePath(), true);
final JobGraph jobGraph = createJobGraphWithCheckpointing(savepointRestoreSettings);
final StandaloneCompletedCheckpointStore completedCheckpointStore = new StandaloneCompletedCheckpointStore(1);
final CheckpointRecoveryFactory testingCheckpointRecoveryFactory = PerJobCheckpointRecoveryFactory.withoutCheckpointStoreRecovery(maxCheckpoints -> completedCheckpointStore);
haServices.setCheckpointRecoveryFactory(testingCheckpointRecoveryFactory);
final JobMaster jobMaster = new JobMasterBuilder(jobGraph, rpcService).withHighAvailabilityServices(haServices).createJobMaster();
try {
// we need to start and register the required slots to let the adaptive scheduler
// restore from the savepoint
jobMaster.start();
final OneShotLatch taskSubmitLatch = new OneShotLatch();
registerSlotsAtJobMaster(1, jobMaster.getSelfGateway(JobMasterGateway.class), jobGraph.getJobID(), new TestingTaskExecutorGatewayBuilder().setSubmitTaskConsumer((taskDeploymentDescriptor, jobMasterId) -> {
taskSubmitLatch.trigger();
return CompletableFuture.completedFuture(Acknowledge.get());
}).createTestingTaskExecutorGateway(), new LocalUnresolvedTaskManagerLocation());
// wait until a task has submitted because this guarantees that the ExecutionGraph has
// been created
taskSubmitLatch.await();
final CompletedCheckpoint savepointCheckpoint = completedCheckpointStore.getLatestCheckpoint();
assertThat(savepointCheckpoint, Matchers.notNullValue());
assertThat(savepointCheckpoint.getCheckpointID(), is(savepointId));
} finally {
RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
}
}
use of org.apache.flink.runtime.taskmanager.LocalUnresolvedTaskManagerLocation in project flink by apache.
the class DefaultJobLeaderServiceTest method handlesConcurrentJobAdditionsAndLeaderChanges.
/**
* Tests that we can concurrently modify the JobLeaderService and complete the leader retrieval
* operation. See FLINK-16373.
*/
@Test
public void handlesConcurrentJobAdditionsAndLeaderChanges() throws Exception {
final JobLeaderService jobLeaderService = new DefaultJobLeaderService(new LocalUnresolvedTaskManagerLocation(), RetryingRegistrationConfiguration.defaultConfiguration());
final TestingJobLeaderListener jobLeaderListener = new TestingJobLeaderListener();
final int numberOperations = 20;
final BlockingQueue<SettableLeaderRetrievalService> instantiatedLeaderRetrievalServices = new ArrayBlockingQueue<>(numberOperations);
final HighAvailabilityServices haServices = new TestingHighAvailabilityServicesBuilder().setJobMasterLeaderRetrieverFunction(leaderForJobId -> {
final SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService();
instantiatedLeaderRetrievalServices.offer(leaderRetrievalService);
return leaderRetrievalService;
}).build();
jobLeaderService.start("foobar", rpcServiceResource.getTestingRpcService(), haServices, jobLeaderListener);
final CheckedThread addJobAction = new CheckedThread() {
@Override
public void go() throws Exception {
for (int i = 0; i < numberOperations; i++) {
final JobID jobId = JobID.generate();
jobLeaderService.addJob(jobId, "foobar");
Thread.yield();
jobLeaderService.removeJob(jobId);
}
}
};
addJobAction.start();
for (int i = 0; i < numberOperations; i++) {
final SettableLeaderRetrievalService leaderRetrievalService = instantiatedLeaderRetrievalServices.take();
leaderRetrievalService.notifyListener("foobar", UUID.randomUUID());
}
addJobAction.sync();
}
Aggregations