/** * Set an entire map full of values * * @param config config to patch * @param map map of data * @param origin origin data */ public static void addConfigMap(Configuration config, Map<String, String> map, String origin) throws BadConfigException { addConfigMap(config, map.entrySet(), origin); }
/** * Add a configuration from a file to an existing configuration * @param conf existing configuration * @param file file to load * @param overwrite flag to indicate new values should overwrite the predecessor * @return the merged configuration * @throws IOException */ public static Configuration addConfigurationFile(Configuration conf, File file, boolean overwrite) throws IOException { Configuration c2 = loadConfFromFile(file, false); mergeConfigurations(conf, c2, file.getAbsolutePath(), overwrite); return conf; }
/** * looks for the config under $confdir/$templateFilename; if not there * loads it from /conf/templateFile. * The property {@link SliderKeys#KEY_TEMPLATE_ORIGIN} is set to the * origin to help debug what's happening * @param systemConf system conf * @param confdir conf dir in FS * @param templateFilename filename in the confdir * @param fallbackResource resource to fall back on * @return loaded conf * @throws IOException IO problems */ public static Configuration loadTemplateConfiguration(Configuration systemConf, Path confdir, String templateFilename, String fallbackResource) throws IOException { FileSystem fs = FileSystem.get(confdir.toUri(), systemConf); Path templatePath = new Path(confdir, templateFilename); return loadTemplateConfiguration(fs, templatePath, fallbackResource); }
Configuration siteConf = ConfigHelper.loadTemplateConfiguration( serviceConf, snapshotConfDirPath, log.debug("Configuration came from {}", siteConf.get(SliderXmlConfKeys.KEY_TEMPLATE_ORIGIN)); ConfigHelper.dumpConf(siteConf); ConfigHelper.addConfigMap(siteConf, clusterConfMap.entrySet(), "HBase Provider"); ConfigHelper.mergeConfigurations(siteConf, clientConfExtras, "Slider Client", true); ConfigHelper.dumpConf(siteConf); Path sitePath = ConfigHelper.saveConfig(serviceConf, siteConf, generatedConfDirPath,
URL serverXmlUrl = ConfigHelper.getResourceUrl(SLIDER_SERVER_XML); if (serverXmlUrl != null) { log.info("Loading {} at {}", SLIDER_SERVER_XML, serverXmlUrl); Configuration serverConf = ConfigHelper.loadFromResource(SLIDER_SERVER_XML); ConfigHelper.mergeConfigurations(customConf, serverConf, SLIDER_SERVER_XML, true); ConfigHelper.dumpConfigToString(customConf)); for (Map.Entry<String, String> envs : System.getenv().entrySet()) { log.info("System env {}={}", envs.getKey(), envs.getValue()); ConfigHelper.mergeConfigurations(conf, customConf, SLIDER_CLIENT_XML, true);
/** * Load a specific XML configuration file for the provider config * @param confDir configuration directory * @param siteXMLFilename provider-specific filename * @return a configuration to be included in status * @throws BadCommandArgumentsException argument problems * @throws IOException IO problems */ protected Configuration loadProviderConfigurationInformation(File confDir, String siteXMLFilename) throws BadCommandArgumentsException, IOException { Configuration siteConf; File siteXML = new File(confDir, siteXMLFilename); if (!siteXML.exists()) { throw new BadCommandArgumentsException( "Configuration directory %s doesn't contain %s - listing is %s", confDir, siteXMLFilename, SliderUtils.listDir(confDir)); } //now read it in siteConf = ConfigHelper.loadConfFromFile(siteXML); log.info("{} file is at {}", siteXMLFilename, siteXML); log.info(ConfigHelper.dumpConfigToString(siteConf)); return siteConf; }
/** * Load a Hadoop configuration from a local file. * @param file file to load * @return a configuration which hasn't actually had the load triggered * yet. * @throws FileNotFoundException file is not there * @throws IOException any other IO problem */ public static Configuration loadConfFromFile(File file) throws IOException { return loadConfFromFile(file, false); }
@Override protected void serviceInit(Configuration conf) throws Exception { Configuration clientConf = loadSliderClientXML(); ConfigHelper.mergeConfigurations(conf, clientConf, SLIDER_CLIENT_XML, true); serviceArgs.applyDefinitions(conf); serviceArgs.applyFileSystemBinding(conf); AbstractActionArgs coreAction = serviceArgs.getCoreAction(); // init security with our conf if (!coreAction.disableSecureLogin() && isHadoopClusterSecure(conf)) { forceLogin(); initProcessSecurity(conf); } if (coreAction.getHadoopServicesRequired()) { initHadoopBinding(); } super.serviceInit(conf); }
/** * Save a config file in a destination directory on a given filesystem * @param systemConf system conf used for creating filesystems * @param confToSave config to save * @param confdir the directory path where the file is to go * @param filename the filename * @return the destination path where the file was saved * @throws IOException IO problems */ public static Path saveConfig(Configuration systemConf, Configuration confToSave, Path confdir, String filename) throws IOException { FileSystem fs = FileSystem.get(confdir.toUri(), systemConf); Path destPath = new Path(confdir, filename); saveConfig(fs, destPath, confToSave); return destPath; }
Set<String> envList = ConfigHelper.sortedConfigKeys(env.entrySet()); StringBuilder builder = new StringBuilder("Environment variables:\n"); for (String key : envList) { println("Slider client configuration:\n" + ConfigHelper.dumpConfigToString(config));
if (fs.exists(templatePath)) { log.debug("Loading template configuration {}", templatePath); conf = loadConfiguration(fs, templatePath); origin = templatePath.toString(); } else {
/** * Load a configuration from a resource on this classpath. * If the resource is not found, an empty configuration is returned * @param resource the resource name * @return the loaded configuration. */ public static Configuration loadFromResource(String resource) { Configuration conf = new Configuration(false); URL resURL = getResourceUrl(resource); if (resURL != null) { log.debug("loaded resources from {}", resURL); conf.addResource(resource); } else{ log.debug("failed to find {} on the classpath", resource); } return conf; }
log.info(ConfigHelper.dumpConfigToString(siteConf)); throw e;
Configuration siteConf = ConfigHelper.loadTemplateConfiguration( serviceConf, snapshotConfDirPath, ConfigHelper.addConfigMap(siteConf, clusterConfMap.entrySet(), "Accumulo Provider"); ConfigHelper.mergeConfigurations(siteConf, clientConfExtras, "Slider Client", true); ConfigHelper.dumpConf(siteConf); Path sitePath = ConfigHelper.saveConfig(serviceConf, siteConf, generatedConfDirPath,
URL serverXmlUrl = ConfigHelper.getResourceUrl(SLIDER_SERVER_XML); if (serverXmlUrl != null) { log.info("Loading {} at {}", SLIDER_SERVER_XML, serverXmlUrl); Configuration serverConf = ConfigHelper.loadFromResource(SLIDER_SERVER_XML); ConfigHelper.mergeConfigurations(customConf, serverConf, SLIDER_SERVER_XML, true); ConfigHelper.dumpConfigToString(customConf)); for (Map.Entry<String, String> envs : System.getenv().entrySet()) { log.info("System env {}={}", envs.getKey(), envs.getValue()); ConfigHelper.mergeConfigurations(conf, customConf, SLIDER_CLIENT_XML, true);
/** * Load a specific XML configuration file for the provider config * @param confDir configuration directory * @param siteXMLFilename provider-specific filename * @return a configuration to be included in status * @throws BadCommandArgumentsException argument problems * @throws IOException IO problems */ protected Configuration loadProviderConfigurationInformation(File confDir, String siteXMLFilename) throws BadCommandArgumentsException, IOException { Configuration siteConf; File siteXML = new File(confDir, siteXMLFilename); if (!siteXML.exists()) { throw new BadCommandArgumentsException( "Configuration directory %s doesn't contain %s - listing is %s", confDir, siteXMLFilename, SliderUtils.listDir(confDir)); } //now read it in siteConf = ConfigHelper.loadConfFromFile(siteXML); log.info("{} file is at {}", siteXMLFilename, siteXML); log.info(ConfigHelper.dumpConfigToString(siteConf)); return siteConf; }
/** * Load a Hadoop configuration from a local file. * @param file file to load * @return a configuration which hasn't actually had the load triggered * yet. * @throws FileNotFoundException file is not there * @throws IOException any other IO problem */ public static Configuration loadConfFromFile(File file) throws IOException { return loadConfFromFile(file, false); }
@Override protected void serviceInit(Configuration conf) throws Exception { Configuration clientConf = loadSliderClientXML(); ConfigHelper.mergeConfigurations(conf, clientConf, SLIDER_CLIENT_XML, true); serviceArgs.applyDefinitions(conf); serviceArgs.applyFileSystemBinding(conf); AbstractActionArgs coreAction = serviceArgs.getCoreAction(); // init security with our conf if (!coreAction.disableSecureLogin() && isHadoopClusterSecure(conf)) { forceLogin(); initProcessSecurity(conf); } if (coreAction.getHadoopServicesRequired()) { initHadoopBinding(); } super.serviceInit(conf); }
/** * Save a config file in a destination directory on a given filesystem * @param systemConf system conf used for creating filesystems * @param confToSave config to save * @param confdir the directory path where the file is to go * @param filename the filename * @return the destination path where the file was saved * @throws IOException IO problems */ public static Path saveConfig(Configuration systemConf, Configuration confToSave, Path confdir, String filename) throws IOException { FileSystem fs = FileSystem.get(confdir.toUri(), systemConf); Path destPath = new Path(confdir, filename); saveConfig(fs, destPath, confToSave); return destPath; }
Set<String> envList = ConfigHelper.sortedConfigKeys(env.entrySet()); StringBuilder builder = new StringBuilder("Environment variables:\n"); for (String key : envList) { println("Slider client configuration:\n" + ConfigHelper.dumpConfigToString(config));