GJL commented on a change in pull request #9860: [FLINK-14331][runtime] Reset 
vertices right after they transition to terminated states
URL: https://github.com/apache/flink/pull/9860#discussion_r333521037
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/scheduler/DefaultSchedulerTest.java
 ##########
 @@ -254,6 +262,58 @@ public void failJobIfNotEnoughResources() throws 
Exception {
                                "Could not allocate the required slot within 
slot request timeout.").isPresent());
        }
 
+       @Test
+       public void vertexIsResetBeforeRestarted() throws Exception {
+               final JobGraph jobGraph = singleNonParallelJobVertexJobGraph();
+
+               final TestSchedulingStrategy.Factory schedulingStrategyFactory 
= new TestSchedulingStrategy.Factory();
+               final DefaultScheduler scheduler = createScheduler(jobGraph, 
schedulingStrategyFactory);
+               final TestSchedulingStrategy schedulingStrategy = 
schedulingStrategyFactory.getLastCreatedSchedulingStrategy();
+               final SchedulingTopology topology = 
schedulingStrategy.getSchedulingTopology();
+
+               startScheduling(scheduler);
+
+               final SchedulingExecutionVertex vertex = 
Iterables.getOnlyElement(topology.getVertices());
+               final ExecutionAttemptID attemptId = 
scheduler.getExecutionVertex(vertex.getId()).getCurrentExecutionAttempt().getAttemptId();
+
+               
schedulingStrategy.schedule(Collections.singleton(vertex.getId()));
+
+               scheduler.updateTaskExecutionState(new 
TaskExecutionState(jobGraph.getJobID(), attemptId, ExecutionState.FAILED));
+
+               taskRestartExecutor.triggerScheduledTasks();
+
+               Set<ExecutionVertexID> verticesToRestart = 
schedulingStrategy.getReceivedVerticesToRestart();
+               assertEquals(1, verticesToRestart.size());
+               assertEquals(ExecutionState.CREATED, 
topology.getVertexOrThrow(verticesToRestart.iterator().next()).getState());
+       }
+
+       @Test
+       public void scheduleOnlyIfVertexIsCreated() throws Exception {
+               final JobGraph jobGraph = singleNonParallelJobVertexJobGraph();
+
+               final TestSchedulingStrategy.Factory schedulingStrategyFactory 
= new TestSchedulingStrategy.Factory();
+               final DefaultScheduler scheduler = createScheduler(jobGraph, 
schedulingStrategyFactory);
+               final TestSchedulingStrategy schedulingStrategy = 
schedulingStrategyFactory.getLastCreatedSchedulingStrategy();
+               final SchedulingTopology topology = 
schedulingStrategy.getSchedulingTopology();
+
+               startScheduling(scheduler);
+
+               final SchedulingExecutionVertex vertex = 
Iterables.getOnlyElement(topology.getVertices());
+
+               // The first time scheduling of a vertex will result in one 
deployment
+               
schedulingStrategy.schedule(Collections.singleton(vertex.getId()));
+               testTaskManagerGateway.getDeployedExecutionVertices(1, 
TIMEOUT_MS);
+
+               // The scheduling of a non-CREATED vertex will result in no 
deployment
+               
schedulingStrategy.schedule(Collections.singleton(vertex.getId()));
+               try {
+                       testTaskManagerGateway.getDeployedExecutionVertices(1, 
TIMEOUT_MS);
 
 Review comment:
   It's probably better to use the changes from #9872 later

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to