use of scala.concurrent.duration.FiniteDuration in project flink by apache.
the class StackTraceSampleCoordinatorITCase method testTaskClearedWhileSampling.
/**
* Tests that a cleared task is answered with a partial success response.
*/
@Test
public void testTaskClearedWhileSampling() throws Exception {
new JavaTestKit(testActorSystem) {
{
final FiniteDuration deadline = new FiniteDuration(60, TimeUnit.SECONDS);
// The JobGraph
final JobGraph jobGraph = new JobGraph();
final int parallelism = 1;
final JobVertex task = new JobVertex("Task");
task.setInvokableClass(BlockingNoOpInvokable.class);
task.setParallelism(parallelism);
jobGraph.addVertex(task);
ActorGateway jobManger = null;
ActorGateway taskManager = null;
try {
jobManger = TestingUtils.createJobManager(testActorSystem, TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), new Configuration());
final Configuration config = new Configuration();
config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, parallelism);
taskManager = TestingUtils.createTaskManager(testActorSystem, jobManger, config, true, true);
final ActorGateway jm = jobManger;
new Within(deadline) {
@Override
protected void run() {
try {
ActorGateway testActor = new AkkaActorGateway(getTestActor(), null);
int maxAttempts = 10;
int sleepTime = 100;
for (int i = 0; i < maxAttempts; i++, sleepTime *= 2) {
// Submit the job and wait until it is running
JobClient.submitJobDetached(jm, config, jobGraph, deadline, ClassLoader.getSystemClassLoader());
jm.tell(new WaitForAllVerticesToBeRunning(jobGraph.getJobID()), testActor);
expectMsgEquals(new AllVerticesRunning(jobGraph.getJobID()));
// Get the ExecutionGraph
jm.tell(new RequestExecutionGraph(jobGraph.getJobID()), testActor);
ExecutionGraphFound executionGraphResponse = expectMsgClass(ExecutionGraphFound.class);
ExecutionGraph executionGraph = (ExecutionGraph) executionGraphResponse.executionGraph();
ExecutionJobVertex vertex = executionGraph.getJobVertex(task.getID());
StackTraceSampleCoordinator coordinator = new StackTraceSampleCoordinator(testActorSystem.dispatcher(), 60000);
Future<StackTraceSample> sampleFuture = coordinator.triggerStackTraceSample(vertex.getTaskVertices(), // sampling.
21474700 * 100, Time.milliseconds(10L), 0);
// Wait before cancelling so that some samples
// are actually taken.
Thread.sleep(sleepTime);
// Cancel job
scala.concurrent.Future<?> removeFuture = jm.ask(new TestingJobManagerMessages.NotifyWhenJobRemoved(jobGraph.getJobID()), remaining());
jm.tell(new JobManagerMessages.CancelJob(jobGraph.getJobID()));
try {
// Throws Exception on failure
sampleFuture.get(remaining().toMillis(), TimeUnit.MILLISECONDS);
// partial result.
break;
} catch (Throwable t) {
// We were too fast in cancelling the job.
// Fall through and retry.
} finally {
Await.ready(removeFuture, remaining());
}
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
};
} finally {
TestingUtils.stopActor(jobManger);
TestingUtils.stopActor(taskManager);
}
}
};
}
use of scala.concurrent.duration.FiniteDuration in project flink by apache.
the class TaskManagersHandlerTest method testGetPaths.
@Test
public void testGetPaths() {
TaskManagersHandler handler = new TaskManagersHandler(new FiniteDuration(0, TimeUnit.SECONDS), null);
String[] paths = handler.getPaths();
Assert.assertEquals(2, paths.length);
List<String> pathsList = Lists.newArrayList(paths);
Assert.assertTrue(pathsList.contains("/taskmanagers"));
Assert.assertTrue(pathsList.contains("/taskmanagers/:taskmanagerid"));
}
use of scala.concurrent.duration.FiniteDuration in project flink by apache.
the class CurrentJobIdsHandlerTest method testGetPaths.
@Test
public void testGetPaths() {
CurrentJobIdsHandler handler = new CurrentJobIdsHandler(new FiniteDuration(0, TimeUnit.SECONDS));
String[] paths = handler.getPaths();
Assert.assertEquals(1, paths.length);
Assert.assertEquals("/jobs", paths[0]);
}
use of scala.concurrent.duration.FiniteDuration in project flink by apache.
the class CurrentJobsOverviewHandlerTest method testGetPaths.
@Test
public void testGetPaths() {
CurrentJobsOverviewHandler handlerAll = new CurrentJobsOverviewHandler(new FiniteDuration(0, TimeUnit.SECONDS), true, true);
String[] pathsAll = handlerAll.getPaths();
Assert.assertEquals(1, pathsAll.length);
Assert.assertEquals("/joboverview", pathsAll[0]);
CurrentJobsOverviewHandler handlerRunning = new CurrentJobsOverviewHandler(new FiniteDuration(0, TimeUnit.SECONDS), true, false);
String[] pathsRunning = handlerRunning.getPaths();
Assert.assertEquals(1, pathsRunning.length);
Assert.assertEquals("/joboverview/running", pathsRunning[0]);
CurrentJobsOverviewHandler handlerCompleted = new CurrentJobsOverviewHandler(new FiniteDuration(0, TimeUnit.SECONDS), false, true);
String[] pathsCompleted = handlerCompleted.getPaths();
Assert.assertEquals(1, pathsCompleted.length);
Assert.assertEquals("/joboverview/completed", pathsCompleted[0]);
}
use of scala.concurrent.duration.FiniteDuration in project flink by apache.
the class FlinkFuture method get.
@Override
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
Preconditions.checkNotNull(scalaFuture);
Preconditions.checkArgument(timeout >= 0L, "The timeout value has to be larger or " + "equal than 0.");
try {
return Await.result(scalaFuture, new FiniteDuration(timeout, unit));
} catch (InterruptedException | TimeoutException e) {
throw e;
} catch (Exception e) {
throw new ExecutionException(e);
}
}
Aggregations