Search in sources :

Example 16 with AllocatedSlot

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);
}
Also used : SlotOwner(org.apache.flink.runtime.jobmanager.slots.SlotOwner) Field(java.lang.reflect.Field) AllocatedSlot(org.apache.flink.runtime.jobmanager.slots.AllocatedSlot) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot)

Aggregations

AllocatedSlot (org.apache.flink.runtime.jobmanager.slots.AllocatedSlot)16 Test (org.junit.Test)9 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)8 Time (org.apache.flink.api.common.time.Time)6 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)6 ScheduledUnit (org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit)6 UUID (java.util.UUID)5 SlotRequest (org.apache.flink.runtime.resourcemanager.SlotRequest)5 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)5 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)4 TaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JobID (org.apache.flink.api.common.JobID)2 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)2 Slot (org.apache.flink.runtime.instance.Slot)2 Field (java.lang.reflect.Field)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeoutException (java.util.concurrent.TimeoutException)1 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1