public AbstractYarnClusterDescriptor() { // for unit tests only if (System.getenv("IN_TESTS") != null) { try { conf.addResource(new File(System.getenv("YARN_CONF_DIR") + "/yarn-site.xml").toURI().toURL()); } catch (Throwable t) { throw new RuntimeException("Error", t); } } // tries to load the config through the environment, if it fails it can //still be set through the setters try { this.configurationDirectory = CliFrontend. getConfigurationDirectoryFromEnv(); GlobalConfiguration.loadConfiguration(configurationDirectory); this.flinkConfiguration = GlobalConfiguration.getConfiguration(); File confFile = new File(configurationDirectory + File.separator + CONFIG_FILE_NAME); if (!confFile.exists()) { throw new RuntimeException("Unable to locate configuration file in " + confFile); } flinkConfigurationPath = new Path(confFile.getAbsolutePath()); } catch (Exception e) { LOG.debug("Config couldn't be loaded from environment variable."); } }
public FlinkPlanner(List<String> classPath) { super(); this.classPath = classPath; env.getConfig().disableSysoutLogging(); if (env.getParallelism() <= 0) { // load the default parallelism from config GlobalConfiguration.loadConfiguration(new File(CliFrontend.getConfigurationDirectoryFromEnv()).getAbsolutePath()); org.apache.flink.configuration.Configuration configuration = GlobalConfiguration.getConfiguration(); int parallelism = configuration.getInteger(ConfigConstants.DEFAULT_PARALLELISM_KEY, -1); if (parallelism <= 0) { throw new RuntimeException("Please set the default parallelism via the -p command-line flag"); } else { env.setParallelism(parallelism); } } }