use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by apache.
the class ExecutionGraphDeploymentTest method setupExecution.
private Tuple2<ExecutionGraph, Map<ExecutionAttemptID, Execution>> setupExecution(JobVertex v1, int dop1, JobVertex v2, int dop2) throws Exception {
final JobID jobId = new JobID();
v1.setParallelism(dop1);
v2.setParallelism(dop2);
v1.setInvokableClass(BatchTask.class);
v2.setInvokableClass(BatchTask.class);
Scheduler scheduler = new Scheduler(TestingUtils.defaultExecutionContext());
for (int i = 0; i < dop1 + dop2; i++) {
scheduler.newInstanceAvailable(ExecutionGraphTestUtils.getInstance(new ActorTaskManagerGateway(new ExecutionGraphTestUtils.SimpleActorGateway(TestingUtils.directExecutionContext()))));
}
// execution graph that executes actions synchronously
ExecutionGraph eg = new ExecutionGraph(new DirectScheduledExecutorService(), TestingUtils.defaultExecutor(), jobId, "some job", new Configuration(), new SerializedValue<>(new ExecutionConfig()), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), scheduler);
eg.setQueuedSchedulingAllowed(false);
List<JobVertex> ordered = Arrays.asList(v1, v2);
eg.attachJobGraph(ordered);
assertEquals(dop1 + dop2, scheduler.getNumberOfAvailableSlots());
// schedule, this triggers mock deployment
eg.scheduleForExecution();
Map<ExecutionAttemptID, Execution> executions = eg.getRegisteredExecutions();
assertEquals(dop1 + dop2, executions.size());
return new Tuple2<>(eg, executions);
}
use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by apache.
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 apache.
the class RetryingExecutorTest method testRetryDelay.
@Test
public void testRetryDelay() throws Exception {
int delayAfterFailure = 123;
int numAttempts = 2;
testPolicy(numAttempts, RetryPolicy.fixed(Integer.MAX_VALUE, 0, delayAfterFailure), a -> {
if (a < numAttempts) {
throw new IOException();
}
}, new DirectScheduledExecutorService() {
@Override
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
assertEquals(delayAfterFailure, delay);
command.run();
return CompletedScheduledFuture.create(null);
}
});
}
use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by apache.
the class BatchingStateChangeUploaderTest method testErrorHandling.
@Test(expected = RejectedExecutionException.class)
public void testErrorHandling() throws Exception {
TestingStateChangeUploader probe = new TestingStateChangeUploader();
DirectScheduledExecutorService scheduler = new DirectScheduledExecutorService();
try (BatchingStateChangeUploader store = new BatchingStateChangeUploader(Integer.MAX_VALUE, MAX_BYTES_IN_FLIGHT, MAX_BYTES_IN_FLIGHT, RetryPolicy.NONE, probe, scheduler, new RetryingExecutor(5, createUnregisteredChangelogStorageMetricGroup().getAttemptsPerUpload()), createUnregisteredChangelogStorageMetricGroup())) {
scheduler.shutdown();
upload(store, getChanges(4));
}
}
use of org.apache.flink.runtime.testutils.DirectScheduledExecutorService in project flink by apache.
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;
}
Aggregations