org.apache.flink.runtime.minicluster.MiniCluster Java Examples
The following examples show how to use
org.apache.flink.runtime.minicluster.MiniCluster.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlinkSavepointTest.java From beam with Apache License 2.0 | 6 votes |
@BeforeClass public static void beforeClass() throws Exception { Configuration config = new Configuration(); // Avoid port collision in parallel tests config.setInteger(RestOptions.PORT, 0); config.setString(CheckpointingOptions.STATE_BACKEND, "filesystem"); String savepointPath = "file://" + tempFolder.getRoot().getAbsolutePath(); LOG.info("Savepoints will be written to {}", savepointPath); // It is necessary to configure the checkpoint directory for the state backend, // even though we only create savepoints in this test. config.setString(CheckpointingOptions.CHECKPOINTS_DIRECTORY, savepointPath); // Checkpoints will go into a subdirectory of this directory config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointPath); MiniClusterConfiguration clusterConfig = new MiniClusterConfiguration.Builder() .setConfiguration(config) .setNumTaskManagers(2) .setNumSlotsPerTaskManager(2) .build(); flinkCluster = new MiniCluster(clusterConfig); flinkCluster.start(); }
Example #2
Source File: PerJobMiniClusterFactory.java From flink with Apache License 2.0 | 6 votes |
/** * Starts a {@link MiniCluster} and submits a job. */ public CompletableFuture<JobClient> submitJob(JobGraph jobGraph) throws Exception { MiniClusterConfiguration miniClusterConfig = getMiniClusterConfig(jobGraph.getMaximumParallelism()); MiniCluster miniCluster = miniClusterFactory.apply(miniClusterConfig); miniCluster.start(); return miniCluster .submitJob(jobGraph) .thenApply(result -> new PerJobMiniClusterJobClient(result.getJobID(), miniCluster)) .whenComplete((ignored, throwable) -> { if (throwable != null) { // We failed to create the JobClient and must shutdown to ensure cleanup. shutDownCluster(miniCluster); } }) .thenApply(Function.identity()); }
Example #3
Source File: LocalExecutor.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private JobExecutorService createJobExecutorService(Configuration configuration) throws Exception { if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers( configuration.getInteger( ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, ConfigConstants.DEFAULT_LOCAL_NUMBER_TASK_MANAGER)) .setRpcServiceSharing(RpcServiceSharing.SHARED) .setNumSlotsPerTaskManager( configuration.getInteger( TaskManagerOptions.NUM_TASK_SLOTS, 1)) .build(); final MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration); miniCluster.start(); configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().get().getPort()); return miniCluster; }
Example #4
Source File: DataStreamTestEnvironment.java From flink-spector with Apache License 2.0 | 6 votes |
/** * Factory method to startWith a new instance, providing a new instance of {@link MiniCluster} * * @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(); Configuration configuration = new Configuration(); configuration.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, "0"); if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } int numSlotsPerTaskManager = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS, taskSlots); MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumSlotsPerTaskManager(numSlotsPerTaskManager) .build(); MiniCluster miniCluster = new MiniCluster(cfg); return new DataStreamTestEnvironment( miniCluster, parallelism); }
Example #5
Source File: LocalExecutor.java From flink with Apache License 2.0 | 6 votes |
private JobExecutorService createJobExecutorService(Configuration configuration) throws Exception { if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers( configuration.getInteger( ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, ConfigConstants.DEFAULT_LOCAL_NUMBER_TASK_MANAGER)) .setRpcServiceSharing(RpcServiceSharing.SHARED) .setNumSlotsPerTaskManager( configuration.getInteger( TaskManagerOptions.NUM_TASK_SLOTS, 1)) .build(); final MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration); miniCluster.start(); configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().get().getPort()); return miniCluster; }
Example #6
Source File: ShuffleCompressionITCase.java From flink with Apache License 2.0 | 6 votes |
private void executeTest(JobGraph jobGraph) throws Exception { Configuration configuration = new Configuration(); configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g")); configuration.setBoolean(NettyShuffleEnvironmentOptions.BLOCKING_SHUFFLE_COMPRESSION_ENABLED, true); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(NUM_TASKMANAGERS) .setNumSlotsPerTaskManager(NUM_SLOTS) .build(); try (MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); MiniClusterClient miniClusterClient = new MiniClusterClient(configuration, miniCluster); // wait for the submission to succeed JobID jobID = miniClusterClient.submitJob(jobGraph).get(); CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobID); assertFalse(resultFuture.get().getSerializedThrowable().isPresent()); } }
Example #7
Source File: DataSetTestEnvironment.java From flink-spector with Apache License 2.0 | 6 votes |
/** * Factory method to startWith a new instance, providing a * new instance of {@link MiniCluster} * * @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(); Configuration configuration = new Configuration(); configuration.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, "0"); if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } int numSlotsPerTaskManager = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS, taskSlots); MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumSlotsPerTaskManager(numSlotsPerTaskManager) .build(); MiniCluster miniCluster = new MiniCluster(cfg); return new DataSetTestEnvironment(miniCluster, parallelism); }
Example #8
Source File: LocalExecutorITCase.java From flink with Apache License 2.0 | 5 votes |
@Before public void before() { executor = LocalExecutor.createWithFactory(new Configuration(), config -> { miniCluster = new MiniCluster(config); return miniCluster; }); }
Example #9
Source File: FlinkRequiresStableInputTest.java From beam with Apache License 2.0 | 5 votes |
@BeforeClass public static void beforeClass() throws Exception { final int parallelism = 1; Configuration config = new Configuration(); // Avoid port collision in parallel tests config.setInteger(RestOptions.PORT, 0); config.setString(CheckpointingOptions.STATE_BACKEND, "filesystem"); // It is necessary to configure the checkpoint directory for the state backend, // even though we only create savepoints in this test. config.setString( CheckpointingOptions.CHECKPOINTS_DIRECTORY, "file://" + tempFolder.getRoot().getAbsolutePath()); // Checkpoints will go into a subdirectory of this directory config.setString( CheckpointingOptions.SAVEPOINT_DIRECTORY, "file://" + tempFolder.getRoot().getAbsolutePath()); MiniClusterConfiguration clusterConfig = new MiniClusterConfiguration.Builder() .setConfiguration(config) .setNumTaskManagers(1) .setNumSlotsPerTaskManager(1) .build(); flinkCluster = new MiniCluster(clusterConfig); flinkCluster.start(); TestStreamEnvironment.setAsContext(flinkCluster, parallelism); }
Example #10
Source File: DataStreamTestEnvironment.java From flink-spector with Apache License 2.0 | 5 votes |
public DataStreamTestEnvironment(MiniCluster cluster, int parallelism) { super(cluster, parallelism); runner = new Runner(cluster) { @Override protected void executeEnvironment() throws Throwable { TestStreamEnvironment.setAsContext(cluster, parallelism); try { execute(); } finally { TestStreamEnvironment.unsetAsContext(); } } }; }
Example #11
Source File: DataSetTestEnvironment.java From flink-spector with Apache License 2.0 | 5 votes |
public DataSetTestEnvironment(MiniCluster executor, int parallelism) { super(executor, parallelism, false); runner = new Runner(executor) { @Override protected void executeEnvironment() throws Throwable { TestStreamEnvironment.setAsContext(executor, parallelism); try { execute(); } finally { TestStreamEnvironment.unsetAsContext(); } } }; }
Example #12
Source File: Runner.java From flink-spector with Apache License 2.0 | 5 votes |
public Runner(MiniCluster executor) { this.cluster = executor; executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)); currentInstance = 1; runningListeners = new AtomicInteger(0); stopExecution = new TimerTask() { public void run() { stopExecution(); } }; }
Example #13
Source File: JobManagerWatermarkTrackerTest.java From flink with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { final Configuration config = new Configuration(); config.setInteger(RestOptions.PORT, 0); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(config) .setNumTaskManagers(1) .setNumSlotsPerTaskManager(1) .build(); flink = new MiniCluster(miniClusterConfiguration); flink.start(); }
Example #14
Source File: SchedulingITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void executeSchedulingTest(Configuration configuration) throws Exception { configuration.setString(RestOptions.BIND_PORT, "0"); final long slotIdleTimeout = 50L; configuration.setLong(JobManagerOptions.SLOT_IDLE_TIMEOUT, slotIdleTimeout); final int parallelism = 4; final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); MiniClusterClient miniClusterClient = new MiniClusterClient(configuration, miniCluster); JobGraph jobGraph = createJobGraph(slotIdleTimeout << 1, parallelism); CompletableFuture<JobSubmissionResult> submissionFuture = miniClusterClient.submitJob(jobGraph); // wait for the submission to succeed JobSubmissionResult jobSubmissionResult = submissionFuture.get(); CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobSubmissionResult.getJobID()); JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #15
Source File: SchedulingITCase.java From flink with Apache License 2.0 | 5 votes |
private void executeSchedulingTest(Configuration configuration) throws Exception { configuration.setString(RestOptions.BIND_PORT, "0"); final long slotIdleTimeout = 50L; configuration.setLong(JobManagerOptions.SLOT_IDLE_TIMEOUT, slotIdleTimeout); configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g")); final int parallelism = 4; final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); MiniClusterClient miniClusterClient = new MiniClusterClient(configuration, miniCluster); JobGraph jobGraph = createJobGraph(slotIdleTimeout << 1, parallelism); // wait for the submission to succeed JobID jobID = miniClusterClient.submitJob(jobGraph).get(); CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobID); JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #16
Source File: FileBufferReaderITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSequentialReading() throws Exception { // setup final Configuration configuration = new Configuration(); configuration.setString(RestOptions.BIND_PORT, "0"); configuration.setString(NettyShuffleEnvironmentOptions.NETWORK_BLOCKING_SHUFFLE_TYPE, "file"); configuration.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g")); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (final MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); final MiniClusterClient client = new MiniClusterClient(configuration, miniCluster); final JobGraph jobGraph = createJobGraph(); // wait for the submission to succeed final JobID jobID = client.submitJob(jobGraph).get(); final CompletableFuture<JobResult> resultFuture = client.requestJobResult(jobID); final JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #17
Source File: CoordinatorEventsExactlyOnceITCase.java From flink with Apache License 2.0 | 5 votes |
@BeforeClass public static void startMiniCluster() throws Exception { final Configuration config = new Configuration(); config.setString(RestOptions.BIND_PORT, "0"); final MiniClusterConfiguration clusterCfg = new MiniClusterConfiguration.Builder() .setNumTaskManagers(2) .setNumSlotsPerTaskManager(1) .setConfiguration(config) .build(); miniCluster = new MiniCluster(clusterCfg); miniCluster.start(); }
Example #18
Source File: MiniClusterResource.java From flink with Apache License 2.0 | 5 votes |
private void startMiniCluster() throws Exception { final Configuration configuration = new Configuration(miniClusterResourceConfiguration.getConfiguration()); configuration.setString(CoreOptions.TMP_DIRS, temporaryFolder.newFolder().getAbsolutePath()); // we need to set this since a lot of test expect this because TestBaseUtils.startCluster() // enabled this by default if (!configuration.contains(CoreOptions.FILESYTEM_DEFAULT_OVERRIDE)) { configuration.setBoolean(CoreOptions.FILESYTEM_DEFAULT_OVERRIDE, true); } if (!configuration.contains(TaskManagerOptions.MANAGED_MEMORY_SIZE)) { configuration.set(TaskManagerOptions.MANAGED_MEMORY_SIZE, DEFAULT_MANAGED_MEMORY_SIZE); } // set rest and rpc port to 0 to avoid clashes with concurrent MiniClusters configuration.setInteger(JobManagerOptions.PORT, 0); configuration.setString(RestOptions.BIND_PORT, "0"); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(miniClusterResourceConfiguration.getNumberTaskManagers()) .setNumSlotsPerTaskManager(miniClusterResourceConfiguration.getNumberSlotsPerTaskManager()) .build(); miniCluster = new MiniCluster(miniClusterConfiguration); miniCluster.start(); final URI restAddress = miniCluster.getRestAddress().get(); createClientConfiguration(restAddress); }
Example #19
Source File: PerJobMiniClusterFactory.java From flink with Apache License 2.0 | 5 votes |
private static void shutDownCluster(MiniCluster miniCluster) { miniCluster.closeAsync() .whenComplete((ignored, throwable) -> { if (throwable != null) { LOG.warn("Shutdown of MiniCluster failed.", throwable); } }); }
Example #20
Source File: PerJobMiniClusterFactory.java From flink with Apache License 2.0 | 5 votes |
private PerJobMiniClusterJobClient(JobID jobID, MiniCluster miniCluster) { this.jobID = jobID; this.miniCluster = miniCluster; this.jobResultFuture = miniCluster .requestJobResult(jobID) // Make sure to shutdown the cluster when the job completes. .whenComplete((result, throwable) -> shutDownCluster(miniCluster)); }
Example #21
Source File: RemoteChannelThroughputBenchmark.java From flink-benchmarks with Apache License 2.0 | 5 votes |
@Setup public void setUp() throws Exception { MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setNumTaskManagers(NUM_VERTICES * PARALLELISM) .setNumSlotsPerTaskManager(1) .build(); miniCluster = new MiniCluster(miniClusterConfiguration); miniCluster.start(); }
Example #22
Source File: MiniClusterResource.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void startMiniCluster() throws Exception { final Configuration configuration = new Configuration(miniClusterResourceConfiguration.getConfiguration()); configuration.setString(CoreOptions.TMP_DIRS, temporaryFolder.newFolder().getAbsolutePath()); // we need to set this since a lot of test expect this because TestBaseUtils.startCluster() // enabled this by default if (!configuration.contains(CoreOptions.FILESYTEM_DEFAULT_OVERRIDE)) { configuration.setBoolean(CoreOptions.FILESYTEM_DEFAULT_OVERRIDE, true); } if (!configuration.contains(TaskManagerOptions.MANAGED_MEMORY_SIZE)) { configuration.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, DEFAULT_MANAGED_MEMORY_SIZE); } // set rest and rpc port to 0 to avoid clashes with concurrent MiniClusters configuration.setInteger(JobManagerOptions.PORT, 0); configuration.setString(RestOptions.BIND_PORT, "0"); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(miniClusterResourceConfiguration.getNumberTaskManagers()) .setNumSlotsPerTaskManager(miniClusterResourceConfiguration.getNumberSlotsPerTaskManager()) .build(); miniCluster = new MiniCluster(miniClusterConfiguration); miniCluster.start(); final URI restAddress = miniCluster.getRestAddress().get(); createClientConfiguration(restAddress); }
Example #23
Source File: JobManagerWatermarkTrackerTest.java From flink with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { final Configuration config = new Configuration(); config.setInteger(RestOptions.PORT, 0); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(config) .setNumTaskManagers(1) .setNumSlotsPerTaskManager(1) .build(); flink = new MiniCluster(miniClusterConfiguration); flink.start(); }
Example #24
Source File: SchedulingITCase.java From flink with Apache License 2.0 | 5 votes |
private void executeSchedulingTest(Configuration configuration) throws Exception { configuration.setString(RestOptions.BIND_PORT, "0"); final long slotIdleTimeout = 50L; configuration.setLong(JobManagerOptions.SLOT_IDLE_TIMEOUT, slotIdleTimeout); final int parallelism = 4; final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); MiniClusterClient miniClusterClient = new MiniClusterClient(configuration, miniCluster); JobGraph jobGraph = createJobGraph(slotIdleTimeout << 1, parallelism); CompletableFuture<JobSubmissionResult> submissionFuture = miniClusterClient.submitJob(jobGraph); // wait for the submission to succeed JobSubmissionResult jobSubmissionResult = submissionFuture.get(); CompletableFuture<JobResult> resultFuture = miniClusterClient.requestJobResult(jobSubmissionResult.getJobID()); JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #25
Source File: FileBufferReaderITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testSequentialReading() throws Exception { // setup final Configuration configuration = new Configuration(); configuration.setString(RestOptions.BIND_PORT, "0"); configuration.setString(NettyShuffleEnvironmentOptions.NETWORK_BOUNDED_BLOCKING_SUBPARTITION_TYPE, "file"); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(parallelism) .setNumSlotsPerTaskManager(1) .build(); try (final MiniCluster miniCluster = new MiniCluster(miniClusterConfiguration)) { miniCluster.start(); final MiniClusterClient client = new MiniClusterClient(configuration, miniCluster); final JobGraph jobGraph = createJobGraph(); final CompletableFuture<JobSubmissionResult> submitFuture = client.submitJob(jobGraph); // wait for the submission to succeed final JobSubmissionResult result = submitFuture.get(); final CompletableFuture<JobResult> resultFuture = client.requestJobResult(result.getJobID()); final JobResult jobResult = resultFuture.get(); assertThat(jobResult.getSerializedThrowable().isPresent(), is(false)); } }
Example #26
Source File: MiniClusterResource.java From flink with Apache License 2.0 | 5 votes |
private void startMiniCluster() throws Exception { final Configuration configuration = new Configuration(miniClusterResourceConfiguration.getConfiguration()); configuration.setString(CoreOptions.TMP_DIRS, temporaryFolder.newFolder().getAbsolutePath()); // we need to set this since a lot of test expect this because TestBaseUtils.startCluster() // enabled this by default if (!configuration.contains(CoreOptions.FILESYTEM_DEFAULT_OVERRIDE)) { configuration.setBoolean(CoreOptions.FILESYTEM_DEFAULT_OVERRIDE, true); } if (!configuration.contains(TaskManagerOptions.MANAGED_MEMORY_SIZE)) { configuration.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, DEFAULT_MANAGED_MEMORY_SIZE); } // set rest and rpc port to 0 to avoid clashes with concurrent MiniClusters configuration.setInteger(JobManagerOptions.PORT, 0); configuration.setString(RestOptions.BIND_PORT, "0"); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(miniClusterResourceConfiguration.getNumberTaskManagers()) .setNumSlotsPerTaskManager(miniClusterResourceConfiguration.getNumberSlotsPerTaskManager()) .build(); miniCluster = new MiniCluster(miniClusterConfiguration); miniCluster.start(); final URI restAddress = miniCluster.getRestAddress().get(); createClientConfiguration(restAddress); }
Example #27
Source File: JobManagerWatermarkTrackerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { final Configuration config = new Configuration(); config.setInteger(RestOptions.PORT, 0); final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder() .setConfiguration(config) .setNumTaskManagers(1) .setNumSlotsPerTaskManager(1) .build(); flink = new MiniCluster(miniClusterConfiguration); flink.start(); }
Example #28
Source File: FlinkMiniClusterEntryPoint.java From beam with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { MiniClusterArgs miniClusterArgs = parseArgs(args); Configuration flinkConfig = new Configuration(); flinkConfig.setInteger(RestOptions.PORT, miniClusterArgs.restPort); if (!miniClusterArgs.restBindAddress.isEmpty()) { flinkConfig.setString(RestOptions.BIND_ADDRESS, miniClusterArgs.restBindAddress); } MiniClusterConfiguration clusterConfig = new MiniClusterConfiguration.Builder() .setConfiguration(flinkConfig) .setNumTaskManagers(miniClusterArgs.numTaskManagers) .setNumSlotsPerTaskManager(miniClusterArgs.numSlotsPerTaskManager) .build(); try (MiniCluster miniCluster = new MiniCluster(clusterConfig)) { miniCluster.start(); System.out.println( String.format( "Started Flink mini cluster (%s TaskManagers with %s task slots) with Rest API at %s", miniClusterArgs.numTaskManagers, miniClusterArgs.numSlotsPerTaskManager, miniCluster.getRestAddress())); Thread.sleep(Long.MAX_VALUE); } }
Example #29
Source File: MiniExecutor.java From sylph with Apache License 2.0 | 5 votes |
public MiniExecutor(JobGraph jobGraph) throws Exception { jobGraph.setAllowQueuedScheduling(true); Configuration configuration = new Configuration(); configuration.addAll(jobGraph.getJobConfiguration()); configuration.setString(TaskManagerOptions.MANAGED_MEMORY_SIZE, "0"); // add (and override) the settings with what the user defined configuration.addAll(jobGraph.getJobConfiguration()); if (!configuration.contains(RestOptions.PORT)) { configuration.setInteger(RestOptions.PORT, 0); } int numSlotsPerTaskManager = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS, jobGraph.getMaximumParallelism()); MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumSlotsPerTaskManager(numSlotsPerTaskManager) .build(); if (logger.isInfoEnabled()) { logger.info("Running job on local embedded Flink mini cluster"); } this.miniCluster = new MiniCluster(cfg); this.jobGraph = jobGraph; miniCluster.start(); configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().get().getPort()); }
Example #30
Source File: MiniClusterResource.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
public MiniCluster getMiniCluster() { return miniCluster; }