Search in sources :

Example 11 with SimpleActorGateway

use of org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.SimpleActorGateway in project flink by apache.

the class ExecutionVertexDeploymentTest method testDeployWithSynchronousAnswer.

@Test
public void testDeployWithSynchronousAnswer() {
    try {
        final JobVertexID jid = new JobVertexID();
        final ExecutionJobVertex ejv = getExecutionVertex(jid, new DirectScheduledExecutorService());
        final Instance instance = getInstance(new ActorTaskManagerGateway(new SimpleActorGateway(TestingUtils.directExecutionContext())));
        final SimpleSlot slot = instance.allocateSimpleSlot(ejv.getJobId());
        final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
        assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
        vertex.deployToSlot(slot);
        assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
        // no repeated scheduling
        try {
            vertex.deployToSlot(slot);
            fail("Scheduled from wrong state");
        } catch (IllegalStateException e) {
        // as expected
        }
        assertNull(vertex.getFailureCause());
        assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
        assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
        assertTrue(vertex.getStateTimestamp(ExecutionState.RUNNING) == 0);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : Instance(org.apache.flink.runtime.instance.Instance) ExecutionGraphTestUtils.getInstance(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getInstance) DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) SimpleActorGateway(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.SimpleActorGateway) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway) Test(org.junit.Test)

Aggregations

SimpleActorGateway (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.SimpleActorGateway)11 Instance (org.apache.flink.runtime.instance.Instance)11 ActorTaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway)11 Test (org.junit.Test)10 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)7 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)7 Scheduler (org.apache.flink.runtime.jobmanager.scheduler.Scheduler)7 IOException (java.io.IOException)5 SuppressRestartsException (org.apache.flink.runtime.execution.SuppressRestartsException)5 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)4 ExecutionGraphTestUtils.getExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex)4 ExecutionGraphTestUtils.getInstance (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getInstance)4 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)4 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)4 InfiniteDelayRestartStrategy (org.apache.flink.runtime.executiongraph.restart.InfiniteDelayRestartStrategy)3 FiniteDuration (scala.concurrent.duration.FiniteDuration)3 JobID (org.apache.flink.api.common.JobID)2 Configuration (org.apache.flink.configuration.Configuration)2 FixedDelayRestartStrategy (org.apache.flink.runtime.executiongraph.restart.FixedDelayRestartStrategy)2 Deadline (scala.concurrent.duration.Deadline)2