Search in sources :

Example 31 with LogicalSlot

use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.

the class Execution method notifyCheckpointOnComplete.

/**
 * Notify the task of this execution about a completed checkpoint and the last subsumed
 * checkpoint id if possible.
 *
 * @param completedCheckpointId of the completed checkpoint
 * @param completedTimestamp of the completed checkpoint
 * @param lastSubsumedCheckpointId of the last subsumed checkpoint, a value of {@link
 *     org.apache.flink.runtime.checkpoint.CheckpointStoreUtil#INVALID_CHECKPOINT_ID} means no
 *     checkpoint has been subsumed.
 */
public void notifyCheckpointOnComplete(long completedCheckpointId, long completedTimestamp, long lastSubsumedCheckpointId) {
    final LogicalSlot slot = assignedResource;
    if (slot != null) {
        final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
        taskManagerGateway.notifyCheckpointOnComplete(attemptId, getVertex().getJobId(), completedCheckpointId, completedTimestamp, lastSubsumedCheckpointId);
    } else {
        LOG.debug("The execution has no slot assigned. This indicates that the execution is " + "no longer running.");
    }
}
Also used : TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot)

Example 32 with LogicalSlot

use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.

the class SharedSlot method release.

@Override
public void release(Throwable cause) {
    LOG.debug("Release shared slot ({})", physicalSlotRequestId);
    Preconditions.checkState(state == State.ALLOCATED, "The shared slot has already been released.");
    // ensures that we won't call the external release callback if there are still logical slots
    // to release
    state = State.RELEASING;
    // copy the logical slot collection to avoid ConcurrentModificationException
    // if logical slot releases cause cancellation of other executions
    // which will try to call returnLogicalSlot and modify allocatedLogicalSlots collection
    final List<LogicalSlot> logicalSlotsToRelease = new ArrayList<>(allocatedLogicalSlots.values());
    for (LogicalSlot allocatedLogicalSlot : logicalSlotsToRelease) {
        // this will also cause the logical slot to be returned
        allocatedLogicalSlot.releaseSlot(cause);
    }
    allocatedLogicalSlots.clear();
    state = State.RELEASED;
}
Also used : ArrayList(java.util.ArrayList) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) SingleLogicalSlot(org.apache.flink.runtime.jobmaster.slotpool.SingleLogicalSlot)

Example 33 with LogicalSlot

use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.

the class SlotSharingSlotAllocator method tryReserveResources.

@Override
public Optional<ReservedSlots> tryReserveResources(VertexParallelism vertexParallelism) {
    Preconditions.checkArgument(vertexParallelism instanceof VertexParallelismWithSlotSharing, String.format("%s expects %s as argument.", SlotSharingSlotAllocator.class.getSimpleName(), VertexParallelismWithSlotSharing.class.getSimpleName()));
    final VertexParallelismWithSlotSharing vertexParallelismWithSlotSharing = (VertexParallelismWithSlotSharing) vertexParallelism;
    final Collection<AllocationID> expectedSlots = calculateExpectedSlots(vertexParallelismWithSlotSharing.getAssignments());
    if (areAllExpectedSlotsAvailableAndFree(expectedSlots)) {
        final Map<ExecutionVertexID, LogicalSlot> assignedSlots = new HashMap<>();
        for (ExecutionSlotSharingGroupAndSlot executionSlotSharingGroup : vertexParallelismWithSlotSharing.getAssignments()) {
            final SharedSlot sharedSlot = reserveSharedSlot(executionSlotSharingGroup.getSlotInfo());
            for (ExecutionVertexID executionVertexId : executionSlotSharingGroup.getExecutionSlotSharingGroup().getContainedExecutionVertices()) {
                final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
                assignedSlots.put(executionVertexId, logicalSlot);
            }
        }
        return Optional.of(ReservedSlots.create(assignedSlots));
    } else {
        return Optional.empty();
    }
}
Also used : HashMap(java.util.HashMap) ExecutionVertexID(org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot)

Example 34 with LogicalSlot

use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.

the class DefaultExecutionGraphDeploymentWithSmallBlobCacheSizeLimitTest method testDeployMultipleTasksWithSmallBlobCacheSizeLimit.

/**
 * Test the deployment works well even the size limit of {@link BlobCacheSizeTracker} in {@link
 * PermanentBlobCache} is set to the minimum value.
 *
 * <p>In this extreme case, since the size limit is 1, every time a task is deployed, all the
 * existing **tracked** BLOBs on the cache must be untracked and deleted before the new BLOB is
 * stored onto the cache.
 *
 * <p>This extreme case covers the situation of the normal case, where the size limit is much
 * larger than 1 and the deletion won't happen so frequently.
 */
@Test
public void testDeployMultipleTasksWithSmallBlobCacheSizeLimit() throws Exception {
    final int numberOfVertices = 4;
    final int parallelism = 10;
    final ExecutionGraph eg = createAndSetupExecutionGraph(numberOfVertices, parallelism);
    final SimpleAckingTaskManagerGateway taskManagerGateway = new SimpleAckingTaskManagerGateway();
    final BlockingQueue<TaskDeploymentDescriptor> tdds = new ArrayBlockingQueue<>(numberOfVertices * parallelism);
    taskManagerGateway.setSubmitConsumer(FunctionUtils.uncheckedConsumer(taskDeploymentDescriptor -> {
        taskDeploymentDescriptor.loadBigData(blobCache);
        tdds.offer(taskDeploymentDescriptor);
    }));
    for (ExecutionJobVertex ejv : eg.getVerticesTopologically()) {
        for (ExecutionVertex ev : ejv.getTaskVertices()) {
            assertEquals(ExecutionState.CREATED, ev.getExecutionState());
            LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(taskManagerGateway).createTestingLogicalSlot();
            final Execution execution = ev.getCurrentExecutionAttempt();
            execution.transitionState(ExecutionState.SCHEDULED);
            execution.registerProducedPartitions(slot.getTaskManagerLocation(), true).get();
            ev.deployToSlot(slot);
            assertEquals(ExecutionState.DEPLOYING, ev.getExecutionState());
            TaskDeploymentDescriptor tdd = tdds.take();
            assertNotNull(tdd);
            List<InputGateDeploymentDescriptor> igdds = tdd.getInputGates();
            assertEquals(ev.getAllConsumedPartitionGroups().size(), igdds.size());
            if (igdds.size() > 0) {
                checkShuffleDescriptors(igdds.get(0), ev.getConsumedPartitionGroup(0));
            }
        }
    }
}
Also used : ComponentMainThreadExecutorServiceAdapter(org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID) BlobServer(org.apache.flink.runtime.blob.BlobServer) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) BlobCacheSizeTracker(org.apache.flink.runtime.blob.BlobCacheSizeTracker) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ResultPartitionType(org.apache.flink.runtime.io.network.partition.ResultPartitionType) TaskDeploymentDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor) ArrayList(java.util.ArrayList) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) JobException(org.apache.flink.runtime.JobException) FunctionUtils(org.apache.flink.util.function.FunctionUtils) JobGraphTestUtils(org.apache.flink.runtime.jobgraph.JobGraphTestUtils) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) DistributionPattern(org.apache.flink.runtime.jobgraph.DistributionPattern) Before(org.junit.Before) BlobServerOptions(org.apache.flink.configuration.BlobServerOptions) VoidBlobStore(org.apache.flink.runtime.blob.VoidBlobStore) Assert.assertNotNull(org.junit.Assert.assertNotNull) Configuration(org.apache.flink.configuration.Configuration) ExecutionState(org.apache.flink.runtime.execution.ExecutionState) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test) IOException(java.io.IOException) BlockingQueue(java.util.concurrent.BlockingQueue) InetSocketAddress(java.net.InetSocketAddress) SimpleAckingTaskManagerGateway(org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) List(java.util.List) ConsumedPartitionGroup(org.apache.flink.runtime.scheduler.strategy.ConsumedPartitionGroup) PermanentBlobCache(org.apache.flink.runtime.blob.PermanentBlobCache) BatchTask(org.apache.flink.runtime.operators.BatchTask) InputGateDeploymentDescriptor(org.apache.flink.runtime.deployment.InputGateDeploymentDescriptor) Assert.assertEquals(org.junit.Assert.assertEquals) InputGateDeploymentDescriptor(org.apache.flink.runtime.deployment.InputGateDeploymentDescriptor) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) SimpleAckingTaskManagerGateway(org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) TaskDeploymentDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) Test(org.junit.Test)

Example 35 with LogicalSlot

use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.

the class ExecutionVertexDeploymentTest method testDeployFailedSynchronous.

@Test
public void testDeployFailedSynchronous() {
    try {
        final ExecutionVertex vertex = getExecutionVertex();
        final LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new SubmitFailingSimpleAckingTaskManagerGateway()).createTestingLogicalSlot();
        assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
        vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
        vertex.deployToSlot(slot);
        assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
        assertTrue(vertex.getFailureInfo().isPresent());
        assertThat(vertex.getFailureInfo().map(ErrorInfo::getExceptionAsString).get(), containsString(ERROR_MESSAGE));
        assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
        assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
        assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) TestingLogicalSlot(org.apache.flink.runtime.jobmaster.TestingLogicalSlot) Test(org.junit.Test)

Aggregations

LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)57 Test (org.junit.Test)34 TestingLogicalSlotBuilder (org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder)18 CompletableFuture (java.util.concurrent.CompletableFuture)13 SlotRequestId (org.apache.flink.runtime.jobmaster.SlotRequestId)13 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)9 ExecutionGraphTestUtils.getExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex)9 TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)9 ExecutionVertexID (org.apache.flink.runtime.scheduler.strategy.ExecutionVertexID)8 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)7 SimpleAckingTaskManagerGateway (org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 TaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway)6 FlinkException (org.apache.flink.util.FlinkException)6 TestLogger (org.apache.flink.util.TestLogger)6 IOException (java.io.IOException)5 List (java.util.List)5 Map (java.util.Map)5 Consumer (java.util.function.Consumer)5