use of org.apache.flink.api.common.JobID in project flink by apache.
the class SchedulerTestUtils method getDummyTask.
public static Execution getDummyTask() {
ExecutionVertex vertex = mock(ExecutionVertex.class);
when(vertex.getJobId()).thenReturn(new JobID());
when(vertex.toString()).thenReturn("TEST-VERTEX");
Execution execution = mock(Execution.class);
when(execution.getVertex()).thenReturn(vertex);
return execution;
}
use of org.apache.flink.api.common.JobID in project flink by apache.
the class SchedulerTestUtils method getTestVertexWithLocation.
public static Execution getTestVertexWithLocation(JobVertexID jid, int taskIndex, int numTasks, TaskManagerLocation... locations) {
ExecutionVertex vertex = mock(ExecutionVertex.class);
when(vertex.getPreferredLocationsBasedOnInputs()).thenReturn(Arrays.asList(locations));
when(vertex.getJobId()).thenReturn(new JobID());
when(vertex.getJobvertexId()).thenReturn(jid);
when(vertex.getParallelSubtaskIndex()).thenReturn(taskIndex);
when(vertex.getTotalNumberOfParallelSubtasks()).thenReturn(numTasks);
when(vertex.getMaxParallelism()).thenReturn(numTasks);
when(vertex.toString()).thenReturn("TEST-VERTEX");
Execution execution = mock(Execution.class);
when(execution.getVertex()).thenReturn(vertex);
return execution;
}
use of org.apache.flink.api.common.JobID in project flink by apache.
the class ZooKeeperSubmittedJobGraphsStoreITCase method testUpdateJobGraphYouDidNotGetOrAdd.
@Test(expected = IllegalStateException.class)
public void testUpdateJobGraphYouDidNotGetOrAdd() throws Exception {
ZooKeeperSubmittedJobGraphStore jobGraphs = new ZooKeeperSubmittedJobGraphStore(ZooKeeper.createClient(), "/testUpdateJobGraphYouDidNotGetOrAdd", localStateStorage, Executors.directExecutor());
ZooKeeperSubmittedJobGraphStore otherJobGraphs = new ZooKeeperSubmittedJobGraphStore(ZooKeeper.createClient(), "/testUpdateJobGraphYouDidNotGetOrAdd", localStateStorage, Executors.directExecutor());
jobGraphs.start(null);
otherJobGraphs.start(null);
SubmittedJobGraph jobGraph = createSubmittedJobGraph(new JobID(), 0);
jobGraphs.putJobGraph(jobGraph);
otherJobGraphs.putJobGraph(jobGraph);
}
use of org.apache.flink.api.common.JobID in project flink by apache.
the class CoLocationConstraintTest method testAssignSlotAndLockLocation.
@Test
public void testAssignSlotAndLockLocation() {
try {
JobID jid = new JobID();
JobVertex vertex = new JobVertex("vertex");
vertex.setParallelism(1);
SlotSharingGroup sharingGroup = new SlotSharingGroup(vertex.getID());
SlotSharingGroupAssignment assignment = sharingGroup.getTaskAssignment();
CoLocationGroup constraintGroup = new CoLocationGroup(vertex);
CoLocationConstraint constraint = constraintGroup.getLocationConstraint(0);
// constraint is completely unassigned
assertFalse(constraint.isAssigned());
assertFalse(constraint.isAssignedAndAlive());
Instance instance1 = SchedulerTestUtils.getRandomInstance(2);
Instance instance2 = SchedulerTestUtils.getRandomInstance(2);
SharedSlot slot1_1 = instance1.allocateSharedSlot(jid, assignment);
SharedSlot slot1_2 = instance1.allocateSharedSlot(jid, assignment);
SharedSlot slot2_1 = instance2.allocateSharedSlot(jid, assignment);
SharedSlot slot2_2 = instance2.allocateSharedSlot(jid, assignment);
// constraint is still completely unassigned
assertFalse(constraint.isAssigned());
assertFalse(constraint.isAssignedAndAlive());
// set the slot, but do not lock the location yet
constraint.setSharedSlot(slot1_1);
assertFalse(constraint.isAssigned());
assertFalse(constraint.isAssignedAndAlive());
// try to get the location
try {
constraint.getLocation();
fail("should throw an IllegalStateException");
} catch (IllegalStateException e) {
// as expected
} catch (Exception e) {
fail("wrong exception, should be IllegalStateException");
}
// check that we can reassign the slot as long as the location is not locked
constraint.setSharedSlot(slot2_1);
// the previous slot should have been released now
assertTrue(slot1_1.isReleased());
// still the location is not assigned
assertFalse(constraint.isAssigned());
assertFalse(constraint.isAssignedAndAlive());
// we can do an identity re-assign
constraint.setSharedSlot(slot2_1);
assertFalse(slot2_1.isReleased());
// still the location is not assigned
assertFalse(constraint.isAssigned());
assertFalse(constraint.isAssignedAndAlive());
constraint.lockLocation();
// now, the location is assigned and we have a location
assertTrue(constraint.isAssigned());
assertTrue(constraint.isAssignedAndAlive());
assertEquals(instance2.getTaskManagerLocation(), constraint.getLocation());
// release the slot
slot2_1.releaseSlot();
// we should still have a location
assertTrue(constraint.isAssigned());
assertFalse(constraint.isAssignedAndAlive());
assertEquals(instance2.getTaskManagerLocation(), constraint.getLocation());
// we can not assign a different location
try {
constraint.setSharedSlot(slot1_2);
fail("should throw an IllegalArgumentException");
} catch (IllegalArgumentException e) {
// as expected
} catch (Exception e) {
fail("wrong exception, should be IllegalArgumentException");
}
// assign a new slot with the same location
constraint.setSharedSlot(slot2_2);
assertTrue(constraint.isAssigned());
assertTrue(constraint.isAssignedAndAlive());
assertEquals(instance2.getTaskManagerLocation(), constraint.getLocation());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.api.common.JobID in project flink by apache.
the class CheckpointMessagesTest method testTriggerAndConfirmCheckpoint.
@Test
public void testTriggerAndConfirmCheckpoint() {
try {
NotifyCheckpointComplete cc = new NotifyCheckpointComplete(new JobID(), new ExecutionAttemptID(), 45287698767345L, 467L);
testSerializabilityEqualsHashCode(cc);
TriggerCheckpoint tc = new TriggerCheckpoint(new JobID(), new ExecutionAttemptID(), 347652734L, 7576752L, CheckpointOptions.forFullCheckpoint());
testSerializabilityEqualsHashCode(tc);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations