use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.
the class ExecutionVertexDeploymentTest method testDeployWithAsynchronousAnswer.
@Test
public void testDeployWithAsynchronousAnswer() {
try {
final JobVertexID jid = new JobVertexID();
final ExecutionJobVertex ejv = getExecutionVertex(jid);
final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
final Instance instance = getInstance(new ActorTaskManagerGateway(new SimpleActorGateway(TestingUtils.defaultExecutionContext())));
final SimpleSlot slot = instance.allocateSimpleSlot(ejv.getJobId());
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.deployToSlot(slot);
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
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());
}
}
use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.
the class ExecutionVertexDeploymentTest method testDeployFailedAsynchronously.
@Test
public void testDeployFailedAsynchronously() {
try {
final JobVertexID jid = new JobVertexID();
final ExecutionJobVertex ejv = getExecutionVertex(jid);
final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0], AkkaUtils.getDefaultTimeout());
final Instance instance = getInstance(new ActorTaskManagerGateway(new SimpleFailingActorGateway(TestingUtils.directExecutionContext())));
final SimpleSlot slot = instance.allocateSimpleSlot(ejv.getJobId());
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.deployToSlot(slot);
// wait until the state transition must be done
for (int i = 0; i < 100; i++) {
if (vertex.getExecutionState() == ExecutionState.FAILED && vertex.getFailureCause() != null) {
break;
} else {
Thread.sleep(10);
}
}
assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
assertNotNull(vertex.getFailureCause());
assertTrue(vertex.getFailureCause().getMessage().contains(ERROR_MESSAGE));
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.
the class ExecutionStateProgressTest method testAccumulatedStateFinished.
@Test
public void testAccumulatedStateFinished() {
try {
final JobID jid = new JobID();
final JobVertexID vid = new JobVertexID();
JobVertex ajv = new JobVertex("TestVertex", vid);
ajv.setParallelism(3);
ajv.setInvokableClass(mock(AbstractInvokable.class).getClass());
ExecutionGraph graph = new ExecutionGraph(TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), jid, "test job", new Configuration(), new SerializedValue<>(new ExecutionConfig()), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), new Scheduler(TestingUtils.defaultExecutionContext()));
graph.attachJobGraph(Collections.singletonList(ajv));
setGraphStatus(graph, JobStatus.RUNNING);
ExecutionJobVertex ejv = graph.getJobVertex(vid);
// mock resources and mock taskmanager
for (ExecutionVertex ee : ejv.getTaskVertices()) {
SimpleSlot slot = getInstance(new ActorTaskManagerGateway(new SimpleActorGateway(TestingUtils.defaultExecutionContext()))).allocateSimpleSlot(jid);
ee.deployToSlot(slot);
}
// finish all
for (ExecutionVertex ee : ejv.getTaskVertices()) {
ee.executionFinished();
}
assertTrue(ejv.isInFinalState());
assertEquals(JobStatus.FINISHED, graph.getState());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway in project flink by apache.
the class InstanceManagerTest method testReportHeartbeat.
@Test
public void testReportHeartbeat() {
try {
InstanceManager cm = new InstanceManager();
final int dataPort = 20000;
ResourceID resID1 = ResourceID.generate();
ResourceID resID2 = ResourceID.generate();
ResourceID resID3 = ResourceID.generate();
HardwareDescription hardwareDescription = HardwareDescription.extractFromSystem(4096);
InetAddress address = InetAddress.getByName("127.0.0.1");
// register three instances
TaskManagerLocation ici1 = new TaskManagerLocation(resID1, address, dataPort);
TaskManagerLocation ici2 = new TaskManagerLocation(resID2, address, dataPort + 1);
TaskManagerLocation ici3 = new TaskManagerLocation(resID3, address, dataPort + 2);
JavaTestKit probe1 = new JavaTestKit(system);
JavaTestKit probe2 = new JavaTestKit(system);
JavaTestKit probe3 = new JavaTestKit(system);
InstanceID instanceID1 = cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe1.getRef(), leaderSessionID)), ici1, hardwareDescription, 1);
InstanceID instanceID2 = cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe2.getRef(), leaderSessionID)), ici2, hardwareDescription, 1);
InstanceID instanceID3 = cm.registerTaskManager(new ActorTaskManagerGateway(new AkkaActorGateway(probe3.getRef(), leaderSessionID)), ici3, hardwareDescription, 1);
// report some immediate heart beats
assertTrue(cm.reportHeartBeat(instanceID1));
assertTrue(cm.reportHeartBeat(instanceID2));
assertTrue(cm.reportHeartBeat(instanceID3));
// report heart beat for non-existing instance
assertFalse(cm.reportHeartBeat(new InstanceID()));
final long WAIT = 200;
CommonTestUtils.sleepUninterruptibly(WAIT);
Iterator<Instance> it = cm.getAllRegisteredInstances().iterator();
Instance instance1 = it.next();
long h1 = instance1.getLastHeartBeat();
long h2 = it.next().getLastHeartBeat();
long h3 = it.next().getLastHeartBeat();
// send one heart beat again and verify that the
assertTrue(cm.reportHeartBeat(instance1.getId()));
long newH1 = instance1.getLastHeartBeat();
long now = System.currentTimeMillis();
assertTrue(now - h1 >= WAIT);
assertTrue(now - h2 >= WAIT);
assertTrue(now - h3 >= WAIT);
assertTrue(now - newH1 <= WAIT);
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 InstanceTest method testAllocatingAndCancellingSlots.
@Test
public void testAllocatingAndCancellingSlots() {
try {
ResourceID resourceID = ResourceID.generate();
HardwareDescription hardwareDescription = new HardwareDescription(4, 2L * 1024 * 1024 * 1024, 1024 * 1024 * 1024, 512 * 1024 * 1024);
InetAddress address = InetAddress.getByName("127.0.0.1");
TaskManagerLocation connection = new TaskManagerLocation(resourceID, address, 10001);
Instance instance = new Instance(new ActorTaskManagerGateway(DummyActorGateway.INSTANCE), connection, new InstanceID(), hardwareDescription, 4);
assertEquals(4, instance.getTotalNumberOfSlots());
assertEquals(4, instance.getNumberOfAvailableSlots());
assertEquals(0, instance.getNumberOfAllocatedSlots());
SimpleSlot slot1 = instance.allocateSimpleSlot(new JobID());
SimpleSlot slot2 = instance.allocateSimpleSlot(new JobID());
SimpleSlot slot3 = instance.allocateSimpleSlot(new JobID());
SimpleSlot slot4 = instance.allocateSimpleSlot(new JobID());
assertNotNull(slot1);
assertNotNull(slot2);
assertNotNull(slot3);
assertNotNull(slot4);
assertEquals(0, instance.getNumberOfAvailableSlots());
assertEquals(4, instance.getNumberOfAllocatedSlots());
assertEquals(6, slot1.getSlotNumber() + slot2.getSlotNumber() + slot3.getSlotNumber() + slot4.getSlotNumber());
// no more slots
assertNull(instance.allocateSimpleSlot(new JobID()));
try {
instance.returnAllocatedSlot(slot2);
fail("instance accepted a non-cancelled slot.");
} catch (IllegalArgumentException e) {
// good
}
// release the slots. this returns them to the instance
slot1.releaseSlot();
slot2.releaseSlot();
slot3.releaseSlot();
slot4.releaseSlot();
assertEquals(4, instance.getNumberOfAvailableSlots());
assertEquals(0, instance.getNumberOfAllocatedSlots());
assertFalse(instance.returnAllocatedSlot(slot1));
assertFalse(instance.returnAllocatedSlot(slot2));
assertFalse(instance.returnAllocatedSlot(slot3));
assertFalse(instance.returnAllocatedSlot(slot4));
assertEquals(4, instance.getNumberOfAvailableSlots());
assertEquals(0, instance.getNumberOfAllocatedSlots());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations