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