Search in sources :

Example 31 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.

the class JobExceptionsHandlerTest method testWithLocalExceptionHistoryEntryNotHavingATaskManagerInformationAvailable.

@Test
public void testWithLocalExceptionHistoryEntryNotHavingATaskManagerInformationAvailable() throws HandlerRequestException {
    final RootExceptionHistoryEntry failure = new RootExceptionHistoryEntry(new RuntimeException("exception #1"), System.currentTimeMillis(), "task name", null, Collections.emptySet());
    final ExecutionGraphInfo executionGraphInfo = createExecutionGraphInfo(failure);
    final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
    final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
    assertThat(response.getExceptionHistory().getEntries(), contains(historyContainsJobExceptionInfo(failure.getException(), failure.getTimestamp(), failure.getFailingTaskName(), JobExceptionsHandler.toString(failure.getTaskManagerLocation()))));
}
Also used : RootExceptionHistoryEntry(org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) JobExceptionsInfoWithHistory(org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory) Test(org.junit.Test)

Example 32 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.

the class DefaultExecutionGraphCacheTest method testConcurrentAccess.

/**
 * Tests that concurrent accesses only trigger a single AccessExecutionGraph request.
 */
@Test
public void testConcurrentAccess() throws Exception {
    final Time timeout = Time.milliseconds(100L);
    final Time timeToLive = Time.hours(1L);
    final CountingRestfulGateway restfulGateway = createCountingRestfulGateway(expectedJobId, CompletableFuture.completedFuture(expectedExecutionGraphInfo));
    final int numConcurrentAccesses = 10;
    final ArrayList<CompletableFuture<ExecutionGraphInfo>> executionGraphFutures = new ArrayList<>(numConcurrentAccesses);
    final ExecutorService executor = java.util.concurrent.Executors.newFixedThreadPool(numConcurrentAccesses);
    try (ExecutionGraphCache executionGraphCache = new DefaultExecutionGraphCache(timeout, timeToLive)) {
        for (int i = 0; i < numConcurrentAccesses; i++) {
            CompletableFuture<ExecutionGraphInfo> executionGraphFuture = CompletableFuture.supplyAsync(() -> executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway), executor).thenCompose(Function.identity());
            executionGraphFutures.add(executionGraphFuture);
        }
        final CompletableFuture<Collection<ExecutionGraphInfo>> allExecutionGraphFutures = FutureUtils.combineAll(executionGraphFutures);
        Collection<ExecutionGraphInfo> allExecutionGraphs = allExecutionGraphFutures.get();
        for (ExecutionGraphInfo executionGraph : allExecutionGraphs) {
            assertEquals(expectedExecutionGraphInfo, executionGraph);
        }
        assertThat(restfulGateway.getNumRequestJobCalls(), Matchers.equalTo(1));
    } finally {
        ExecutorUtils.gracefulShutdown(5000L, TimeUnit.MILLISECONDS, executor);
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArrayList(java.util.ArrayList) Time(org.apache.flink.api.common.time.Time) CompletableFuture(java.util.concurrent.CompletableFuture) ExecutorService(java.util.concurrent.ExecutorService) Collection(java.util.Collection) Test(org.junit.Test)

Example 33 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.

the class DefaultExecutionGraphCacheTest method testExecutionGraphCaching.

/**
 * Tests that we can cache AccessExecutionGraphs over multiple accesses.
 */
@Test
public void testExecutionGraphCaching() throws Exception {
    final Time timeout = Time.milliseconds(100L);
    final Time timeToLive = Time.hours(1L);
    final CountingRestfulGateway restfulGateway = createCountingRestfulGateway(expectedJobId, CompletableFuture.completedFuture(expectedExecutionGraphInfo));
    try (ExecutionGraphCache executionGraphCache = new DefaultExecutionGraphCache(timeout, timeToLive)) {
        CompletableFuture<ExecutionGraphInfo> executionGraphInfoFuture = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
        assertEquals(expectedExecutionGraphInfo, executionGraphInfoFuture.get());
        executionGraphInfoFuture = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
        assertEquals(expectedExecutionGraphInfo, executionGraphInfoFuture.get());
        assertThat(restfulGateway.getNumRequestJobCalls(), Matchers.equalTo(1));
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) Time(org.apache.flink.api.common.time.Time) Test(org.junit.Test)

Example 34 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.

the class DefaultExecutionGraphCacheTest method testExecutionGraphEntryInvalidation.

/**
 * Tests that an AccessExecutionGraph is invalidated after its TTL expired.
 */
@Test
public void testExecutionGraphEntryInvalidation() throws Exception {
    final Time timeout = Time.milliseconds(100L);
    final Time timeToLive = Time.milliseconds(1L);
    final CountingRestfulGateway restfulGateway = createCountingRestfulGateway(expectedJobId, CompletableFuture.completedFuture(expectedExecutionGraphInfo), CompletableFuture.completedFuture(expectedExecutionGraphInfo));
    try (ExecutionGraphCache executionGraphCache = new DefaultExecutionGraphCache(timeout, timeToLive)) {
        CompletableFuture<ExecutionGraphInfo> executionGraphInfoFuture = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
        assertEquals(expectedExecutionGraphInfo, executionGraphInfoFuture.get());
        // sleep for the TTL
        Thread.sleep(timeToLive.toMilliseconds() * 5L);
        CompletableFuture<ExecutionGraphInfo> executionGraphInfoFuture2 = executionGraphCache.getExecutionGraphInfo(expectedJobId, restfulGateway);
        assertEquals(expectedExecutionGraphInfo, executionGraphInfoFuture2.get());
        assertThat(restfulGateway.getNumRequestJobCalls(), Matchers.equalTo(2));
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) Time(org.apache.flink.api.common.time.Time) Test(org.junit.Test)

Example 35 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.

the class Dispatcher method submitFailedJob.

@Override
public CompletableFuture<Acknowledge> submitFailedJob(JobID jobId, String jobName, Throwable exception) {
    final ArchivedExecutionGraph archivedExecutionGraph = ArchivedExecutionGraph.createSparseArchivedExecutionGraph(jobId, jobName, JobStatus.FAILED, exception, null, System.currentTimeMillis());
    archiveExecutionGraph(new ExecutionGraphInfo(archivedExecutionGraph));
    return CompletableFuture.completedFuture(Acknowledge.get());
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)

Aggregations

ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)45 Test (org.junit.Test)33 ArchivedExecutionGraphBuilder (org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)23 Time (org.apache.flink.api.common.time.Time)12 CompletableFuture (java.util.concurrent.CompletableFuture)11 JobID (org.apache.flink.api.common.JobID)11 JobStatus (org.apache.flink.api.common.JobStatus)9 FlinkException (org.apache.flink.util.FlinkException)8 File (java.io.File)7 TestingJobManagerRunner (org.apache.flink.runtime.jobmaster.TestingJobManagerRunner)7 ArrayList (java.util.ArrayList)6 ArchivedExecutionGraph (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)6 FlinkJobNotFoundException (org.apache.flink.runtime.messages.FlinkJobNotFoundException)6 EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)6 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)5 JobManagerRunner (org.apache.flink.runtime.jobmaster.JobManagerRunner)5 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)5 JobExceptionsInfoWithHistory (org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory)5 RootExceptionHistoryEntry (org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry)5 ExceptionUtils (org.apache.flink.util.ExceptionUtils)5