Search in sources :

Example 21 with LocalTaskManagerLocation

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());
}
Also used : RootExceptionHistoryEntry(org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) JobExceptionsInfoWithHistory(org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory) Test(org.junit.Test)

Example 22 with LocalTaskManagerLocation

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())));
}
Also used : TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) Test(org.junit.Test)

Example 23 with LocalTaskManagerLocation

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);
}
Also used : ExecutionState(org.apache.flink.runtime.execution.ExecutionState) Configuration(org.apache.flink.configuration.Configuration) RestHandlerConfiguration(org.apache.flink.runtime.rest.handler.RestHandlerConfiguration) HashMap(java.util.HashMap) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ArchivedExecution(org.apache.flink.runtime.executiongraph.ArchivedExecution) IOMetrics(org.apache.flink.runtime.executiongraph.IOMetrics) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) DefaultExecutionGraphCache(org.apache.flink.runtime.rest.handler.legacy.DefaultExecutionGraphCache) IOMetricsInfo(org.apache.flink.runtime.rest.messages.job.metrics.IOMetricsInfo) MetricFetcherImpl(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcherImpl) SubtaskExecutionAttemptDetailsInfo(org.apache.flink.runtime.rest.messages.job.SubtaskExecutionAttemptDetailsInfo) RestHandlerConfiguration(org.apache.flink.runtime.rest.handler.RestHandlerConfiguration) ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) ArchivedExecutionVertex(org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) MetricFetcher(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher) SubtaskMessageParameters(org.apache.flink.runtime.rest.messages.job.SubtaskMessageParameters) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 24 with LocalTaskManagerLocation

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);
        }
    }
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) ComponentMainThreadExecutorServiceAdapter(org.apache.flink.runtime.concurrent.ComponentMainThreadExecutorServiceAdapter) IntStream(java.util.stream.IntStream) FlinkException(org.apache.flink.util.FlinkException) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) Matchers.not(org.hamcrest.Matchers.not) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) Matchers.nullValue(org.hamcrest.Matchers.nullValue) TestLogger(org.apache.flink.util.TestLogger) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) CheckedSupplier(org.apache.flink.util.function.CheckedSupplier) Before(org.junit.Before) Collection(java.util.Collection) Test(org.junit.Test) Collectors(java.util.stream.Collectors) SimpleAckingTaskManagerGateway(org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway) ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) Consumer(java.util.function.Consumer) TestingResourceManagerGateway(org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway) List(java.util.List) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.is(org.hamcrest.Matchers.is) Collections(java.util.Collections) Time(org.apache.flink.api.common.time.Time) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) FlinkException(org.apache.flink.util.FlinkException) SimpleAckingTaskManagerGateway(org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway) CompletableFuture(java.util.concurrent.CompletableFuture) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation)

Example 25 with LocalTaskManagerLocation

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));
    }
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) SimpleAckingTaskManagerGateway(org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway) SlotOffer(org.apache.flink.runtime.taskexecutor.slot.SlotOffer) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) 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