Search in sources :

Example 6 with ActorTaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.

the class ExecutionVertexSchedulingTest method testSlotReleasedWhenScheduledImmediately.

@Test
public void testSlotReleasedWhenScheduledImmediately() {
    try {
        final ExecutionJobVertex ejv = getExecutionVertex(new JobVertexID());
        final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
        // a slot than cannot be deployed to
        final Instance instance = getInstance(new ActorTaskManagerGateway(DummyActorGateway.INSTANCE));
        final SimpleSlot slot = instance.allocateSimpleSlot(ejv.getJobId());
        slot.releaseSlot();
        assertTrue(slot.isReleased());
        Scheduler scheduler = mock(Scheduler.class);
        FlinkCompletableFuture<SimpleSlot> future = new FlinkCompletableFuture<>();
        future.complete(slot);
        when(scheduler.allocateSlot(Matchers.any(ScheduledUnit.class), anyBoolean())).thenReturn(future);
        assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
        // try to deploy to the slot
        vertex.scheduleForExecution(scheduler, false);
        // will have failed
        assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
    } 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) Scheduler(org.apache.flink.runtime.jobmanager.scheduler.Scheduler) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ScheduledUnit(org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) FlinkCompletableFuture(org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway) Test(org.junit.Test)

Example 7 with ActorTaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.

the class ExecutionVertexSchedulingTest method testScheduleToDeploying.

@Test
public void testScheduleToDeploying() {
    try {
        final ExecutionJobVertex ejv = getExecutionVertex(new JobVertexID());
        final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
        final Instance instance = getInstance(new ActorTaskManagerGateway(new ExecutionGraphTestUtils.SimpleActorGateway(TestingUtils.defaultExecutionContext())));
        final SimpleSlot slot = instance.allocateSimpleSlot(ejv.getJobId());
        Scheduler scheduler = mock(Scheduler.class);
        FlinkCompletableFuture<SimpleSlot> future = new FlinkCompletableFuture<>();
        future.complete(slot);
        when(scheduler.allocateSlot(Matchers.any(ScheduledUnit.class), anyBoolean())).thenReturn(future);
        assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
        // try to deploy to the slot
        vertex.scheduleForExecution(scheduler, false);
        assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
    } 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) Scheduler(org.apache.flink.runtime.jobmanager.scheduler.Scheduler) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ScheduledUnit(org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) FlinkCompletableFuture(org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway) Test(org.junit.Test)

Example 8 with ActorTaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.

the class ExecutionVertexStopTest method testStopRpc.

@Test
public void testStopRpc() throws Exception {
    final JobVertexID jid = new JobVertexID();
    final ExecutionJobVertex ejv = getExecutionVertex(jid);
    final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
    final ExecutionAttemptID execId = vertex.getCurrentExecutionAttempt().getAttemptId();
    setVertexState(vertex, ExecutionState.SCHEDULED);
    assertEquals(ExecutionState.SCHEDULED, vertex.getExecutionState());
    final ActorGateway gateway = new StopSequenceInstanceGateway(TestingUtils.defaultExecutionContext());
    Instance instance = getInstance(new ActorTaskManagerGateway(gateway));
    SimpleSlot slot = instance.allocateSimpleSlot(new JobID());
    vertex.deployToSlot(slot);
    receivedStopSignal = false;
    vertex.stop();
    assertTrue(receivedStopSignal);
}
Also used : Instance(org.apache.flink.runtime.instance.Instance) ExecutionGraphTestUtils.getInstance(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getInstance) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) BaseTestingActorGateway(org.apache.flink.runtime.instance.BaseTestingActorGateway) ActorGateway(org.apache.flink.runtime.instance.ActorGateway) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) JobID(org.apache.flink.api.common.JobID) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with ActorTaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.

the class InstanceManagerTest method testInstanceRegistering.

@Test
public void testInstanceRegistering() {
    try {
        InstanceManager cm = new InstanceManager();
        final int dataPort = 20000;
        HardwareDescription hardwareDescription = HardwareDescription.extractFromSystem(4096);
        InetAddress address = InetAddress.getByName("127.0.0.1");
        // register three instances
        ResourceID resID1 = ResourceID.generate();
        ResourceID resID2 = ResourceID.generate();
        ResourceID resID3 = ResourceID.generate();
        TaskManagerLocation ici1 = new TaskManagerLocation(resID1, address, dataPort);
        TaskManagerLocation ici2 = new TaskManagerLocation(resID2, address, dataPort + 15);
        TaskManagerLocation ici3 = new TaskManagerLocation(resID3, address, dataPort + 30);
        final JavaTestKit probe1 = new JavaTestKit(system);
        final JavaTestKit probe2 = new JavaTestKit(system);
        final JavaTestKit probe3 = new JavaTestKit(system);
        cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe1.getRef(), leaderSessionID)), ici1, hardwareDescription, 1);
        cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe2.getRef(), leaderSessionID)), ici2, hardwareDescription, 2);
        cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe3.getRef(), leaderSessionID)), ici3, hardwareDescription, 5);
        assertEquals(3, cm.getNumberOfRegisteredTaskManagers());
        assertEquals(8, cm.getTotalNumberOfSlots());
        Collection<Instance> instances = cm.getAllRegisteredInstances();
        Set<TaskManagerLocation> taskManagerLocations = new HashSet<TaskManagerLocation>();
        for (Instance instance : instances) {
            taskManagerLocations.add(instance.getTaskManagerLocation());
        }
        assertTrue(taskManagerLocations.contains(ici1));
        assertTrue(taskManagerLocations.contains(ici2));
        assertTrue(taskManagerLocations.contains(ici3));
        cm.shutdown();
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        Assert.fail("Test erroneous: " + e.getMessage());
    }
}
Also used : TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) InetAddress(java.net.InetAddress) JavaTestKit(akka.testkit.JavaTestKit) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with ActorTaskManagerGateway

use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.

the class InstanceManagerTest method testShutdown.

@Test
public void testShutdown() {
    try {
        InstanceManager cm = new InstanceManager();
        cm.shutdown();
        try {
            ResourceID resID = ResourceID.generate();
            HardwareDescription resources = HardwareDescription.extractFromSystem(4096);
            InetAddress address = InetAddress.getByName("127.0.0.1");
            TaskManagerLocation ici = new TaskManagerLocation(resID, address, 20000);
            JavaTestKit probe = new JavaTestKit(system);
            cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe.getRef(), leaderSessionID)), ici, resources, 1);
            fail("Should raise exception in shutdown state");
        } catch (IllegalStateException e) {
        // expected
        }
        assertFalse(cm.reportHeartBeat(new InstanceID()));
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        Assert.fail("Test erroneous: " + e.getMessage());
    }
}
Also used : ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) InetAddress(java.net.InetAddress) JavaTestKit(akka.testkit.JavaTestKit) ActorTaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway) Test(org.junit.Test)

Aggregations

ActorTaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway)40 Test (org.junit.Test)36 Instance (org.apache.flink.runtime.instance.Instance)29 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)22 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)22 JobID (org.apache.flink.api.common.JobID)20 Scheduler (org.apache.flink.runtime.jobmanager.scheduler.Scheduler)16 IOException (java.io.IOException)14 ExecutionGraphTestUtils.getInstance (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getInstance)12 SimpleActorGateway (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.SimpleActorGateway)11 ExecutionGraphTestUtils.getExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex)11 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)11 InetAddress (java.net.InetAddress)9 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)9 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)9 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)8 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)8 BaseTestingActorGateway (org.apache.flink.runtime.instance.BaseTestingActorGateway)8 DirectScheduledExecutorService (org.apache.flink.runtime.testutils.DirectScheduledExecutorService)8 DummyActorGateway (org.apache.flink.runtime.instance.DummyActorGateway)7