@Test public void testRestPortSpecified() throws IOException { final Configuration initialConfiguration = new Configuration(); final int port = 1337; initialConfiguration.setInteger(RestOptions.PORT, port); final Configuration configuration = loadConfiguration(initialConfiguration); assertThat(configuration.getString(RestOptions.BIND_PORT), is(equalTo(String.valueOf(port)))); }
public static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log) { Configuration configuration = GlobalConfiguration.loadConfiguration(workingDirectory); final String remoteKeytabPrincipal = env.get(YarnConfigKeys.KEYTAB_PRINCIPAL); final String zooKeeperNamespace = env.get(YarnConfigKeys.ENV_ZOOKEEPER_NAMESPACE); final Map<String, String> dynamicProperties = FlinkYarnSessionCli.getDynamicProperties( env.get(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES)); final String hostname = env.get(ApplicationConstants.Environment.NM_HOST.key()); Preconditions.checkState( hostname != null, "ApplicationMaster hostname variable %s not set", ApplicationConstants.Environment.NM_HOST.key()); configuration.setString(JobManagerOptions.ADDRESS, hostname); configuration.setString(RestOptions.ADDRESS, hostname); for (Map.Entry<String, String> property : dynamicProperties.entrySet()) { configuration.setString(property.getKey(), property.getValue()); } if (zooKeeperNamespace != null) { configuration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zooKeeperNamespace); } if (configuration.getInteger(WebOptions.PORT, 0) >= 0) { configuration.setInteger(WebOptions.PORT, 0); } if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_APPLICATION_MASTER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_MASTER_ENV_PREFIX); BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_TASK_MANAGER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX); final String keytabPath; if (env.get(YarnConfigKeys.KEYTAB_PATH) == null) { keytabPath = null; } else { File f = new File(workingDirectory, Utils.KEYTAB_FILE_NAME); keytabPath = f.getAbsolutePath(); } if (keytabPath != null && remoteKeytabPrincipal != null) { configuration.setString(SecurityOptions.KERBEROS_LOGIN_KEYTAB, keytabPath); configuration.setString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL, remoteKeytabPrincipal); } final String localDirs = env.get(ApplicationConstants.Environment.LOCAL_DIRS.key()); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); return configuration; }
YarnEntrypointUtils { public static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log) { Configuration configuration = GlobalConfiguration.loadConfiguration(workingDirectory); final String remoteKeytabPrincipal = env.get(YarnConfigKeys.KEYTAB_PRINCIPAL); final String zooKeeperNamespace = env.get(YarnConfigKeys.ENV_ZOOKEEPER_NAMESPACE); final Map<String, String> dynamicProperties = FlinkYarnSessionCli.getDynamicProperties( env.get(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES)); final String hostname = env.get(ApplicationConstants.Environment.NM_HOST.key()); Preconditions.checkState( hostname != null, "ApplicationMaster hostname variable %s not set", ApplicationConstants.Environment.NM_HOST.key()); configuration.setString(JobManagerOptions.ADDRESS, hostname); configuration.setString(RestOptions.ADDRESS, hostname); for (Map.Entry<String, String> property : dynamicProperties.entrySet()) { configuration.setString(property.getKey(), property.getValue()); } if (zooKeeperNamespace != null) { configuration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zooKeeperNamespace); } if (configuration.getInteger(WebOptions.PORT, 0) >= 0) { configuration.setInteger(WebOptions.PORT, 0); } if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_APPLICATION_MASTER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_MASTER_ENV_PREFIX); BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_TASK_MANAGER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX); final String keytabPath; if (env.get(YarnConfigKeys.KEYTAB_PATH) == null) { keytabPath = null; } else { File f = new File(workingDirectory, Utils.KEYTAB_FILE_NAME); keytabPath = f.getAbsolutePath(); } if (keytabPath != null && remoteKeytabPrincipal != null) { configuration.setString(SecurityOptions.KERBEROS_LOGIN_KEYTAB, keytabPath); configuration.setString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL, remoteKeytabPrincipal); } final String localDirs = env.get(ApplicationConstants.Environment.LOCAL_DIRS.key()); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); return configuration; } }
YarnEntrypointUtils { public static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log) { Configuration configuration = GlobalConfiguration.loadConfiguration(workingDirectory); final String remoteKeytabPrincipal = env.get(YarnConfigKeys.KEYTAB_PRINCIPAL); final String zooKeeperNamespace = env.get(YarnConfigKeys.ENV_ZOOKEEPER_NAMESPACE); final Map<String, String> dynamicProperties = FlinkYarnSessionCli.getDynamicProperties( env.get(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES)); final String hostname = env.get(ApplicationConstants.Environment.NM_HOST.key()); Preconditions.checkState( hostname != null, "ApplicationMaster hostname variable %s not set", ApplicationConstants.Environment.NM_HOST.key()); configuration.setString(JobManagerOptions.ADDRESS, hostname); configuration.setString(RestOptions.ADDRESS, hostname); for (Map.Entry<String, String> property : dynamicProperties.entrySet()) { configuration.setString(property.getKey(), property.getValue()); } if (zooKeeperNamespace != null) { configuration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zooKeeperNamespace); } if (configuration.getInteger(WebOptions.PORT, 0) >= 0) { configuration.setInteger(WebOptions.PORT, 0); } if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_APPLICATION_MASTER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_MASTER_ENV_PREFIX); BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_TASK_MANAGER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX); final String keytabPath; if (env.get(YarnConfigKeys.KEYTAB_PATH) == null) { keytabPath = null; } else { File f = new File(workingDirectory, Utils.KEYTAB_FILE_NAME); keytabPath = f.getAbsolutePath(); } if (keytabPath != null && remoteKeytabPrincipal != null) { configuration.setString(SecurityOptions.KERBEROS_LOGIN_KEYTAB, keytabPath); configuration.setString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL, remoteKeytabPrincipal); } final String localDirs = env.get(ApplicationConstants.Environment.LOCAL_DIRS.key()); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); return configuration; }  }
YarnEntrypointUtils { public static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log) { Configuration configuration = GlobalConfiguration.loadConfiguration(workingDirectory); final String remoteKeytabPrincipal = env.get(YarnConfigKeys.KEYTAB_PRINCIPAL); final String zooKeeperNamespace = env.get(YarnConfigKeys.ENV_ZOOKEEPER_NAMESPACE); final Map<String, String> dynamicProperties = FlinkYarnSessionCli.getDynamicProperties( env.get(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES)); final String hostname = env.get(ApplicationConstants.Environment.NM_HOST.key()); Preconditions.checkState( hostname != null, "ApplicationMaster hostname variable %s not set", ApplicationConstants.Environment.NM_HOST.key()); configuration.setString(JobManagerOptions.ADDRESS, hostname); configuration.setString(RestOptions.ADDRESS, hostname); for (Map.Entry<String, String> property : dynamicProperties.entrySet()) { configuration.setString(property.getKey(), property.getValue()); } if (zooKeeperNamespace != null) { configuration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zooKeeperNamespace); } if (configuration.getInteger(WebOptions.PORT, 0) >= 0) { configuration.setInteger(WebOptions.PORT, 0); } if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_APPLICATION_MASTER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_MASTER_ENV_PREFIX); BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_TASK_MANAGER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX); final String keytabPath; if (env.get(YarnConfigKeys.KEYTAB_PATH) == null) { keytabPath = null; } else { File f = new File(workingDirectory, Utils.KEYTAB_FILE_NAME); keytabPath = f.getAbsolutePath(); } if (keytabPath != null && remoteKeytabPrincipal != null) { configuration.setString(SecurityOptions.KERBEROS_LOGIN_KEYTAB, keytabPath); configuration.setString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL, remoteKeytabPrincipal); } final String localDirs = env.get(ApplicationConstants.Environment.LOCAL_DIRS.key()); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); return configuration; }  static SecurityContext installSecurityContext(
			Configuration configuration,
			String workingDirectory); static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log); static void logYarnEnvironmentInformation(Map<String, String> env, Logger log); }
YarnEntrypointUtils { public static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log) { Configuration configuration = GlobalConfiguration.loadConfiguration(workingDirectory); final String remoteKeytabPrincipal = env.get(YarnConfigKeys.KEYTAB_PRINCIPAL); final String zooKeeperNamespace = env.get(YarnConfigKeys.ENV_ZOOKEEPER_NAMESPACE); final Map<String, String> dynamicProperties = FlinkYarnSessionCli.getDynamicProperties( env.get(YarnConfigKeys.ENV_DYNAMIC_PROPERTIES)); final String hostname = env.get(ApplicationConstants.Environment.NM_HOST.key()); Preconditions.checkState( hostname != null, "ApplicationMaster hostname variable %s not set", ApplicationConstants.Environment.NM_HOST.key()); configuration.setString(JobManagerOptions.ADDRESS, hostname); configuration.setString(RestOptions.ADDRESS, hostname); for (Map.Entry<String, String> property : dynamicProperties.entrySet()) { configuration.setString(property.getKey(), property.getValue()); } if (zooKeeperNamespace != null) { configuration.setString(HighAvailabilityOptions.HA_CLUSTER_ID, zooKeeperNamespace); } if (configuration.getInteger(WebOptions.PORT, 0) >= 0) { configuration.setInteger(WebOptions.PORT, 0); } if (!configuration.contains(RestOptions.BIND_PORT)) { configuration.setString(RestOptions.BIND_PORT, "0"); } BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_APPLICATION_MASTER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_MASTER_ENV_PREFIX); BootstrapTools.substituteDeprecatedConfigPrefix(configuration, ConfigConstants.YARN_TASK_MANAGER_ENV_PREFIX, ResourceManagerOptions.CONTAINERIZED_TASK_MANAGER_ENV_PREFIX); final String keytabPath; if (env.get(YarnConfigKeys.KEYTAB_PATH) == null) { keytabPath = null; } else { File f = new File(workingDirectory, Utils.KEYTAB_FILE_NAME); keytabPath = f.getAbsolutePath(); } if (keytabPath != null && remoteKeytabPrincipal != null) { configuration.setString(SecurityOptions.KERBEROS_LOGIN_KEYTAB, keytabPath); configuration.setString(SecurityOptions.KERBEROS_LOGIN_PRINCIPAL, remoteKeytabPrincipal); } final String localDirs = env.get(ApplicationConstants.Environment.LOCAL_DIRS.key()); BootstrapTools.updateTmpDirectoriesInConfiguration(configuration, localDirs); return configuration; }  static SecurityContext installSecurityContext(
			Configuration configuration,
			String workingDirectory); static Configuration loadConfiguration(String workingDirectory, Map<String, String> env, Logger log); static void logYarnEnvironmentInformation(Map<String, String> env, Logger log);  }