Skip to content

Commit

Permalink
[FLINK-36880][network] Handle the finished vertex in InputConsumableD…
Browse files Browse the repository at this point in the history
…ecider
  • Loading branch information
reswqa committed Dec 23, 2024
1 parent 1523f2c commit 8c6aa0b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.apache.flink.runtime.scheduler.strategy;

import org.apache.flink.runtime.execution.ExecutionState;

import java.util.Map;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -60,7 +62,8 @@ private Factory() {}
@Override
public InputConsumableDecider createInstance(
SchedulingTopology schedulingTopology,
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever) {
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever,
Function<ExecutionVertexID, ExecutionState> executionStateRetriever) {
return new AllFinishedInputConsumableDecider();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.flink.runtime.scheduler.strategy;

import org.apache.flink.runtime.execution.ExecutionState;
import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID;

import java.util.Map;
Expand All @@ -40,12 +41,16 @@ public class DefaultInputConsumableDecider implements InputConsumableDecider {

private final Function<ExecutionVertexID, Boolean> scheduledVertexRetriever;

private final Function<ExecutionVertexID, ExecutionState> executionStateRetriever;

DefaultInputConsumableDecider(
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever,
Function<IntermediateResultPartitionID, SchedulingResultPartition>
resultPartitionRetriever) {
resultPartitionRetriever,
Function<ExecutionVertexID, ExecutionState> executionStateRetriever) {
this.scheduledVertexRetriever = scheduledVertexRetriever;
this.resultPartitionRetriever = resultPartitionRetriever;
this.executionStateRetriever = executionStateRetriever;
}

@Override
Expand Down Expand Up @@ -86,7 +91,12 @@ private boolean isConsumedPartitionGroupConsumable(
ExecutionVertexID producerVertex =
resultPartitionRetriever.apply(partitionId).getProducer().getId();
if (!verticesToSchedule.contains(producerVertex)
&& !scheduledVertexRetriever.apply(producerVertex)) {
&& !scheduledVertexRetriever.apply(producerVertex)
// For jm failover: the producer can be transitioned to FINISHED state not
// touched by scheduling strategy. This means all producer
// partitions finished, so we can schedule the downstream execution.
&& executionStateRetriever.apply(producerVertex)
!= ExecutionState.FINISHED) {
return false;
}
}
Expand All @@ -112,9 +122,12 @@ private Factory() {}
@Override
public InputConsumableDecider createInstance(
SchedulingTopology schedulingTopology,
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever) {
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever,
Function<ExecutionVertexID, ExecutionState> executionStateRetriever) {
return new DefaultInputConsumableDecider(
scheduledVertexRetriever, schedulingTopology::getResultPartition);
scheduledVertexRetriever,
schedulingTopology::getResultPartition,
executionStateRetriever);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.apache.flink.runtime.scheduler.strategy;

import org.apache.flink.runtime.execution.ExecutionState;

import java.util.Map;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -53,6 +55,7 @@ boolean isConsumableBasedOnFinishedProducers(
interface Factory {
InputConsumableDecider createInstance(
SchedulingTopology schedulingTopology,
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever);
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever,
Function<ExecutionVertexID, ExecutionState> executionStateRetriever);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.apache.flink.runtime.scheduler.strategy;

import org.apache.flink.runtime.execution.ExecutionState;

import java.util.Map;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -75,7 +77,8 @@ private Factory() {}
@Override
public InputConsumableDecider createInstance(
SchedulingTopology schedulingTopology,
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever) {
Function<ExecutionVertexID, Boolean> scheduledVertexRetriever,
Function<ExecutionVertexID, ExecutionState> executionStateRetriever) {
return new PartialFinishedInputConsumableDecider();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public VertexwiseSchedulingStrategy(
this.schedulingTopology = checkNotNull(schedulingTopology);
this.inputConsumableDecider =
inputConsumableDeciderFactory.createInstance(
schedulingTopology, scheduledVertices::contains);
schedulingTopology,
scheduledVertices::contains,
(executionVertexId) ->
schedulingTopology.getVertex(executionVertexId).getState());
LOG.info(
"Using InputConsumableDecider {} for VertexwiseSchedulingStrategy.",
inputConsumableDecider.getClass().getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ void testHybridAndBlockingInputButBlockingInputNotFinished() {
private DefaultInputConsumableDecider createDefaultInputConsumableDecider(
Set<ExecutionVertexID> scheduledVertices, SchedulingTopology schedulingTopology) {
return new DefaultInputConsumableDecider(
scheduledVertices::contains, schedulingTopology::getResultPartition);
scheduledVertices::contains,
schedulingTopology::getResultPartition,
(id) -> schedulingTopology.getVertex(id).getState());
}
}

0 comments on commit 8c6aa0b

Please sign in to comment.