Search in sources :

Example 16 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID 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 17 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID 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 18 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID 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)

Example 19 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class SlotManagerTest method testNewlyAppearedFreeSlotNotMatchPendingRequests.

/**
	 * Tests that a new slot appeared in SlotReport, but it't not suitable for all the pending requests
	 */
@Test
public void testNewlyAppearedFreeSlotNotMatchPendingRequests() {
    TestingSlotManager slotManager = new TestingSlotManager();
    slotManager.requestSlot(new SlotRequest(new JobID(), new AllocationID(), DEFAULT_TESTING_BIG_PROFILE));
    assertEquals(1, slotManager.getPendingRequestCount());
    SlotID slotId = SlotID.generate();
    SlotStatus slotStatus = new SlotStatus(slotId, DEFAULT_TESTING_PROFILE);
    SlotReport slotReport = new SlotReport(Collections.singletonList(slotStatus));
    slotManager.registerTaskExecutor(slotId.getResourceID(), taskExecutorRegistration, slotReport);
    assertEquals(0, slotManager.getAllocatedSlotCount());
    assertEquals(1, slotManager.getFreeSlotCount());
    assertEquals(1, slotManager.getPendingRequestCount());
    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) SlotRequest(org.apache.flink.runtime.resourcemanager.SlotRequest) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 20 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class TaskManagerTest method createTaskDeploymentDescriptor.

private static TaskDeploymentDescriptor createTaskDeploymentDescriptor(JobID jobId, String jobName, JobVertexID jobVertexId, ExecutionAttemptID executionAttemptId, SerializedValue<ExecutionConfig> serializedExecutionConfig, String taskName, int numberOfKeyGroups, int subtaskIndex, int parallelism, int attemptNumber, Configuration jobConfiguration, Configuration taskConfiguration, String invokableClassName, Collection<ResultPartitionDeploymentDescriptor> producedPartitions, Collection<InputGateDeploymentDescriptor> inputGates, Collection<BlobKey> requiredJarFiles, Collection<URL> requiredClasspaths, int targetSlotNumber) throws IOException {
    JobInformation jobInformation = new JobInformation(jobId, jobName, serializedExecutionConfig, jobConfiguration, requiredJarFiles, requiredClasspaths);
    TaskInformation taskInformation = new TaskInformation(jobVertexId, taskName, parallelism, numberOfKeyGroups, invokableClassName, taskConfiguration);
    SerializedValue<JobInformation> serializedJobInformation = new SerializedValue<>(jobInformation);
    SerializedValue<TaskInformation> serializedJobVertexInformation = new SerializedValue<>(taskInformation);
    return new TaskDeploymentDescriptor(serializedJobInformation, serializedJobVertexInformation, executionAttemptId, new AllocationID(), subtaskIndex, attemptNumber, targetSlotNumber, null, producedPartitions, inputGates);
}
Also used : JobInformation(org.apache.flink.runtime.executiongraph.JobInformation) TaskInformation(org.apache.flink.runtime.executiongraph.TaskInformation) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) TaskDeploymentDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor) SerializedValue(org.apache.flink.util.SerializedValue)

Aggregations

AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)45 JobID (org.apache.flink.api.common.JobID)29 Test (org.junit.Test)27 SlotRequest (org.apache.flink.runtime.resourcemanager.SlotRequest)16 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)13 SlotID (org.apache.flink.runtime.clusterframework.types.SlotID)13 Configuration (org.apache.flink.configuration.Configuration)12 BroadcastVariableManager (org.apache.flink.runtime.broadcast.BroadcastVariableManager)12 FileCache (org.apache.flink.runtime.filecache.FileCache)12 IOManager (org.apache.flink.runtime.io.disk.iomanager.IOManager)12 MemoryManager (org.apache.flink.runtime.memory.MemoryManager)12 NetworkEnvironment (org.apache.flink.runtime.io.network.NetworkEnvironment)11 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)10 UUID (java.util.UUID)9 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)9 Time (org.apache.flink.api.common.time.Time)9 JobInformation (org.apache.flink.runtime.executiongraph.JobInformation)9 TaskInformation (org.apache.flink.runtime.executiongraph.TaskInformation)9 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)9 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)9