use of org.apache.flink.runtime.registration.RegistrationResponse in project flink by apache.
the class JobMasterTest method testTaskManagerRegistrationTriggersHeartbeating.
@Test
public void testTaskManagerRegistrationTriggersHeartbeating() throws Exception {
final CompletableFuture<ResourceID> heartbeatResourceIdFuture = new CompletableFuture<>();
final UnresolvedTaskManagerLocation unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
final TestingTaskExecutorGateway taskExecutorGateway = new TestingTaskExecutorGatewayBuilder().setHeartbeatJobManagerFunction((taskManagerId, ignored) -> {
heartbeatResourceIdFuture.complete(taskManagerId);
return FutureUtils.completedVoidFuture();
}).createTestingTaskExecutorGateway();
rpcService.registerGateway(taskExecutorGateway.getAddress(), taskExecutorGateway);
final JobMaster jobMaster = new JobMasterBuilder(jobGraph, rpcService).withResourceId(jmResourceId).withConfiguration(configuration).withHighAvailabilityServices(haServices).withHeartbeatServices(new HeartbeatServices(1L, 10000L)).createJobMaster();
jobMaster.start();
try {
final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
// register task manager will trigger monitor heartbeat target, schedule heartbeat
// request at interval time
CompletableFuture<RegistrationResponse> registrationResponse = jobMasterGateway.registerTaskManager(jobGraph.getJobID(), TaskManagerRegistrationInformation.create(taskExecutorGateway.getAddress(), unresolvedTaskManagerLocation, TestingUtils.zeroUUID()), testingTimeout);
// wait for the completion of the registration
registrationResponse.get();
assertThat(heartbeatResourceIdFuture.join(), anyOf(nullValue(), equalTo(jmResourceId)));
} finally {
RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
}
}
use of org.apache.flink.runtime.registration.RegistrationResponse in project flink by apache.
the class ResourceManagerJobMasterTest method testRegisterJobMasterWithUnmatchedLeaderSessionId2.
/**
* Test receive registration with unmatched leadershipId from job master.
*/
@Test
public void testRegisterJobMasterWithUnmatchedLeaderSessionId2() throws Exception {
// test throw exception when receive a registration from job master which takes unmatched
// leaderSessionId
JobMasterId differentJobMasterId = JobMasterId.generate();
CompletableFuture<RegistrationResponse> unMatchedLeaderFuture = resourceManagerGateway.registerJobMaster(differentJobMasterId, jobMasterResourceId, jobMasterGateway.getAddress(), jobId, TIMEOUT);
assertTrue(unMatchedLeaderFuture.get() instanceof RegistrationResponse.Failure);
}
use of org.apache.flink.runtime.registration.RegistrationResponse in project flink by apache.
the class ResourceManagerJobMasterTest method testRegisterJobMaster.
/**
* Test receive normal registration from job master and receive duplicate registration from job
* master.
*/
@Test
public void testRegisterJobMaster() throws Exception {
// test response successful
CompletableFuture<RegistrationResponse> successfulFuture = resourceManagerGateway.registerJobMaster(jobMasterGateway.getFencingToken(), jobMasterResourceId, jobMasterGateway.getAddress(), jobId, TIMEOUT);
RegistrationResponse response = successfulFuture.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
assertTrue(response instanceof JobMasterRegistrationSuccess);
}
use of org.apache.flink.runtime.registration.RegistrationResponse in project flink by apache.
the class ResourceManagerPartitionLifecycleTest method registerTaskExecutor.
public static void registerTaskExecutor(ResourceManagerGateway resourceManagerGateway, ResourceID taskExecutorId, String taskExecutorAddress) throws Exception {
final TaskExecutorRegistration taskExecutorRegistration = new TaskExecutorRegistration(taskExecutorAddress, taskExecutorId, 1234, 23456, new HardwareDescription(42, 1337L, 1337L, 0L), new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), ResourceProfile.ZERO, ResourceProfile.ZERO);
final CompletableFuture<RegistrationResponse> registrationFuture = resourceManagerGateway.registerTaskExecutor(taskExecutorRegistration, TestingUtils.TIMEOUT);
assertThat(registrationFuture.get(), instanceOf(RegistrationResponse.Success.class));
}
use of org.apache.flink.runtime.registration.RegistrationResponse in project flink by apache.
the class ResourceManagerTaskExecutorTest method testDisconnectTaskExecutor.
/**
* Tests that a TaskExecutor can disconnect from the {@link ResourceManager}.
*/
@Test
public void testDisconnectTaskExecutor() throws Exception {
final int numberSlots = 10;
final TaskExecutorRegistration taskExecutorRegistration = new TaskExecutorRegistration(taskExecutorGateway.getAddress(), taskExecutorResourceID, dataPort, jmxPort, hardwareDescription, new TaskExecutorMemoryConfiguration(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), DEFAULT_SLOT_PROFILE, DEFAULT_SLOT_PROFILE.multiply(numberSlots));
final RegistrationResponse registrationResponse = rmGateway.registerTaskExecutor(taskExecutorRegistration, TIMEOUT).get();
assertThat(registrationResponse, instanceOf(TaskExecutorRegistrationSuccess.class));
final InstanceID registrationId = ((TaskExecutorRegistrationSuccess) registrationResponse).getRegistrationId();
final Collection<SlotStatus> slots = createSlots(numberSlots);
final SlotReport slotReport = new SlotReport(slots);
rmGateway.sendSlotReport(taskExecutorResourceID, registrationId, slotReport, TIMEOUT).get();
final ResourceOverview resourceOverview = rmGateway.requestResourceOverview(TIMEOUT).get();
assertThat(resourceOverview.getNumberTaskManagers(), is(1));
assertThat(resourceOverview.getNumberRegisteredSlots(), is(numberSlots));
rmGateway.disconnectTaskManager(taskExecutorResourceID, new FlinkException("testDisconnectTaskExecutor"));
final ResourceOverview afterDisconnectResourceOverview = rmGateway.requestResourceOverview(TIMEOUT).get();
assertThat(afterDisconnectResourceOverview.getNumberTaskManagers(), is(0));
assertThat(afterDisconnectResourceOverview.getNumberRegisteredSlots(), is(0));
}
Aggregations