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());
}
}
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());
}
}
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);
}
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());
}
}
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());
}
}
Aggregations