use of org.apache.flink.runtime.jobmanager.slots.AllocatedSlot in project flink by apache.
the class ExecutionVertexLocalityTest method initializeLocation.
private void initializeLocation(ExecutionVertex vertex, TaskManagerLocation location) throws Exception {
// we need a bit of reflection magic to initialize the location without going through
// scheduling paths. we choose to do that, rather than the alternatives:
// - mocking the scheduler created fragile tests that break whenever the scheduler is adjusted
// - exposing test methods in the ExecutionVertex leads to undesirable setters
AllocatedSlot slot = new AllocatedSlot(new AllocationID(), jobId, location, 0, ResourceProfile.UNKNOWN, mock(TaskManagerGateway.class));
SimpleSlot simpleSlot = new SimpleSlot(slot, mock(SlotOwner.class), 0);
final Field locationField = Execution.class.getDeclaredField("assignedResource");
locationField.setAccessible(true);
locationField.set(vertex.getCurrentExecutionAttempt(), simpleSlot);
}
Aggregations