shuai-xu commented on a change in pull request #7227: [FLINK-11059] [runtime]
do not add releasing failed slot to free slots
URL: https://github.com/apache/flink/pull/7227#discussion_r293286781
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/TaskExecutorTest.java
##########
@@ -1662,6 +1665,82 @@ public void testTerminationOnFatalError() throws
Throwable {
}
}
+ /**
+ * Tests that task manager will sync slot with job master throw
heartbeat (See FLINK-11059).
+ */
+ @Test(timeout = 10000L)
+ public void testSyncSlotsWithJobMasterByHeartbeat() throws Exception {
+ final TaskSlotTable taskSlotTable = new TaskSlotTable(
+ Arrays.asList(ResourceProfile.UNKNOWN,
ResourceProfile.UNKNOWN),
+ timerService);
+ final TaskManagerServices taskManagerServices = new
TaskManagerServicesBuilder().setTaskSlotTable(taskSlotTable).build();
+
+ final TaskExecutor taskExecutor =
createTaskExecutor(taskManagerServices);
+
+ final TestingResourceManagerGateway
testingResourceManagerGateway = new TestingResourceManagerGateway();
+
+ final CompletableFuture<AllocationID> allocationNotifiedFree =
new CompletableFuture<>();
+
+ final CompletableFuture<Void> initialSlotReportFuture = new
CompletableFuture<>();
+
testingResourceManagerGateway.setSendSlotReportFunction(resourceIDInstanceIDSlotReportTuple3
-> {
+ initialSlotReportFuture.complete(null);
+ return
CompletableFuture.completedFuture(Acknowledge.get());
+
+ });
+
+
testingResourceManagerGateway.setNotifySlotAvailableConsumer(instanceIDSlotIDAllocationIDTuple3
->
+
allocationNotifiedFree.complete(instanceIDSlotIDAllocationIDTuple3.f2));
+
+ rpc.registerGateway(testingResourceManagerGateway.getAddress(),
testingResourceManagerGateway);
+
resourceManagerLeaderRetriever.notifyListener(testingResourceManagerGateway.getAddress(),
testingResourceManagerGateway.getFencingToken().toUUID());
+
+ final CountDownLatch slotOfferings = new CountDownLatch(2);
+ final CompletableFuture<AllocationID> failedSlotFuture = new
CompletableFuture<>();
+ final TestingJobMasterGateway jobMasterGateway = new
TestingJobMasterGatewayBuilder()
+ .setFailSlotConsumer((resourceID, allocationID,
throwable) -> {
+ failedSlotFuture.complete(allocationID);
+ })
+ .setOfferSlotsFunction((resourceID, slotOffers)
-> {
+ slotOffers.forEach((ignored) ->
slotOfferings.countDown());
+ return
CompletableFuture.completedFuture(new ArrayList<>(slotOffers));
+ })
+ .build();
+ final String jobManagerAddress = jobMasterGateway.getAddress();
+ rpc.registerGateway(jobManagerAddress, jobMasterGateway);
+ jobManagerLeaderRetriever.notifyListener(jobManagerAddress,
jobMasterGateway.getFencingToken().toUUID());
+
+ taskExecutor.start();
+
+ try {
+ final TaskExecutorGateway taskExecutorGateway =
taskExecutor.getSelfGateway(TaskExecutorGateway.class);
+
+ initialSlotReportFuture.get();
+
+ final SlotID slotId1 = new
SlotID(taskExecutor.getResourceID(), 0);
+ final SlotID slotId2 = new
SlotID(taskExecutor.getResourceID(), 1);
+ final AllocationID allocationIdInBoth = new
AllocationID();
+ final AllocationID allocationIdOnlyInJM = new
AllocationID();
+ final AllocationID allocationIdOnlyInTM = new
AllocationID();
+
+ taskExecutorGateway.requestSlot(slotId1, jobId,
allocationIdInBoth, "foobar", testingResourceManagerGateway.getFencingToken(),
timeout);
+ taskExecutorGateway.requestSlot(slotId2, jobId,
allocationIdOnlyInTM, "foobar",
testingResourceManagerGateway.getFencingToken(), timeout);
+
+ slotOfferings.await();
+
+ List<OfferedSlot> offeredSlots = Arrays.asList(
+ new OfferedSlot(0, allocationIdInBoth),
+ new OfferedSlot(1, allocationIdOnlyInJM)
+ );
+ SlotSnapshot snapshot = new SlotSnapshot(jobId,
offeredSlots);
+
taskExecutorGateway.heartbeatFromJobManager(ResourceID.generate(), snapshot);
+
+ assertEquals(allocationIdOnlyInJM,
failedSlotFuture.get());
+ assertEquals(allocationIdOnlyInTM,
allocationNotifiedFree.get());
Review comment:
OK
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services