Search in sources :

Example 76 with JobID

use of org.apache.flink.api.common.JobID in project flink by apache.

the class SlotManagerTest method testSlotAllocationFailedAtTaskManagerOccupiedByOther.

/**
	 * Tests that we did some allocation but failed / rejected by TaskManager, and slot is occupied by another request
	 * This can only occur after reconnect of the TaskExecutor.
	 */
@Test
public void testSlotAllocationFailedAtTaskManagerOccupiedByOther() {
    TestingSlotManager slotManager = new TestingSlotManager();
    final SlotID slotID = SlotID.generate();
    SlotStatus slot = new SlotStatus(slotID, DEFAULT_TESTING_PROFILE);
    SlotReport slotReport = new SlotReport(slot);
    slotManager.registerTaskExecutor(slotID.getResourceID(), taskExecutorRegistration, slotReport);
    SlotRequest request = new SlotRequest(new JobID(), new AllocationID(), DEFAULT_TESTING_PROFILE);
    slotManager.requestSlot(request);
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
    // slot is set empty by a reconnect of the TaskExecutor
    slotManager.registerTaskExecutor(slotID.getResourceID(), taskExecutorRegistration, slotReport);
    assertEquals(0, slotManager.getAllocatedSlotCount());
    assertEquals(1, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
    // another request takes the slot
    SlotRequest request2 = new SlotRequest(new JobID(), new AllocationID(), DEFAULT_TESTING_PROFILE);
    slotManager.requestSlot(request2);
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
    assertFalse(slotManager.isAllocated(request.getAllocationId()));
    assertTrue(slotManager.isAllocated(request2.getAllocationId()));
    // original request should be retried
    slotManager.handleSlotRequestFailedAtTaskManager(request, slotID);
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
    assertFalse(slotManager.isAllocated(request.getAllocationId()));
    assertTrue(slotManager.isAllocated(request2.getAllocationId()));
}
Also used : SlotID(org.apache.flink.runtime.clusterframework.types.SlotID) SlotStatus(org.apache.flink.runtime.taskexecutor.SlotStatus) SlotReport(org.apache.flink.runtime.taskexecutor.SlotReport) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotRequest(org.apache.flink.runtime.resourcemanager.SlotRequest) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 77 with JobID

use of org.apache.flink.api.common.JobID in project flink by apache.

the class SlotManagerTest method testSlotAllocationFailedAtTaskManager.

/**
	 * Tests that we did some allocation but failed / rejected by TaskManager, request will retry
	 */
@Test
public void testSlotAllocationFailedAtTaskManager() {
    TestingSlotManager slotManager = new TestingSlotManager();
    ResourceSlot slot = new ResourceSlot(SlotID.generate(), DEFAULT_TESTING_PROFILE, taskExecutorRegistration);
    slotManager.addFreeSlot(slot);
    SlotRequest request = new SlotRequest(new JobID(), new AllocationID(), DEFAULT_TESTING_PROFILE);
    slotManager.requestSlot(request);
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
    assertTrue(slotManager.isAllocated(slot.getSlotId()));
    slotManager.handleSlotRequestFailedAtTaskManager(request, slot.getSlotId());
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotRequest(org.apache.flink.runtime.resourcemanager.SlotRequest) ResourceSlot(org.apache.flink.runtime.clusterframework.types.ResourceSlot) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 78 with JobID

use of org.apache.flink.api.common.JobID in project flink by apache.

the class SlotManagerTest method testMultipleSlotRequestsWithOneSlot.

/**
	 * Tests multiple slot requests with one slots.
	 */
@Test
public void testMultipleSlotRequestsWithOneSlot() {
    TestingSlotManager slotManager = new TestingSlotManager();
    final AllocationID allocationID = new AllocationID();
    SlotRequest request1 = new SlotRequest(new JobID(), allocationID, DEFAULT_TESTING_PROFILE);
    slotManager.requestSlot(request1);
    final ResourceID resourceID = ResourceID.generate();
    final SlotStatus slotStatus = new SlotStatus(new SlotID(resourceID, 0), DEFAULT_TESTING_PROFILE);
    final SlotReport slotReport = new SlotReport(slotStatus);
    slotManager.registerTaskExecutor(resourceID, taskExecutorRegistration, slotReport);
    // another request pending
    SlotRequest request2 = new SlotRequest(new JobID(), new AllocationID(), DEFAULT_TESTING_PROFILE);
    slotManager.requestSlot(request2);
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(1, slotManager.getPendingRequestCount());
    assertTrue(slotManager.isAllocated(allocationID));
    assertTrue(slotManager.isAllocated(request1.getAllocationId()));
    // but slot is reported empty in a report in the meantime which shouldn't affect the state
    slotManager.notifySlotAvailable(resourceID, slotStatus.getSlotID());
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
    assertTrue(slotManager.isAllocated(slotStatus.getSlotID()));
    assertTrue(slotManager.isAllocated(request2.getAllocationId()));
    // but slot is reported empty in a report in the meantime which shouldn't affect the state
    slotManager.notifySlotAvailable(resourceID, slotStatus.getSlotID());
    assertEquals(0, slotManager.getAllocatedSlotCount());
    assertEquals(1, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
}
Also used : SlotID(org.apache.flink.runtime.clusterframework.types.SlotID) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) SlotStatus(org.apache.flink.runtime.taskexecutor.SlotStatus) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotReport(org.apache.flink.runtime.taskexecutor.SlotReport) SlotRequest(org.apache.flink.runtime.resourcemanager.SlotRequest) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 79 with JobID

use of org.apache.flink.api.common.JobID in project flink by apache.

the class SlotManagerTest method testExistingInUseSlotUpdateStatus.

/**
	 * Tests that we had a slot in-use and is freed again subsequently.
	 */
@Test
public void testExistingInUseSlotUpdateStatus() {
    TestingSlotManager slotManager = new TestingSlotManager();
    SlotID slotId = SlotID.generate();
    SlotStatus slotStatus = new SlotStatus(slotId, DEFAULT_TESTING_PROFILE, new JobID(), new AllocationID());
    SlotReport slotReport = new SlotReport(Collections.singletonList(slotStatus));
    slotManager.registerTaskExecutor(slotId.getResourceID(), taskExecutorRegistration, slotReport);
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertTrue(slotManager.isAllocated(slotId));
    // slot is freed again
    slotManager.notifySlotAvailable(slotId.getResourceID(), slotId);
    assertEquals(0, slotManager.getAllocatedSlotCount());
    assertEquals(1, slotManager.getFreeSlotCount());
    assertFalse(slotManager.isAllocated(slotId));
}
Also used : SlotID(org.apache.flink.runtime.clusterframework.types.SlotID) SlotStatus(org.apache.flink.runtime.taskexecutor.SlotStatus) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotReport(org.apache.flink.runtime.taskexecutor.SlotReport) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 80 with JobID

use of org.apache.flink.api.common.JobID in project flink by apache.

the class SlotManagerTest method testRequestSlotWithFreeSlot.

/**
	 * Tests that there are some free slots when we request, and the request is fulfilled immediately
	 */
@Test
public void testRequestSlotWithFreeSlot() {
    TestingSlotManager slotManager = new TestingSlotManager();
    directlyProvideFreeSlots(slotManager, DEFAULT_TESTING_PROFILE, 1);
    assertEquals(1, slotManager.getFreeSlotCount());
    slotManager.requestSlot(new SlotRequest(new JobID(), new AllocationID(), DEFAULT_TESTING_PROFILE));
    assertEquals(1, slotManager.getAllocatedSlotCount());
    assertEquals(0, slotManager.getFreeSlotCount());
    assertEquals(0, slotManager.getPendingRequestCount());
    assertEquals(0, slotManager.getAllocatedContainers().size());
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotRequest(org.apache.flink.runtime.resourcemanager.SlotRequest) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

JobID (org.apache.flink.api.common.JobID)335 Test (org.junit.Test)274 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)88 IOException (java.io.IOException)74 Configuration (org.apache.flink.configuration.Configuration)72 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)61 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)48 ActorGateway (org.apache.flink.runtime.instance.ActorGateway)47 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)44 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)42 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)38 ArrayList (java.util.ArrayList)37 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)32 KeyGroupRange (org.apache.flink.runtime.state.KeyGroupRange)31 HashMap (java.util.HashMap)29 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)29 FiniteDuration (scala.concurrent.duration.FiniteDuration)28 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)24 File (java.io.File)23 UUID (java.util.UUID)23