final TestingCluster cluster = new TestingCluster(configuration); cluster.start(); clientActorSystem = cluster.startJobClientActorSystem(graph.getJobID()); ActorGateway jm = cluster.getLeaderGateway(deadline.timeLeft()); cluster.waitForTaskManagersToBeRegisteredAtJobManager(jm.actor()); cluster.clearLeader(); cluster.shutdownJobClientActorSystem(clientActorSystem); jobSubmission.finished = true; cluster.stop();
configuration.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, numTMs); TestingCluster cluster = new TestingCluster(configuration); cluster.start(); ActorGateway leadingJM = cluster.getLeaderGateway(timeout); cluster.waitForTaskManagersToBeRegisteredAtJobManager(leadingJM.actor()); cluster.clearLeader(); leadingJM.tell(PoisonPill.getInstance()); cluster.stop();
private void shutdownLocalCluster() { if(!cluster.running()) { return; } try { cluster.getCurrentlyRunningJobsJava() .forEach(jobID -> { try { cluster.cancelJob(jobID); } catch(Exception e) { ExceptionUtils.rethrow(e); } }); cluster.stop(); } catch(IllegalStateException e) { //this can happen in some cases if Flink has some timers register wih akka. } catch(Exception e) { e.printStackTrace(); } }
/** * Factory method to startWith a new instance, providing a new instance of {@link LocalFlinkMiniCluster} * * @param parallelism global setting for parallel execution. * @return new instance of {@link DataStreamTestEnvironment} * @throws Exception */ public static DataStreamTestEnvironment createTestEnvironment(int parallelism) { int taskSlots = Runtime.getRuntime().availableProcessors(); final Configuration configuration = new Configuration(); configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, taskSlots); return new DataStreamTestEnvironment(new TestingCluster(configuration), parallelism); }
private synchronized void runLocalCluster() throws Throwable { try { running.set(true); cluster.start(); executeEnvironment(); finished.set(true); cleanUp(); } catch(JobTimeoutException | IllegalStateException e) { //cluster has been shutdown forcefully, most likely by a timeout. cleanUp(); failed.set(true); } }
/** * Factory method to startWith a new instance, providing a * new instance of {@link LocalFlinkMiniCluster} * * @param parallelism global setting for parallel execution. * @return new instance of {@link DataSetTestEnvironment} * @throws Exception */ public static DataSetTestEnvironment createTestEnvironment(int parallelism) { int taskSlots = Runtime.getRuntime().availableProcessors(); final Configuration configuration = new Configuration(); configuration.setInteger(TaskManagerOptions.NUM_TASK_SLOTS, taskSlots); return new DataSetTestEnvironment(new TestingCluster(configuration), parallelism); }