use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.
the class JobExceptionsHandlerTest method testWithExceptionHistoryWithTruncationThroughParameter.
@Test
public void testWithExceptionHistoryWithTruncationThroughParameter() throws HandlerRequestException {
final RootExceptionHistoryEntry rootCause = fromGlobalFailure(new RuntimeException("exception #0"), System.currentTimeMillis());
final RootExceptionHistoryEntry otherFailure = new RootExceptionHistoryEntry(new RuntimeException("exception #1"), System.currentTimeMillis(), "task name", new LocalTaskManagerLocation(), Collections.emptySet());
final ExecutionGraphInfo executionGraphInfo = createExecutionGraphInfo(rootCause, otherFailure);
final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 1);
final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
assertThat(response.getExceptionHistory().getEntries(), contains(historyContainsGlobalFailure(rootCause.getException(), rootCause.getTimestamp())));
assertThat(response.getExceptionHistory().getEntries(), iterableWithSize(1));
assertTrue(response.getExceptionHistory().isTruncated());
}
use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.
the class JobExceptionsHandlerTest method testArchivedTaskManagerLocationHandling.
@Test
public void testArchivedTaskManagerLocationHandling() {
final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
assertThat(JobExceptionsHandler.toString(taskManagerLocation), is(String.format("%s:%s", taskManagerLocation.getFQDNHostname(), taskManagerLocation.dataPort())));
}
use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.
the class SubtaskCurrentAttemptDetailsHandlerTest method testHandleRequest.
@Test
public void testHandleRequest() throws Exception {
// Prepare the execution graph.
final JobID jobID = new JobID();
final JobVertexID jobVertexID = new JobVertexID();
// The testing subtask.
final long deployingTs = System.currentTimeMillis() - 1024;
final long finishedTs = System.currentTimeMillis();
final long bytesIn = 1L;
final long bytesOut = 10L;
final long recordsIn = 20L;
final long recordsOut = 30L;
final IOMetrics ioMetrics = new IOMetrics(bytesIn, bytesOut, recordsIn, recordsOut);
final long[] timestamps = new long[ExecutionState.values().length];
timestamps[ExecutionState.DEPLOYING.ordinal()] = deployingTs;
final ExecutionState expectedState = ExecutionState.FINISHED;
timestamps[expectedState.ordinal()] = finishedTs;
final LocalTaskManagerLocation assignedResourceLocation = new LocalTaskManagerLocation();
final AllocationID allocationID = new AllocationID();
final int subtaskIndex = 1;
final int attempt = 2;
final ArchivedExecution execution = new ArchivedExecution(new StringifiedAccumulatorResult[0], ioMetrics, new ExecutionAttemptID(), attempt, expectedState, null, assignedResourceLocation, allocationID, subtaskIndex, timestamps);
final ArchivedExecutionVertex executionVertex = new ArchivedExecutionVertex(subtaskIndex, "Test archived execution vertex", execution, new EvictingBoundedList<>(0));
// Instance the handler.
final RestHandlerConfiguration restHandlerConfiguration = RestHandlerConfiguration.fromConfiguration(new Configuration());
final MetricFetcher metricFetcher = new MetricFetcherImpl<>(() -> null, address -> null, TestingUtils.defaultExecutor(), Time.milliseconds(1000L), MetricOptions.METRIC_FETCHER_UPDATE_INTERVAL.defaultValue());
final SubtaskCurrentAttemptDetailsHandler handler = new SubtaskCurrentAttemptDetailsHandler(() -> null, Time.milliseconds(100), Collections.emptyMap(), SubtaskCurrentAttemptDetailsHeaders.getInstance(), new DefaultExecutionGraphCache(restHandlerConfiguration.getTimeout(), Time.milliseconds(restHandlerConfiguration.getRefreshInterval())), TestingUtils.defaultExecutor(), metricFetcher);
final HashMap<String, String> receivedPathParameters = new HashMap<>(2);
receivedPathParameters.put(JobIDPathParameter.KEY, jobID.toString());
receivedPathParameters.put(JobVertexIdPathParameter.KEY, jobVertexID.toString());
final HandlerRequest<EmptyRequestBody> request = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), new SubtaskMessageParameters(), receivedPathParameters, Collections.emptyMap(), Collections.emptyList());
// Handle request.
final SubtaskExecutionAttemptDetailsInfo detailsInfo = handler.handleRequest(request, executionVertex);
// Verify
final IOMetricsInfo ioMetricsInfo = new IOMetricsInfo(bytesIn, true, bytesOut, true, recordsIn, true, recordsOut, true);
final SubtaskExecutionAttemptDetailsInfo expectedDetailsInfo = new SubtaskExecutionAttemptDetailsInfo(subtaskIndex, expectedState, attempt, assignedResourceLocation.getHostname(), deployingTs, finishedTs, finishedTs - deployingTs, ioMetricsInfo, assignedResourceLocation.getResourceID().getResourceIdString());
assertEquals(expectedDetailsInfo, detailsInfo);
}
use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.
the class DeclarativeSlotPoolBridgeRequestCompletionTest method runSlotRequestCompletionTest.
private void runSlotRequestCompletionTest(Supplier<SlotPool> slotPoolSupplier, Consumer<SlotPool> actionAfterSlotRequest) {
try (final SlotPool slotPool = slotPoolSupplier.get()) {
final int requestNum = 10;
final List<SlotRequestId> slotRequestIds = IntStream.range(0, requestNum).mapToObj(ignored -> new SlotRequestId()).collect(Collectors.toList());
final List<CompletableFuture<PhysicalSlot>> slotRequests = slotRequestIds.stream().map(slotRequestId -> slotPool.requestNewAllocatedSlot(slotRequestId, ResourceProfile.UNKNOWN, TIMEOUT)).collect(Collectors.toList());
actionAfterSlotRequest.accept(slotPool);
final LocalTaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
slotPool.registerTaskManager(taskManagerLocation.getResourceID());
// create a slot offer that is initiated by the last request
final SlotOffer slotOffer = new SlotOffer(new AllocationID(), 0, ResourceProfile.ANY);
final Collection<SlotOffer> acceptedSlots = slotPool.offerSlots(taskManagerLocation, new SimpleAckingTaskManagerGateway(), Collections.singleton(slotOffer));
assertThat(acceptedSlots, containsInAnyOrder(slotOffer));
final FlinkException testingReleaseException = new FlinkException("Testing release exception");
// check that the slot requests get completed in sequential order
for (int i = 0; i < slotRequestIds.size(); i++) {
final CompletableFuture<PhysicalSlot> slotRequestFuture = slotRequests.get(i);
assertThat(slotRequestFuture.getNow(null), is(not(nullValue())));
slotPool.releaseSlot(slotRequestIds.get(i), testingReleaseException);
}
}
}
use of org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation in project flink by apache.
the class DeclarativeSlotPoolBridgeTest method testAcceptingOfferedSlotsWithoutResourceManagerConnected.
@Test
public void testAcceptingOfferedSlotsWithoutResourceManagerConnected() throws Exception {
try (DeclarativeSlotPoolBridge declarativeSlotPoolBridge = createDeclarativeSlotPoolBridge(new DefaultDeclarativeSlotPoolFactory(), requestSlotMatchingStrategy)) {
declarativeSlotPoolBridge.start(jobMasterId, "localhost", mainThreadExecutor);
final CompletableFuture<PhysicalSlot> slotFuture = declarativeSlotPoolBridge.requestNewAllocatedSlot(new SlotRequestId(), ResourceProfile.UNKNOWN, rpcTimeout);
final LocalTaskManagerLocation localTaskManagerLocation = new LocalTaskManagerLocation();
declarativeSlotPoolBridge.registerTaskManager(localTaskManagerLocation.getResourceID());
final AllocationID allocationId = new AllocationID();
declarativeSlotPoolBridge.offerSlots(localTaskManagerLocation, new SimpleAckingTaskManagerGateway(), Collections.singleton(new SlotOffer(allocationId, 0, ResourceProfile.ANY)));
assertThat(slotFuture.join().getAllocationId(), is(allocationId));
}
}
Aggregations