Search in sources :

Example 31 with DirectScheduledExecutorService

use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by splunk.

the class DefaultExecutionGraphDeploymentTest method setupScheduler.

private SchedulerBase setupScheduler(JobVertex v1, int dop1, JobVertex v2, int dop2) throws Exception {
    v1.setParallelism(dop1);
    v2.setParallelism(dop2);
    v1.setInvokableClass(BatchTask.class);
    v2.setInvokableClass(BatchTask.class);
    DirectScheduledExecutorService executorService = new DirectScheduledExecutorService();
    // execution graph that executes actions synchronously
    final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(JobGraphTestUtils.streamingJobGraph(v1, v2), ComponentMainThreadExecutorServiceAdapter.forMainThread()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory()).setFutureExecutor(executorService).setBlobWriter(blobWriter).build();
    final ExecutionGraph eg = scheduler.getExecutionGraph();
    checkJobOffloaded((DefaultExecutionGraph) eg);
    // schedule, this triggers mock deployment
    scheduler.startScheduling();
    Map<ExecutionAttemptID, Execution> executions = eg.getRegisteredExecutions();
    assertEquals(dop1 + dop2, executions.size());
    return scheduler;
}
Also used : DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase)

Example 32 with DirectScheduledExecutorService

use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by splunk.

the class DefaultExecutionGraphDeploymentWithSmallBlobCacheSizeLimitTest method createAndSetupExecutionGraph.

private ExecutionGraph createAndSetupExecutionGraph(int numberOfVertices, int parallelism) throws JobException, JobExecutionException {
    final List<JobVertex> vertices = new ArrayList<>();
    for (int i = 0; i < numberOfVertices; i++) {
        JobVertex vertex = new JobVertex(String.format("v%d", i + 1), new JobVertexID());
        vertex.setParallelism(parallelism);
        vertex.setInvokableClass(BatchTask.class);
        vertices.add(vertex);
    }
    for (int i = 1; i < numberOfVertices; i++) {
        vertices.get(i).connectNewDataSetAsInput(vertices.get(i - 1), DistributionPattern.POINTWISE, ResultPartitionType.BLOCKING);
    }
    final JobGraph jobGraph = JobGraphTestUtils.batchJobGraph(vertices.toArray(new JobVertex[0]));
    final DirectScheduledExecutorService executor = new DirectScheduledExecutorService();
    final DefaultExecutionGraph eg = TestingDefaultExecutionGraphBuilder.newBuilder().setJobGraph(jobGraph).setFutureExecutor(executor).setIoExecutor(executor).setBlobWriter(blobWriter).build();
    eg.start(ComponentMainThreadExecutorServiceAdapter.forMainThread());
    return eg;
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) ArrayList(java.util.ArrayList)

Example 33 with DirectScheduledExecutorService

use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by splunk.

the class RetryingExecutorTest method testNoRetryDelayIfTimeout.

@Test
public void testNoRetryDelayIfTimeout() throws Exception {
    int delayAfterFailure = 123;
    int numAttempts = 2;
    testPolicy(numAttempts, RetryPolicy.fixed(Integer.MAX_VALUE, 0, delayAfterFailure), a -> {
        if (a < numAttempts) {
            throw new TimeoutException();
        }
    }, new DirectScheduledExecutorService() {

        @Override
        public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
            fail("task should be executed directly without delay after timeout");
            return CompletedScheduledFuture.create(null);
        }
    });
}
Also used : DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) TimeUnit(java.util.concurrent.TimeUnit) ScheduledFuture(java.util.concurrent.ScheduledFuture) CompletedScheduledFuture(org.apache.flink.core.testutils.CompletedScheduledFuture) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 34 with DirectScheduledExecutorService

use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by splunk.

the class BatchingStateChangeUploadSchedulerTest method testClose.

@Test
public void testClose() throws Exception {
    TestingStateChangeUploader probe = new TestingStateChangeUploader();
    DirectScheduledExecutorService scheduler = new DirectScheduledExecutorService();
    DirectScheduledExecutorService retryScheduler = new DirectScheduledExecutorService();
    new BatchingStateChangeUploadScheduler(0, 0, MAX_BYTES_IN_FLIGHT, RetryPolicy.NONE, probe, scheduler, new RetryingExecutor(retryScheduler, createUnregisteredChangelogStorageMetricGroup().getAttemptsPerUpload()), createUnregisteredChangelogStorageMetricGroup()).close();
    assertTrue(probe.isClosed());
    assertTrue(scheduler.isShutdown());
    assertTrue(retryScheduler.isShutdown());
}
Also used : DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) Test(org.junit.Test)

Example 35 with DirectScheduledExecutorService

use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by splunk.

the class DefaultSchedulerTest method setUp.

@Before
public void setUp() throws Exception {
    executor = Executors.newSingleThreadExecutor();
    scheduledExecutorService = new DirectScheduledExecutorService();
    configuration = new Configuration();
    testRestartBackoffTimeStrategy = new TestRestartBackoffTimeStrategy(true, 0);
    testExecutionVertexOperations = new TestExecutionVertexOperationsDecorator(new DefaultExecutionVertexOperations());
    executionVertexVersioner = new ExecutionVertexVersioner();
    executionSlotAllocatorFactory = new TestExecutionSlotAllocatorFactory();
    testExecutionSlotAllocator = executionSlotAllocatorFactory.getTestExecutionSlotAllocator();
    shuffleMaster = new TestingShuffleMaster();
    partitionTracker = new TestingJobMasterPartitionTracker();
    timeout = Time.seconds(60);
}
Also used : Configuration(org.apache.flink.configuration.Configuration) TestRestartBackoffTimeStrategy(org.apache.flink.runtime.executiongraph.failover.flip1.TestRestartBackoffTimeStrategy) DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) TestingJobMasterPartitionTracker(org.apache.flink.runtime.io.network.partition.TestingJobMasterPartitionTracker) TestingShuffleMaster(org.apache.flink.runtime.shuffle.TestingShuffleMaster) Before(org.junit.Before)

Aggregations

DirectScheduledExecutorService (org.apache.flink.runtime.testutils.DirectScheduledExecutorService)46 Test (org.junit.Test)32 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)17 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)15 SchedulerBase (org.apache.flink.runtime.scheduler.SchedulerBase)15 ArrayList (java.util.ArrayList)14 CompletableFuture (java.util.concurrent.CompletableFuture)10 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)10 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)9 Configuration (org.apache.flink.configuration.Configuration)8 IOException (java.io.IOException)7 Arrays (java.util.Arrays)7 Collection (java.util.Collection)7 List (java.util.List)7 TaskExecutionState (org.apache.flink.runtime.taskmanager.TaskExecutionState)7 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)6 RpcTaskManagerGateway (org.apache.flink.runtime.jobmaster.RpcTaskManagerGateway)6 TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)6 TestingPhysicalSlotProvider (org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider)6 TestingTaskExecutorGateway (org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGateway)6