RocMarshal commented on code in PR #25113:
URL: https://github.com/apache/flink/pull/25113#discussion_r1689451505
##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DeclarativeSlotPoolService.java:
##########
@@ -81,18 +84,26 @@ public DeclarativeSlotPoolService(
DeclarativeSlotPoolFactory declarativeSlotPoolFactory,
Clock clock,
Time idleSlotTimeout,
- Time rpcTimeout) {
+ Time rpcTimeout,
+ Duration slotRequestMaxInterval,
+ @Nonnull ComponentMainThreadExecutor componentMainThreadExecutor) {
this.jobId = jobId;
this.clock = clock;
this.rpcTimeout = rpcTimeout;
this.registeredTaskManagers = new HashSet<>();
this.declarativeSlotPool =
declarativeSlotPoolFactory.create(
- jobId, this::declareResourceRequirements,
idleSlotTimeout, rpcTimeout);
+ jobId,
+ this::declareResourceRequirements,
+ idleSlotTimeout,
+ rpcTimeout,
+ slotRequestMaxInterval,
+ componentMainThreadExecutor);
}
- protected DeclarativeSlotPool getDeclarativeSlotPool() {
+ @VisibleForTesting
+ public DeclarativeSlotPool getDeclarativeSlotPool() {
Review Comment:
removed
##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DeclarativeSlotPoolService.java:
##########
@@ -81,18 +84,26 @@ public DeclarativeSlotPoolService(
DeclarativeSlotPoolFactory declarativeSlotPoolFactory,
Clock clock,
Time idleSlotTimeout,
- Time rpcTimeout) {
+ Time rpcTimeout,
+ Duration slotRequestMaxInterval,
+ @Nonnull ComponentMainThreadExecutor componentMainThreadExecutor) {
Review Comment:
updated
##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultDeclarativeSlotPool.java:
##########
@@ -599,4 +632,27 @@ private ResourceCounter getFulfilledRequirements(
ResourceCounter getFulfilledResourceRequirements() {
return fulfilledResourceRequirements;
}
+
+ @VisibleForTesting
+ @Nonnull
+ public ComponentMainThreadExecutor getComponentMainThreadExecutor() {
+ return componentMainThreadExecutor;
+ }
+
+ @VisibleForTesting
+ @Nonnull
+ public Duration getSlotRequestMaxInterval() {
+ return slotRequestMaxInterval;
+ }
Review Comment:
deleted.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/BlocklistDeclarativeSlotPoolTest.java:
##########
@@ -299,14 +310,22 @@ public BlocklistDeclarativeSlotPoolBuilder
setBlockedTaskManagerChecker(
return this;
}
- public BlocklistDeclarativeSlotPool build() {
+ public BlocklistDeclarativeSlotPool build(
+ Duration slotRequestMaxInterval,
+ ComponentMainThreadExecutor componentMainThreadExecutor) {
return new BlocklistDeclarativeSlotPool(
new JobID(),
new DefaultAllocatedSlotPool(),
ignored -> {},
blockedTaskManagerChecker,
Time.seconds(20),
- Time.seconds(20));
+ Time.seconds(20),
+ slotRequestMaxInterval,
+ componentMainThreadExecutor);
+ }
+
+ public BlocklistDeclarativeSlotPool build() {
+ return build(Duration.ZERO, forMainThread());
Review Comment:
updated.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultDeclarativeSlotPoolTestBase.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.jobmaster.slotpool;
+
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
+import
org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter;
+import org.apache.flink.testutils.junit.extensions.parameterized.Parameter;
+import org.apache.flink.testutils.junit.extensions.parameterized.Parameters;
+
+import org.assertj.core.util.Lists;
+
+import java.time.Duration;
+import java.util.List;
+
+/**
+ * Tests base class for the {@link DefaultDeclarativeSlotPool} & {@link
+ * BlocklistDeclarativeSlotPool}.
Review Comment:
updated.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DeclarativeSlotPoolBridgeTest.java:
##########
@@ -280,7 +279,9 @@ static DeclarativeSlotPoolBridge
createDeclarativeSlotPoolBridge(
rpcTimeout,
Time.seconds(20),
Time.seconds(20),
- requestSlotMatchingStrategy);
+ requestSlotMatchingStrategy,
+ Duration.ZERO,
+ forMainThread());
Review Comment:
updated.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DeclarativeSlotPoolServiceTest.java:
##########
@@ -360,7 +360,9 @@ private DeclarativeSlotPoolService
createDeclarativeSlotPoolService(
declarativeSlotPoolFactory,
SystemClock.getInstance(),
Time.seconds(20L),
- Time.seconds(20L));
+ Time.seconds(20L),
+ Duration.ZERO,
+ forMainThread());
declarativeSlotPoolService.start(jobMasterId, address,
mainThreadExecutor);
Review Comment:
updated.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultDeclarativeSlotPool.java:
##########
@@ -103,12 +108,20 @@ public class DefaultDeclarativeSlotPool implements
DeclarativeSlotPool {
private final RequirementMatcher requirementMatcher = new
DefaultRequirementMatcher();
+ @Nonnull private final ComponentMainThreadExecutor
componentMainThreadExecutor;
+
+ // For slots(resources) requests by batch.
+ @Nonnull private final Duration slotRequestMaxInterval;
+ @Nullable private ScheduledFuture<?> slotRequestMaxIntervalTimeoutFuture;
Review Comment:
updated.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DeclarativeSlotPoolBridgePreferredAllocationsTest.java:
##########
@@ -54,12 +55,11 @@ void
testDeclarativeSlotPoolTakesPreferredAllocationsIntoAccount() throws Except
TestingUtils.infiniteTime(),
TestingUtils.infiniteTime(),
TestingUtils.infiniteTime(),
-
PreferredAllocationRequestSlotMatchingStrategy.INSTANCE);
+
PreferredAllocationRequestSlotMatchingStrategy.INSTANCE,
+ Duration.ZERO,
+ forMainThread());
- declarativeSlotPoolBridge.start(
- JobMasterId.generate(),
- "localhost",
- ComponentMainThreadExecutorServiceAdapter.forMainThread());
+ declarativeSlotPoolBridge.start(JobMasterId.generate(), "localhost",
forMainThread());
Review Comment:
sorted for all related change and updated.
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultDeclarativeSlotPoolTest.java:
##########
@@ -58,45 +61,66 @@
import static org.assertj.core.api.Assertions.assertThat;
/** Tests for the {@link DefaultDeclarativeSlotPool}. */
-class DefaultDeclarativeSlotPoolTest {
+@ExtendWith(ParameterizedTestExtension.class)
+class DefaultDeclarativeSlotPoolTest extends
DefaultDeclarativeSlotPoolTestBase {
Review Comment:
Thanks for the comment.
As show in the existed test cases, Although there are no separate test cases
created to solely test this effect, there are several methods in the current
class that already have assert statements that can achieve this testing effect.
Of course, I'd be willing to create a new test case separately to
specifically test this effect if necessary
##########
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/BlocklistDeclarativeSlotPoolTest.java:
##########
@@ -154,7 +163,7 @@ private void testRegisterSlots(boolean isBlocked) {
BlocklistDeclarativeSlotPoolBuilder.builder()
.setBlockedTaskManagerChecker(
isBlocked ?
taskManager.getResourceID()::equals : ignore -> false)
- .build();
+ .build(Duration.ZERO, componentMainThreadExecutor);
Review Comment:
thx for the comment.
The test case is nothing about slot request max interval ?
##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultDeclarativeSlotPool.java:
##########
@@ -599,4 +632,27 @@ private ResourceCounter getFulfilledRequirements(
ResourceCounter getFulfilledResourceRequirements() {
return fulfilledResourceRequirements;
}
+
+ @VisibleForTesting
+ @Nonnull
+ public ComponentMainThreadExecutor getComponentMainThreadExecutor() {
+ return componentMainThreadExecutor;
+ }
+
+ @VisibleForTesting
+ @Nonnull
+ public Duration getSlotRequestMaxInterval() {
+ return slotRequestMaxInterval;
+ }
+
+ @VisibleForTesting
+ public void tryWaitSlotRequestMaxIntervalTimeout() {
Review Comment:
updated.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DeclarativeSlotPoolBridge.java:
##########
@@ -548,4 +558,13 @@ void increaseResourceRequirementsBy(ResourceCounter
increment) {
boolean isBatchSlotRequestTimeoutCheckEnabled() {
return !isBatchSlotRequestTimeoutCheckDisabled;
}
+
+ @VisibleForTesting
+ public void tryWaitSlotRequestMaxIntervalTimeout() {
Review Comment:
removed
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]