org.apache.flink.runtime.clusterframework.BootstrapTools Java Examples
The following examples show how to use
org.apache.flink.runtime.clusterframework.BootstrapTools.
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: MesosJobClusterEntrypoint.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // startup checks and logging EnvironmentInformation.logEnvironmentInfo(LOG, MesosJobClusterEntrypoint.class.getSimpleName(), args); SignalHandler.register(LOG); JvmShutdownSafeguard.installAsShutdownHook(LOG); // load configuration incl. dynamic properties CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(ALL_OPTIONS, args); } catch (Exception e){ LOG.error("Could not parse the command-line options.", e); System.exit(STARTUP_FAILURE_RETURN_CODE); return; } Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd); Configuration configuration = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG); MesosJobClusterEntrypoint clusterEntrypoint = new MesosJobClusterEntrypoint(configuration, dynamicProperties); ClusterEntrypoint.runClusterEntrypoint(clusterEntrypoint); }
Example #2
Source File: MesosSessionClusterEntrypoint.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // startup checks and logging EnvironmentInformation.logEnvironmentInfo(LOG, MesosSessionClusterEntrypoint.class.getSimpleName(), args); SignalHandler.register(LOG); JvmShutdownSafeguard.installAsShutdownHook(LOG); // load configuration incl. dynamic properties CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(ALL_OPTIONS, args); } catch (Exception e){ LOG.error("Could not parse the command-line options.", e); System.exit(STARTUP_FAILURE_RETURN_CODE); return; } Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd); Configuration configuration = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG); MesosSessionClusterEntrypoint clusterEntrypoint = new MesosSessionClusterEntrypoint(configuration, dynamicProperties); ClusterEntrypoint.runClusterEntrypoint(clusterEntrypoint); }
Example #3
Source File: AkkaRpcServiceUtils.java From flink with Apache License 2.0 | 6 votes |
/** * Utility method to create RPC service from configuration and hostname, port. * * @param hostname The hostname/address that describes the TaskManager's data location. * @param portRangeDefinition The port range to start TaskManager on. * @param configuration The configuration for the TaskManager. * @param actorSystemName The actor system name of the RpcService. * @param actorSystemExecutorConfiguration The configuration of the executor of the actor system. * @return The rpc service which is used to start and connect to the TaskManager RpcEndpoint . * @throws IOException Thrown, if the actor system can not bind to the address * @throws Exception Thrown is some other error occurs while creating akka actor system */ public static RpcService createRpcService( String hostname, String portRangeDefinition, Configuration configuration, String actorSystemName, @Nonnull BootstrapTools.ActorSystemExecutorConfiguration actorSystemExecutorConfiguration) throws Exception { final ActorSystem actorSystem = BootstrapTools.startActorSystem( configuration, actorSystemName, hostname, portRangeDefinition, LOG, actorSystemExecutorConfiguration); return instantiateAkkaRpcService(configuration, actorSystem); }
Example #4
Source File: MesosJobClusterEntrypoint.java From flink with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // startup checks and logging EnvironmentInformation.logEnvironmentInfo(LOG, MesosJobClusterEntrypoint.class.getSimpleName(), args); SignalHandler.register(LOG); JvmShutdownSafeguard.installAsShutdownHook(LOG); // load configuration incl. dynamic properties CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(ALL_OPTIONS, args); } catch (Exception e){ LOG.error("Could not parse the command-line options.", e); System.exit(STARTUP_FAILURE_RETURN_CODE); return; } Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd); Configuration configuration = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG); MesosJobClusterEntrypoint clusterEntrypoint = new MesosJobClusterEntrypoint(configuration, dynamicProperties); ClusterEntrypoint.runClusterEntrypoint(clusterEntrypoint); }
Example #5
Source File: KubernetesResourceManager.java From flink with Apache License 2.0 | 6 votes |
private KubernetesTaskManagerParameters createKubernetesTaskManagerParameters(WorkerResourceSpec workerResourceSpec) { final TaskExecutorProcessSpec taskExecutorProcessSpec = TaskExecutorProcessUtils.processSpecFromWorkerResourceSpec(flinkConfig, workerResourceSpec); final String podName = String.format( TASK_MANAGER_POD_FORMAT, clusterId, currentMaxAttemptId, ++currentMaxPodId); final ContaineredTaskManagerParameters taskManagerParameters = ContaineredTaskManagerParameters.create(flinkConfig, taskExecutorProcessSpec); final Configuration taskManagerConfig = new Configuration(flinkConfig); taskManagerConfig.set(TaskManagerOptions.TASK_MANAGER_RESOURCE_ID, podName); final String dynamicProperties = BootstrapTools.getDynamicPropertiesAsString(flinkClientConfig, taskManagerConfig); return new KubernetesTaskManagerParameters( flinkConfig, podName, dynamicProperties, taskManagerParameters, ExternalResourceUtils.getExternalResources(flinkConfig, KubernetesConfigOptions.EXTERNAL_RESOURCE_KUBERNETES_CONFIG_KEY_SUFFIX)); }
Example #6
Source File: MesosJobClusterEntrypoint.java From flink with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // startup checks and logging EnvironmentInformation.logEnvironmentInfo(LOG, MesosJobClusterEntrypoint.class.getSimpleName(), args); SignalHandler.register(LOG); JvmShutdownSafeguard.installAsShutdownHook(LOG); // load configuration incl. dynamic properties CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(ALL_OPTIONS, args); } catch (Exception e){ LOG.error("Could not parse the command-line options.", e); System.exit(STARTUP_FAILURE_RETURN_CODE); return; } Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd); Configuration configuration = MesosUtils.loadConfiguration(dynamicProperties, LOG); MesosJobClusterEntrypoint clusterEntrypoint = new MesosJobClusterEntrypoint(configuration); ClusterEntrypoint.runClusterEntrypoint(clusterEntrypoint); }
Example #7
Source File: MesosSessionClusterEntrypoint.java From flink with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // startup checks and logging EnvironmentInformation.logEnvironmentInfo(LOG, MesosSessionClusterEntrypoint.class.getSimpleName(), args); SignalHandler.register(LOG); JvmShutdownSafeguard.installAsShutdownHook(LOG); // load configuration incl. dynamic properties CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(ALL_OPTIONS, args); } catch (Exception e){ LOG.error("Could not parse the command-line options.", e); System.exit(STARTUP_FAILURE_RETURN_CODE); return; } Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd); Configuration configuration = MesosUtils.loadConfiguration(dynamicProperties, LOG); MesosSessionClusterEntrypoint clusterEntrypoint = new MesosSessionClusterEntrypoint(configuration); ClusterEntrypoint.runClusterEntrypoint(clusterEntrypoint); }
Example #8
Source File: YarnEntrypointUtilsTest.java From flink with Apache License 2.0 | 5 votes |
@Nonnull private static Configuration loadConfiguration(Configuration initialConfiguration) throws IOException { final File workingDirectory = TEMPORARY_FOLDER.newFolder(); final Map<String, String> env = new HashMap<>(4); env.put(ApplicationConstants.Environment.NM_HOST.key(), "foobar"); BootstrapTools.writeConfiguration(initialConfiguration, new File(workingDirectory, "flink-conf.yaml")); return YarnEntrypointUtils.loadConfiguration(workingDirectory.getAbsolutePath(), env, LOG); }
Example #9
Source File: MetricUtils.java From flink with Apache License 2.0 | 5 votes |
private static RpcService startMetricRpcService( Configuration configuration, AkkaRpcServiceUtils.AkkaRpcServiceBuilder rpcServiceBuilder) throws Exception { final int threadPriority = configuration.getInteger(MetricOptions.QUERY_SERVICE_THREAD_PRIORITY); return rpcServiceBuilder .withActorSystemName(METRICS_ACTOR_SYSTEM_NAME) .withActorSystemExecutorConfiguration(new BootstrapTools.FixedThreadPoolExecutorConfiguration(1, 1, threadPriority)) .createAndStart(); }
Example #10
Source File: MetricUtils.java From flink with Apache License 2.0 | 5 votes |
public static RpcService startMetricsRpcService(Configuration configuration, String hostname) throws Exception { final String portRange = configuration.getString(MetricOptions.QUERY_SERVICE_PORT); final int threadPriority = configuration.getInteger(MetricOptions.QUERY_SERVICE_THREAD_PRIORITY); return AkkaRpcServiceUtils.createRpcService( hostname, portRange, configuration, METRICS_ACTOR_SYSTEM_NAME, new BootstrapTools.FixedThreadPoolExecutorConfiguration(1, 1, threadPriority)); }
Example #11
Source File: TaskManagerLoadingDynamicPropertiesITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testLoadingDynamicPropertiesInBash() throws Exception { final Configuration clientConfiguration = new Configuration(); final File root = folder.getRoot(); final File homeDir = new File(root, "home"); assertTrue(homeDir.mkdir()); BootstrapTools.writeConfiguration(clientConfiguration, new File(homeDir, FLINK_CONF_FILENAME)); final Configuration jmUpdatedConfiguration = getJobManagerUpdatedConfiguration(); final File shellScriptFile = generateLaunchContainerScript( homeDir, BootstrapTools.getDynamicPropertiesAsString(clientConfiguration, jmUpdatedConfiguration)); Process process = new ProcessBuilder(shellScriptFile.getAbsolutePath()).start(); try { final StringWriter processOutput = new StringWriter(); new CommonTestUtils.PipeForwarder(process.getErrorStream(), processOutput); if (!process.waitFor(10, TimeUnit.SECONDS)) { throw new Exception("TestingTaskManagerRunner did not shutdown in time."); } assertEquals(processOutput.toString(), 0, process.exitValue()); } finally { process.destroy(); } }
Example #12
Source File: MesosUtils.java From flink with Apache License 2.0 | 5 votes |
/** * Loads the global configuration, adds the given dynamic properties configuration, and sets * the temp directory paths. * * @param dynamicProperties dynamic properties to integrate * @param log logger instance * @return the loaded and adapted global configuration */ public static Configuration loadConfiguration(Configuration dynamicProperties, Logger log) { Configuration configuration = GlobalConfiguration.loadConfiguration(dynamicProperties); // read the environment variables final Map<String, String> envs = System.getenv(); final String tmpDirs = envs.get(MesosConfigKeys.ENV_FLINK_TMP_DIR); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, tmpDirs); return configuration; }
Example #13
Source File: YarnTaskExecutorRunner.java From flink with Apache License 2.0 | 5 votes |
@VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); SecurityUtils.install(new SecurityConfiguration(configuration)); }
Example #14
Source File: YarnResourceManager.java From flink with Apache License 2.0 | 5 votes |
private ContainerLaunchContext createTaskExecutorLaunchContext( String containerId, String host, TaskExecutorProcessSpec taskExecutorProcessSpec) throws Exception { // init the ContainerLaunchContext final String currDir = env.get(ApplicationConstants.Environment.PWD.key()); final ContaineredTaskManagerParameters taskManagerParameters = ContaineredTaskManagerParameters.create(flinkConfig, taskExecutorProcessSpec); log.info("TaskExecutor {} will be started on {} with {}.", containerId, host, taskExecutorProcessSpec); final Configuration taskManagerConfig = BootstrapTools.cloneConfiguration(flinkConfig); taskManagerConfig.set(TaskManagerOptions.TASK_MANAGER_RESOURCE_ID, containerId); final String taskManagerDynamicProperties = BootstrapTools.getDynamicPropertiesAsString(flinkClientConfig, taskManagerConfig); log.debug("TaskManager configuration: {}", taskManagerConfig); ContainerLaunchContext taskExecutorLaunchContext = Utils.createTaskExecutorContext( flinkConfig, yarnConfig, env, taskManagerParameters, taskManagerDynamicProperties, currDir, YarnTaskExecutorRunner.class, log); taskExecutorLaunchContext.getEnvironment() .put(ENV_FLINK_NODE_ID, host); return taskExecutorLaunchContext; }
Example #15
Source File: YarnResourceManagerTest.java From flink with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException { testingFatalErrorHandler = new TestingFatalErrorHandler(); flinkConfig = new Configuration(); flinkConfig.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g")); File root = folder.getRoot(); File home = new File(root, "home"); boolean created = home.mkdir(); assertTrue(created); env = new HashMap<>(); env.put(ENV_APP_ID, "foo"); env.put(ENV_CLIENT_HOME_DIR, home.getAbsolutePath()); env.put(ENV_CLIENT_SHIP_FILES, ""); env.put(ENV_FLINK_CLASSPATH, ""); env.put(ENV_HADOOP_USER_NAME, "foo"); env.put(FLINK_DIST_JAR, new YarnLocalResourceDescriptor( "flink.jar", new Path("/tmp/flink.jar"), 0, System.currentTimeMillis(), LocalResourceVisibility.APPLICATION).toString()); env.put(ApplicationConstants.Environment.PWD.key(), home.getAbsolutePath()); BootstrapTools.writeConfiguration(flinkConfig, new File(home.getAbsolutePath(), FLINK_CONF_FILENAME)); }
Example #16
Source File: YarnEntrypointUtilsTest.java From flink with Apache License 2.0 | 5 votes |
@Nonnull private static Configuration loadConfiguration(Configuration initialConfiguration, Map<String, String> env) throws IOException { final File workingDirectory = TEMPORARY_FOLDER.newFolder(); env.put(ApplicationConstants.Environment.NM_HOST.key(), "foobar"); BootstrapTools.writeConfiguration(initialConfiguration, new File(workingDirectory, "flink-conf.yaml")); return YarnEntrypointUtils.loadConfiguration(workingDirectory.getAbsolutePath(), env); }
Example #17
Source File: AkkaRpcServiceUtils.java From flink with Apache License 2.0 | 5 votes |
public AkkaRpcService createAndStart() throws Exception { if (actorSystemExecutorConfiguration == null) { actorSystemExecutorConfiguration = BootstrapTools.ForkJoinExecutorConfiguration.fromConfiguration(configuration); } final ActorSystem actorSystem; if (externalAddress == null) { // create local actor system actorSystem = BootstrapTools.startLocalActorSystem( configuration, actorSystemName, logger, actorSystemExecutorConfiguration, customConfig); } else { // create remote actor system actorSystem = BootstrapTools.startRemoteActorSystem( configuration, actorSystemName, externalAddress, externalPortRange, bindAddress, Optional.ofNullable(bindPort), logger, actorSystemExecutorConfiguration, customConfig); } return new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.fromConfiguration(configuration)); }
Example #18
Source File: MetricUtils.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public static ActorSystem startMetricsActorSystem(Configuration configuration, String hostname, Logger logger) throws Exception { final String portRange = configuration.getString(MetricOptions.QUERY_SERVICE_PORT); final int threadPriority = configuration.getInteger(MetricOptions.QUERY_SERVICE_THREAD_PRIORITY); return BootstrapTools.startActorSystem( configuration, METRICS_ACTOR_SYSTEM_NAME, hostname, portRange, logger, new BootstrapTools.FixedThreadPoolExecutorConfiguration(1, 1, threadPriority)); }
Example #19
Source File: MesosEntrypointUtils.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Loads the global configuration, adds the given dynamic properties configuration, and sets * the temp directory paths. * * @param dynamicProperties dynamic properties to integrate * @param log logger instance * @return the loaded and adapted global configuration */ public static Configuration loadConfiguration(Configuration dynamicProperties, Logger log) { Configuration configuration = GlobalConfiguration.loadConfigurationWithDynamicProperties(dynamicProperties); // read the environment variables final Map<String, String> envs = System.getenv(); final String tmpDirs = envs.get(MesosConfigKeys.ENV_FLINK_TMP_DIR); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, tmpDirs); return configuration; }
Example #20
Source File: YarnTaskExecutorRunner.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); installSecurityContext(configuration); }
Example #21
Source File: YarnResourceManager.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private ContainerLaunchContext createTaskExecutorLaunchContext(Resource resource, String containerId, String host) throws Exception { // init the ContainerLaunchContext final String currDir = env.get(ApplicationConstants.Environment.PWD.key()); final ContaineredTaskManagerParameters taskManagerParameters = ContaineredTaskManagerParameters.create(flinkConfig, resource.getMemory(), numberOfTaskSlots); log.debug("TaskExecutor {} will be started with container size {} MB, JVM heap size {} MB, " + "JVM direct memory limit {} MB", containerId, taskManagerParameters.taskManagerTotalMemoryMB(), taskManagerParameters.taskManagerHeapSizeMB(), taskManagerParameters.taskManagerDirectMemoryLimitMB()); Configuration taskManagerConfig = BootstrapTools.cloneConfiguration(flinkConfig); log.debug("TaskManager configuration: {}", taskManagerConfig); ContainerLaunchContext taskExecutorLaunchContext = Utils.createTaskExecutorContext( flinkConfig, yarnConfig, env, taskManagerParameters, taskManagerConfig, currDir, YarnTaskExecutorRunner.class, log); // set a special environment variable to uniquely identify this container taskExecutorLaunchContext.getEnvironment() .put(ENV_FLINK_CONTAINER_ID, containerId); taskExecutorLaunchContext.getEnvironment() .put(ENV_FLINK_NODE_ID, host); return taskExecutorLaunchContext; }
Example #22
Source File: YarnEntrypointUtilsTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Nonnull private static Configuration loadConfiguration(Configuration initialConfiguration) throws IOException { final File workingDirectory = TEMPORARY_FOLDER.newFolder(); final Map<String, String> env = new HashMap<>(4); env.put(ApplicationConstants.Environment.NM_HOST.key(), "foobar"); BootstrapTools.writeConfiguration(initialConfiguration, new File(workingDirectory, "flink-conf.yaml")); return YarnEntrypointUtils.loadConfiguration(workingDirectory.getAbsolutePath(), env, LOG); }
Example #23
Source File: ClusterClient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Creates a new ActorSystem or returns an existing one. * @return ActorSystem * @throws Exception if the ActorSystem could not be created */ @Override public ActorSystem get() throws FlinkException { if (!isLoaded()) { // start actor system log.info("Starting client actor system."); final InetAddress ownHostname; try { ownHostname = LeaderRetrievalUtils.findConnectingAddress( highAvailabilityServices.getJobManagerLeaderRetriever(HighAvailabilityServices.DEFAULT_JOB_ID), timeout); } catch (LeaderRetrievalException lre) { throw new FlinkException("Could not find out our own hostname by connecting to the " + "leading JobManager. Please make sure that the Flink cluster has been started.", lre); } try { actorSystem = BootstrapTools.startActorSystem( configuration, ownHostname.getCanonicalHostName(), 0, log); } catch (Exception e) { throw new FlinkException("Could not start the ActorSystem lazily.", e); } } return actorSystem; }
Example #24
Source File: MesosSessionClusterEntrypoint.java From flink with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // startup checks and logging EnvironmentInformation.logEnvironmentInfo(LOG, MesosSessionClusterEntrypoint.class.getSimpleName(), args); SignalHandler.register(LOG); JvmShutdownSafeguard.installAsShutdownHook(LOG); // load configuration incl. dynamic properties CommandLineParser parser = new PosixParser(); CommandLine cmd; try { cmd = parser.parse(ALL_OPTIONS, args); } catch (Exception e){ LOG.error("Could not parse the command-line options.", e); System.exit(STARTUP_FAILURE_RETURN_CODE); return; } Configuration dynamicProperties = BootstrapTools.parseDynamicProperties(cmd); Configuration configuration = MesosEntrypointUtils.loadConfiguration(dynamicProperties, LOG); MesosSessionClusterEntrypoint clusterEntrypoint = new MesosSessionClusterEntrypoint(configuration, dynamicProperties); ClusterEntrypoint.runClusterEntrypoint(clusterEntrypoint); }
Example #25
Source File: MesosEntrypointUtils.java From flink with Apache License 2.0 | 5 votes |
/** * Loads the global configuration, adds the given dynamic properties configuration, and sets * the temp directory paths. * * @param dynamicProperties dynamic properties to integrate * @param log logger instance * @return the loaded and adapted global configuration */ public static Configuration loadConfiguration(Configuration dynamicProperties, Logger log) { Configuration configuration = GlobalConfiguration.loadConfiguration(dynamicProperties); // read the environment variables final Map<String, String> envs = System.getenv(); final String tmpDirs = envs.get(MesosConfigKeys.ENV_FLINK_TMP_DIR); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, tmpDirs); return configuration; }
Example #26
Source File: YarnTaskExecutorRunner.java From flink with Apache License 2.0 | 5 votes |
@VisibleForTesting static void setupConfigurationAndInstallSecurityContext(Configuration configuration, String currDir, Map<String, String> variables) throws Exception { final String localDirs = variables.get(Environment.LOCAL_DIRS.key()); LOG.info("Current working/local Directory: {}", localDirs); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); setupConfigurationFromVariables(configuration, currDir, variables); installSecurityContext(configuration); }
Example #27
Source File: YarnResourceManager.java From flink with Apache License 2.0 | 5 votes |
private ContainerLaunchContext createTaskExecutorLaunchContext(Resource resource, String containerId, String host) throws Exception { // init the ContainerLaunchContext final String currDir = env.get(ApplicationConstants.Environment.PWD.key()); final ContaineredTaskManagerParameters taskManagerParameters = ContaineredTaskManagerParameters.create(flinkConfig, resource.getMemory(), numberOfTaskSlots); log.debug("TaskExecutor {} will be started with container size {} MB, JVM heap size {} MB, " + "JVM direct memory limit {} MB", containerId, taskManagerParameters.taskManagerTotalMemoryMB(), taskManagerParameters.taskManagerHeapSizeMB(), taskManagerParameters.taskManagerDirectMemoryLimitMB()); Configuration taskManagerConfig = BootstrapTools.cloneConfiguration(flinkConfig); log.debug("TaskManager configuration: {}", taskManagerConfig); ContainerLaunchContext taskExecutorLaunchContext = Utils.createTaskExecutorContext( flinkConfig, yarnConfig, env, taskManagerParameters, taskManagerConfig, currDir, YarnTaskExecutorRunner.class, log); // set a special environment variable to uniquely identify this container taskExecutorLaunchContext.getEnvironment() .put(ENV_FLINK_CONTAINER_ID, containerId); taskExecutorLaunchContext.getEnvironment() .put(ENV_FLINK_NODE_ID, host); return taskExecutorLaunchContext; }
Example #28
Source File: KubernetesUtils.java From flink with Apache License 2.0 | 4 votes |
public static String getCommonStartCommand( Configuration flinkConfig, ClusterComponent mode, String jvmMemOpts, String configDirectory, String logDirectory, boolean hasLogback, boolean hasLog4j, String mainClass, @Nullable String mainArgs) { final Map<String, String> startCommandValues = new HashMap<>(); startCommandValues.put("java", "$JAVA_HOME/bin/java"); startCommandValues.put("classpath", "-classpath " + "$" + Constants.ENV_FLINK_CLASSPATH); startCommandValues.put("jvmmem", jvmMemOpts); final String opts; final String logFileName; if (mode == ClusterComponent.JOB_MANAGER) { opts = getJavaOpts(flinkConfig, CoreOptions.FLINK_JM_JVM_OPTIONS); logFileName = "jobmanager"; } else { opts = getJavaOpts(flinkConfig, CoreOptions.FLINK_TM_JVM_OPTIONS); logFileName = "taskmanager"; } startCommandValues.put("jvmopts", opts); startCommandValues.put("logging", getLogging(logDirectory + "/" + logFileName + ".log", configDirectory, hasLogback, hasLog4j)); startCommandValues.put("class", mainClass); startCommandValues.put("args", mainArgs != null ? mainArgs : ""); startCommandValues.put("redirects", "1> " + logDirectory + "/" + logFileName + ".out " + "2> " + logDirectory + "/" + logFileName + ".err"); final String commandTemplate = flinkConfig.getString(KubernetesConfigOptions.CONTAINER_START_COMMAND_TEMPLATE); return BootstrapTools.getStartCommand(commandTemplate, startCommandValues); }
Example #29
Source File: KubernetesTestBase.java From flink with Apache License 2.0 | 4 votes |
protected void writeFlinkConfiguration() throws IOException { BootstrapTools.writeConfiguration(this.flinkConfig, new File(flinkConfDir, "flink-conf.yaml")); }
Example #30
Source File: AbstractYarnClusterDescriptor.java From flink with Apache License 2.0 | 4 votes |
protected ContainerLaunchContext setupApplicationMasterContainer( String yarnClusterEntrypoint, boolean hasLogback, boolean hasLog4j, boolean hasKrb5, int jobManagerMemoryMb) { // ------------------ Prepare Application Master Container ------------------------------ // respect custom JVM options in the YAML file String javaOpts = flinkConfiguration.getString(CoreOptions.FLINK_JVM_OPTIONS); if (flinkConfiguration.getString(CoreOptions.FLINK_JM_JVM_OPTIONS).length() > 0) { javaOpts += " " + flinkConfiguration.getString(CoreOptions.FLINK_JM_JVM_OPTIONS); } //applicable only for YarnMiniCluster secure test run //krb5.conf file will be available as local resource in JM/TM container if (hasKrb5) { javaOpts += " -Djava.security.krb5.conf=krb5.conf"; } // Set up the container launch context for the application master ContainerLaunchContext amContainer = Records.newRecord(ContainerLaunchContext.class); final Map<String, String> startCommandValues = new HashMap<>(); startCommandValues.put("java", "$JAVA_HOME/bin/java"); int heapSize = Utils.calculateHeapSize(jobManagerMemoryMb, flinkConfiguration); String jvmHeapMem = String.format("-Xms%sm -Xmx%sm", heapSize, heapSize); startCommandValues.put("jvmmem", jvmHeapMem); startCommandValues.put("jvmopts", javaOpts); String logging = ""; if (hasLogback || hasLog4j) { logging = "-Dlog.file=\"" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/jobmanager.log\""; if (hasLogback) { logging += " -Dlogback.configurationFile=file:" + CONFIG_FILE_LOGBACK_NAME; } if (hasLog4j) { logging += " -Dlog4j.configuration=file:" + CONFIG_FILE_LOG4J_NAME; } } startCommandValues.put("logging", logging); startCommandValues.put("class", yarnClusterEntrypoint); startCommandValues.put("redirects", "1> " + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/jobmanager.out " + "2> " + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/jobmanager.err"); startCommandValues.put("args", ""); final String commandTemplate = flinkConfiguration .getString(ConfigConstants.YARN_CONTAINER_START_COMMAND_TEMPLATE, ConfigConstants.DEFAULT_YARN_CONTAINER_START_COMMAND_TEMPLATE); final String amCommand = BootstrapTools.getStartCommand(commandTemplate, startCommandValues); amContainer.setCommands(Collections.singletonList(amCommand)); LOG.debug("Application Master start command: " + amCommand); return amContainer; }