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();
}
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));
}
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));
}
}
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)));
}
}
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()));
}
}
Aggregations