use of org.apache.flink.util.FlinkException in project flink by apache.
the class JobMasterTest method testJobMasterAcceptsSlotsWhenJobIsRestarting.
@Test
public void testJobMasterAcceptsSlotsWhenJobIsRestarting() throws Exception {
configuration.set(RestartStrategyOptions.RESTART_STRATEGY, "fixed-delay");
configuration.set(RestartStrategyOptions.RESTART_STRATEGY_FIXED_DELAY_DELAY, Duration.ofDays(1));
final int numberSlots = 1;
final JobMaster jobMaster = new JobMasterBuilder(jobGraph, rpcService).withConfiguration(configuration).createJobMaster();
try {
jobMaster.start();
final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
final LocalUnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
registerSlotsAtJobMaster(numberSlots, jobMasterGateway, jobGraph.getJobID(), new TestingTaskExecutorGatewayBuilder().setAddress("firstTaskManager").createTestingTaskExecutorGateway(), unresolvedTaskManagerLocation);
CommonTestUtils.waitUntilCondition(() -> jobMasterGateway.requestJobStatus(testingTimeout).get() == JobStatus.RUNNING, Deadline.fromNow(TimeUtils.toDuration(testingTimeout)));
jobMasterGateway.disconnectTaskManager(unresolvedTaskManagerLocation.getResourceID(), new FlinkException("Test exception."));
CommonTestUtils.waitUntilCondition(() -> jobMasterGateway.requestJobStatus(testingTimeout).get() == JobStatus.RESTARTING, Deadline.fromNow(TimeUtils.toDuration(testingTimeout)));
assertThat(registerSlotsAtJobMaster(numberSlots, jobMasterGateway, jobGraph.getJobID(), new TestingTaskExecutorGatewayBuilder().setAddress("secondTaskManager").createTestingTaskExecutorGateway(), new LocalUnresolvedTaskManagerLocation()), hasSize(numberSlots));
} finally {
RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
}
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class JobMasterTest method testReconnectionAfterDisconnect.
/**
* Tests that we continue reconnecting to the latest known RM after a disconnection message.
*/
@Test
public void testReconnectionAfterDisconnect() throws Exception {
final JobMaster jobMaster = new JobMasterBuilder(jobGraph, rpcService).withJobMasterId(jobMasterId).withConfiguration(configuration).withHighAvailabilityServices(haServices).withHeartbeatServices(heartbeatServices).createJobMaster();
jobMaster.start();
final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
try {
final TestingResourceManagerGateway testingResourceManagerGateway = createAndRegisterTestingResourceManagerGateway();
final BlockingQueue<JobMasterId> registrationsQueue = new ArrayBlockingQueue<>(1);
testingResourceManagerGateway.setRegisterJobManagerFunction((jobMasterId, resourceID, s, jobID) -> {
registrationsQueue.offer(jobMasterId);
return CompletableFuture.completedFuture(testingResourceManagerGateway.getJobMasterRegistrationSuccess());
});
final ResourceManagerId resourceManagerId = testingResourceManagerGateway.getFencingToken();
notifyResourceManagerLeaderListeners(testingResourceManagerGateway);
// wait for first registration attempt
final JobMasterId firstRegistrationAttempt = registrationsQueue.take();
assertThat(firstRegistrationAttempt, equalTo(jobMasterId));
assertThat(registrationsQueue.isEmpty(), is(true));
jobMasterGateway.disconnectResourceManager(resourceManagerId, new FlinkException("Test exception"));
// wait for the second registration attempt after the disconnect call
assertThat(registrationsQueue.take(), equalTo(jobMasterId));
} finally {
RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
}
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class DeclarativeSlotPoolServiceTest method testReleaseTaskManager.
@Test
public void testReleaseTaskManager() throws Exception {
try (DeclarativeSlotPoolService declarativeSlotPoolService = createDeclarativeSlotPoolService()) {
final ResourceID knownTaskManager = ResourceID.generate();
declarativeSlotPoolService.registerTaskManager(knownTaskManager);
declarativeSlotPoolService.releaseTaskManager(knownTaskManager, new FlinkException("Test cause"));
assertFalse(declarativeSlotPoolService.isTaskManagerRegistered(knownTaskManager.getResourceID()));
}
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class DefaultDeclarativeSlotPoolTest method testReleaseSlotOnlyReturnsFulfilledRequirementsOfReservedSlots.
@Test
public void testReleaseSlotOnlyReturnsFulfilledRequirementsOfReservedSlots() {
withSlotPoolContainingOneTaskManagerWithTwoSlotsWithUniqueResourceProfiles((slotPool, freeSlot, slotToReserve, ignored) -> {
slotPool.reserveFreeSlot(slotToReserve.getAllocationId(), slotToReserve.getResourceProfile()).tryAssignPayload(new TestingPhysicalSlotPayload());
final ResourceCounter fulfilledRequirementsOfFreeSlot = slotPool.releaseSlot(freeSlot.getAllocationId(), new FlinkException("Test failure"));
final ResourceCounter fulfilledRequirementsOfReservedSlot = slotPool.releaseSlot(slotToReserve.getAllocationId(), new FlinkException("Test failure"));
assertThat(fulfilledRequirementsOfFreeSlot.getResources(), is(empty()));
assertThat(fulfilledRequirementsOfReservedSlot.getResourceCount(slotToReserve.getResourceProfile()), is(1));
});
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class DefaultDeclarativeSlotPoolTest method testReleaseSlotsRemovesSlots.
@Test
public void testReleaseSlotsRemovesSlots() throws InterruptedException {
final NewResourceRequirementsService notifyNewResourceRequirements = new NewResourceRequirementsService();
final DefaultDeclarativeSlotPool slotPool = createDefaultDeclarativeSlotPool(notifyNewResourceRequirements);
final LocalTaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
increaseRequirementsAndOfferSlotsToSlotPool(slotPool, createResourceRequirements(), taskManagerLocation);
notifyNewResourceRequirements.takeResourceRequirements();
slotPool.releaseSlots(taskManagerLocation.getResourceID(), new FlinkException("Test failure"));
assertThat(slotPool.getAllSlotsInformation(), is(empty()));
}
Aggregations