Search in sources :

Example 11 with MiniClusterConfiguration

use of org.apache.flink.runtime.minicluster.MiniClusterConfiguration in project beam by apache.

the class FlinkMiniClusterEntryPoint method main.

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);
    }
}
Also used : MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster)

Example 12 with MiniClusterConfiguration

use of org.apache.flink.runtime.minicluster.MiniClusterConfiguration in project beam by apache.

the class FlinkSavepointTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    flinkJobExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(1));
    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();
}
Also used : MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) BeforeClass(org.junit.BeforeClass)

Example 13 with MiniClusterConfiguration

use of org.apache.flink.runtime.minicluster.MiniClusterConfiguration in project beam by apache.

the class FlinkRequiresStableInputTest method beforeClass.

@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);
}
Also used : MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) BeforeClass(org.junit.BeforeClass)

Example 14 with MiniClusterConfiguration

use of org.apache.flink.runtime.minicluster.MiniClusterConfiguration in project beam by apache.

the class FlinkSubmissionTest method beforeClass.

@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).setRpcServiceSharing(RpcServiceSharing.SHARED).build();
    flinkCluster = new RemoteMiniClusterImpl(clusterConfig);
    flinkCluster.start();
    prepareEnvironment();
}
Also used : MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) BeforeClass(org.junit.BeforeClass)

Example 15 with MiniClusterConfiguration

use of org.apache.flink.runtime.minicluster.MiniClusterConfiguration in project flink by apache.

the class MiniClusterResource method startMiniCluster.

private void startMiniCluster() throws Exception {
    final Configuration configuration = new Configuration(miniClusterResourceConfiguration.getConfiguration());
    configuration.setString(CoreOptions.TMP_DIRS, temporaryFolder.newFolder().getAbsolutePath());
    // 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");
    randomizeConfiguration(configuration);
    final MiniClusterConfiguration miniClusterConfiguration = new MiniClusterConfiguration.Builder().setConfiguration(configuration).setNumTaskManagers(miniClusterResourceConfiguration.getNumberTaskManagers()).setNumSlotsPerTaskManager(miniClusterResourceConfiguration.getNumberSlotsPerTaskManager()).setRpcServiceSharing(miniClusterResourceConfiguration.getRpcServiceSharing()).setHaServices(miniClusterResourceConfiguration.getHaServices()).build();
    miniCluster = new MiniCluster(miniClusterConfiguration, () -> Reference.borrowed(rpcSystem));
    miniCluster.start();
    final URI restAddress = miniCluster.getRestAddress().get();
    createClientConfiguration(restAddress);
}
Also used : MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) UnmodifiableConfiguration(org.apache.flink.configuration.UnmodifiableConfiguration) Configuration(org.apache.flink.configuration.Configuration) MiniClusterConfiguration(org.apache.flink.runtime.minicluster.MiniClusterConfiguration) MiniCluster(org.apache.flink.runtime.minicluster.MiniCluster) URI(java.net.URI)

Aggregations

MiniClusterConfiguration (org.apache.flink.runtime.minicluster.MiniClusterConfiguration)20 Configuration (org.apache.flink.configuration.Configuration)16 MiniCluster (org.apache.flink.runtime.minicluster.MiniCluster)15 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)8 BeforeClass (org.junit.BeforeClass)5 JobID (org.apache.flink.api.common.JobID)4 MiniClusterClient (org.apache.flink.client.program.MiniClusterClient)4 Test (org.junit.Test)4 JobGraphBuilder (org.apache.flink.runtime.jobgraph.JobGraphBuilder)3 JobResult (org.apache.flink.runtime.jobmaster.JobResult)3 RecordWriterBuilder (org.apache.flink.runtime.io.network.api.writer.RecordWriterBuilder)2 URI (java.net.URI)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Function (java.util.function.Function)1 ConfigConstants (org.apache.flink.configuration.ConfigConstants)1 RestOptions (org.apache.flink.configuration.RestOptions)1 TaskManagerOptions (org.apache.flink.configuration.TaskManagerOptions)1 UnmodifiableConfiguration (org.apache.flink.configuration.UnmodifiableConfiguration)1