Search in sources :

Example 1 with LocalTaskManagerLocation

use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.

the class ExecutionPartitionLifecycleTest method setupExecutionGraphAndStartRunningJob.

private void setupExecutionGraphAndStartRunningJob(ResultPartitionType resultPartitionType, JobMasterPartitionTracker partitionTracker, TaskManagerGateway taskManagerGateway, ShuffleMaster<?> shuffleMaster) throws Exception {
    final JobVertex producerVertex = createNoOpJobVertex();
    final JobVertex consumerVertex = createNoOpJobVertex();
    consumerVertex.connectNewDataSetAsInput(producerVertex, DistributionPattern.ALL_TO_ALL, resultPartitionType);
    final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
    final TestingPhysicalSlotProvider physicalSlotProvider = TestingPhysicalSlotProvider.create((resourceProfile) -> CompletableFuture.completedFuture(TestingPhysicalSlot.builder().withTaskManagerGateway(taskManagerGateway).withTaskManagerLocation(taskManagerLocation).build()));
    final JobGraph jobGraph = JobGraphTestUtils.batchJobGraph(producerVertex, consumerVertex);
    final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(jobGraph, ComponentMainThreadExecutorServiceAdapter.forMainThread()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(physicalSlotProvider)).setShuffleMaster(shuffleMaster).setPartitionTracker(partitionTracker).build();
    final ExecutionGraph executionGraph = scheduler.getExecutionGraph();
    final ExecutionJobVertex executionJobVertex = executionGraph.getJobVertex(producerVertex.getID());
    final ExecutionVertex executionVertex = executionJobVertex.getTaskVertices()[0];
    execution = executionVertex.getCurrentExecutionAttempt();
    scheduler.startScheduling();
    execution.switchToRecovering();
    execution.switchToRunning();
    final IntermediateResultPartitionID expectedIntermediateResultPartitionId = executionJobVertex.getProducedDataSets()[0].getPartitions()[0].getPartitionId();
    descriptor = execution.getResultPartitionDeploymentDescriptor(expectedIntermediateResultPartitionId).get();
    taskExecutorResourceId = taskManagerLocation.getResourceID();
    jobId = executionGraph.getJobID();
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) TestingPhysicalSlotProvider(org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) IntermediateResultPartitionID(org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID)

Example 2 with LocalTaskManagerLocation

use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.

the class ExceptionHistoryEntryTest method testCreate.

@Test
public void testCreate() {
    final Throwable failure = new RuntimeException("Expected exception");
    final long timestamp = System.currentTimeMillis();
    final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
    final AccessExecution execution = TestingAccessExecution.newBuilder().withErrorInfo(new ErrorInfo(failure, timestamp)).withTaskManagerLocation(taskManagerLocation).build();
    final String taskName = "task name";
    final ExceptionHistoryEntry entry = ExceptionHistoryEntry.create(execution, taskName);
    assertThat(entry.getException().deserializeError(ClassLoader.getSystemClassLoader()), is(failure));
    assertThat(entry.getTimestamp(), is(timestamp));
    assertThat(entry.getFailingTaskName(), is(taskName));
    assertThat(entry.getTaskManagerLocation(), isArchivedTaskManagerLocation(taskManagerLocation));
    assertThat(entry.isGlobal(), is(false));
}
Also used : AccessExecution(org.apache.flink.runtime.executiongraph.AccessExecution) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) ArchivedTaskManagerLocationMatcher.isArchivedTaskManagerLocation(org.apache.flink.runtime.scheduler.exceptionhistory.ArchivedTaskManagerLocationMatcher.isArchivedTaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) Test(org.junit.Test)

Example 3 with LocalTaskManagerLocation

use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.

the class DeclarativeSlotPoolServiceTest method testSlotOfferingOfKnownTaskManager.

@Test
public void testSlotOfferingOfKnownTaskManager() throws Exception {
    final AtomicReference<Collection<? extends SlotOffer>> receivedSlotOffers = new AtomicReference<>();
    try (DeclarativeSlotPoolService declarativeSlotPoolService = createDeclarativeSlotPoolService(new TestingDeclarativeSlotPoolFactory(new TestingDeclarativeSlotPoolBuilder().setOfferSlotsFunction((slotOffers, taskManagerLocation, taskManagerGateway, aLong) -> {
        receivedSlotOffers.set(slotOffers);
        return new ArrayList<>(slotOffers);
    })))) {
        final LocalTaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
        declarativeSlotPoolService.registerTaskManager(taskManagerLocation.getResourceID());
        final Collection<SlotOffer> slotOffers = Collections.singletonList(new SlotOffer(new AllocationID(), 0, ResourceProfile.UNKNOWN));
        declarativeSlotPoolService.offerSlots(taskManagerLocation, new RpcTaskManagerGateway(new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway(), jobMasterId), slotOffers);
        assertThat(receivedSlotOffers.get(), is(slotOffers));
    }
}
Also used : SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) RpcTaskManagerGateway(org.apache.flink.runtime.jobmaster.RpcTaskManagerGateway) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) ArrayList(java.util.ArrayList) AtomicReference(java.util.concurrent.atomic.AtomicReference) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) Collection(java.util.Collection) Test(org.junit.Test)

Example 4 with LocalTaskManagerLocation

use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.

the class DeclarativeSlotPoolServiceTest method testCreateAllocatedSlotReport.

@Test
public void testCreateAllocatedSlotReport() throws Exception {
    final LocalTaskManagerLocation taskManagerLocation1 = new LocalTaskManagerLocation();
    final LocalTaskManagerLocation taskManagerLocation2 = new LocalTaskManagerLocation();
    final SimpleSlotContext simpleSlotContext2 = createSimpleSlotContext(taskManagerLocation2);
    final Collection<SlotInfo> slotInfos = Arrays.asList(createSimpleSlotContext(taskManagerLocation1), simpleSlotContext2);
    try (DeclarativeSlotPoolService declarativeSlotPoolService = createDeclarativeSlotPoolService(new TestingDeclarativeSlotPoolFactory(new TestingDeclarativeSlotPoolBuilder().setGetAllSlotsInformationSupplier(() -> slotInfos)))) {
        final AllocatedSlotReport allocatedSlotReport = declarativeSlotPoolService.createAllocatedSlotReport(taskManagerLocation2.getResourceID());
        assertThat(allocatedSlotReport.getAllocatedSlotInfos(), contains(matchesWithSlotContext(simpleSlotContext2)));
    }
}
Also used : SimpleSlotContext(org.apache.flink.runtime.instance.SimpleSlotContext) AllocatedSlotReport(org.apache.flink.runtime.jobmaster.AllocatedSlotReport) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) SlotInfo(org.apache.flink.runtime.jobmaster.SlotInfo) AllocatedSlotInfo(org.apache.flink.runtime.jobmaster.AllocatedSlotInfo) Test(org.junit.Test)

Example 5 with LocalTaskManagerLocation

use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.

the class DeclarativeSlotPoolServiceTest method testSlotOfferingOfUnknownTaskManagerIsIgnored.

@Test
public void testSlotOfferingOfUnknownTaskManagerIsIgnored() throws Exception {
    try (DeclarativeSlotPoolService declarativeSlotPoolService = createDeclarativeSlotPoolService()) {
        final Collection<SlotOffer> slotOffers = Collections.singletonList(new SlotOffer(new AllocationID(), 0, ResourceProfile.UNKNOWN));
        final LocalTaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
        final Collection<SlotOffer> acceptedSlots = declarativeSlotPoolService.offerSlots(taskManagerLocation, new RpcTaskManagerGateway(new TestingTaskExecutorGatewayBuilder().createTestingTaskExecutorGateway(), jobMasterId), slotOffers);
        assertThat(acceptedSlots, is(empty()));
    }
}
Also used : SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) RpcTaskManagerGateway(org.apache.flink.runtime.jobmaster.RpcTaskManagerGateway) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder) Test(org.junit.Test)

Aggregations

LocalTaskManagerLocation (org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation)30 Test (org.junit.Test)24 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)13 SlotOffer (org.apache.flink.runtime.taskexecutor.slot.SlotOffer)12 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)9 TestingTaskExecutorGatewayBuilder (org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder)8 ResourceCounter (org.apache.flink.runtime.util.ResourceCounter)7 SimpleAckingTaskManagerGateway (org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway)6 CompletableFuture (java.util.concurrent.CompletableFuture)5 ArchivedExecutionVertex (org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex)5 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)5 RootExceptionHistoryEntry (org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry)5 TestingTaskExecutorGateway (org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGateway)5 FlinkException (org.apache.flink.util.FlinkException)5 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)4 JobID (org.apache.flink.api.common.JobID)4 Time (org.apache.flink.api.common.time.Time)4 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)4 List (java.util.List)3