org.apache.flink.runtime.minicluster.MiniClusterConfiguration Java Examples
The following examples show how to use
org.apache.flink.runtime.minicluster.MiniClusterConfiguration.
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: PerJobMiniClusterFactory.java From flink with Apache License 2.0 | 6 votes |
private MiniClusterConfiguration getMiniClusterConfig(int maximumParallelism) { Configuration configuration = new Configuration(this.configuration); if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } int numTaskManagers = configuration.getInteger( ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, ConfigConstants.DEFAULT_LOCAL_NUMBER_TASK_MANAGER); int numSlotsPerTaskManager = configuration.getOptional(TaskManagerOptions.NUM_TASK_SLOTS) .orElseGet(() -> maximumParallelism > 0 ? MathUtils.divideRoundUp(maximumParallelism, numTaskManagers) : TaskManagerOptions.NUM_TASK_SLOTS.defaultValue()); return new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumTaskManagers(numTaskManagers) .setRpcServiceSharing(RpcServiceSharing.SHARED) .setNumSlotsPerTaskManager(numSlotsPerTaskManager) .build(); }
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: 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 #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: 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 #7
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 #8
Source File: FlinkSubmissionTest.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 on the same machine config.setInteger(RestOptions.PORT.key(), 0); MiniClusterConfiguration clusterConfig = new MiniClusterConfiguration.Builder() .setConfiguration(config) .setNumTaskManagers(1) .setNumSlotsPerTaskManager(1) // Create a shared actor system for all cluster services .setRpcServiceSharing(RpcServiceSharing.SHARED) .build(); flinkCluster = new RemoteMiniClusterImpl(clusterConfig); flinkCluster.start(); prepareEnvironment(); }
Example #9
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 #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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 #25
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 #26
Source File: LocalStreamEnvironment.java From flink with Apache License 2.0 | 4 votes |
/** * Executes the JobGraph of the on a mini cluster of ClusterUtil with a user * specified name. * * @return The result of the job execution, containing elapsed time and accumulators. */ @Override public JobExecutionResult execute(StreamGraph streamGraph) throws Exception { JobGraph jobGraph = streamGraph.getJobGraph(); 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(this.configuration); if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } int numSlotsPerTaskManager = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS, jobGraph.getMaximumParallelism()); MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumSlotsPerTaskManager(numSlotsPerTaskManager) .build(); if (LOG.isInfoEnabled()) { LOG.info("Running job on local embedded Flink mini cluster"); } MiniCluster miniCluster = new MiniCluster(cfg); try { miniCluster.start(); configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().get().getPort()); return miniCluster.executeJobBlocking(jobGraph); } finally { transformations.clear(); miniCluster.close(); } }
Example #27
Source File: RemoteMiniClusterImpl.java From beam with Apache License 2.0 | 4 votes |
public RemoteMiniClusterImpl(MiniClusterConfiguration miniClusterConfiguration) { super(miniClusterConfiguration); }
Example #28
Source File: LocalStreamEnvironment.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Executes the JobGraph of the on a mini cluster of CLusterUtil with a user * specified name. * * @param jobName * name of the job * @return The result of the job execution, containing elapsed time and accumulators. */ @Override public JobExecutionResult execute(String jobName) throws Exception { // transform the streaming program into a JobGraph StreamGraph streamGraph = getStreamGraph(); streamGraph.setJobName(jobName); JobGraph jobGraph = streamGraph.getJobGraph(); 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(this.configuration); if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } int numSlotsPerTaskManager = configuration.getInteger(TaskManagerOptions.NUM_TASK_SLOTS, jobGraph.getMaximumParallelism()); MiniClusterConfiguration cfg = new MiniClusterConfiguration.Builder() .setConfiguration(configuration) .setNumSlotsPerTaskManager(numSlotsPerTaskManager) .build(); if (LOG.isInfoEnabled()) { LOG.info("Running job on local embedded Flink mini cluster"); } MiniCluster miniCluster = new MiniCluster(cfg); try { miniCluster.start(); configuration.setInteger(RestOptions.PORT, miniCluster.getRestAddress().get().getPort()); return miniCluster.executeJobBlocking(jobGraph); } finally { transformations.clear(); miniCluster.close(); } }
Example #29
Source File: LocalExecutor.java From flink with Apache License 2.0 | 4 votes |
public static LocalExecutor createWithFactory( Configuration configuration, Function<MiniClusterConfiguration, MiniCluster> miniClusterFactory) { return new LocalExecutor(configuration, miniClusterFactory); }
Example #30
Source File: LocalExecutor.java From flink with Apache License 2.0 | 4 votes |
private LocalExecutor(Configuration configuration, Function<MiniClusterConfiguration, MiniCluster> miniClusterFactory) { this.configuration = configuration; this.miniClusterFactory = miniClusterFactory; }