public PublishedConfigSet shallowCopy() { PublishedConfigSet that = new PublishedConfigSet(); for (Map.Entry<String, PublishedConfiguration> entry : configurations.entrySet()) { that.put(entry.getKey(), entry.getValue().shallowCopy()); } return that; } }
/** * Get a configuration * @param setname name of the config set * @param config config * @return null if there was a config, but not a set * @throws NotFoundException if there was no matching set */ public PublishedConfiguration getPublishedConfiguration(String setname, String config) { return getConfigSet(setname).get(config); }
@GET @Path("/"+ SETNAME_PATTERN) @Produces({MediaType.APPLICATION_JSON}) public PublishedConfigSet getPublishedConfiguration( @PathParam(SETNAME) String setname, @Context UriInfo uriInfo, @Context HttpServletResponse res) { init(res, uriInfo); logRequest(uriInfo); PublishedConfigSet publishedConfigSet = getConfigSet(setname); log.debug("Number of configurations: {}", publishedConfigSet.size()); return publishedConfigSet.shallowCopy(); }
/** * Publish a named property bag that may contain name-value pairs for app configurations such as hbase-site * * @param name * @param description * @param entries */ protected void publishApplicationInstanceData(String name, String description, Iterable<Map.Entry<String, String>> entries) { PublishedConfiguration pubconf = new PublishedConfiguration(); pubconf.description = description; pubconf.putValues(entries); log.info("publishing {}", pubconf); getAmState().getPublishedSliderConfigurations().put(name, pubconf); }
/** * Put a name -it will be converted to lower case before insertion. * Any existing entry will be overwritten (that includes an entry * with a different case in the original name) * @param name name of entry * @param conf configuration * @throws IllegalArgumentException if not a valid name */ public void put(String name, PublishedConfiguration conf) { String name1 = name.toLowerCase(Locale.ENGLISH); validateName(name1); configurations.put(name1, conf); }
@Override public PublishedConfigSet getOrCreatePublishedConfigSet(String name) { PublishedConfigSet set = publishedConfigSets.get(name); if (set == null) { validator.validate(name); synchronized (publishedConfigSets) { // synchronized double check to ensure that there is never an overridden // config set created set = publishedConfigSets.get(name); if (set == null) { set = new PublishedConfigSet(); publishedConfigSets.put(name, set); } } } return set; }
/** * Get a complete configuration, with all values * @param configSet config set to ask for * @param name name of the configuration * @param external flag to indicate that it is an external configuration * @return the retrieved config * @throws IOException IO problems */ public PublishedConfiguration retrieveConfiguration(PublishedConfigSet configSet, String name, boolean external) throws IOException { String confURL = getConfigurationURL(external); if (!configSet.contains(name)) { throw new FileNotFoundException("Unknown configuration " + name); } confURL = SliderUtils.appendToURL(confURL, name); WebResource webResource = resource(confURL); return get(webResource, PublishedConfiguration.class); }
/** * Publish a named property bag that may contain name-value pairs for app configurations such as hbase-site * * @param name * @param description * @param entries */ protected void publishApplicationInstanceData(String name, String description, Iterable<Map.Entry<String, String>> entries) { PublishedConfiguration pubconf = new PublishedConfiguration(); pubconf.description = description; pubconf.putValues(entries); log.info("publishing {}", pubconf); getAmState().getPublishedSliderConfigurations().put(name, pubconf); }
/** * Put a name -it will be converted to lower case before insertion. * Any existing entry will be overwritten (that includes an entry * with a different case in the original name) * @param name name of entry * @param conf configuration * @throws IllegalArgumentException if not a valid name */ public void put(String name, PublishedConfiguration conf) { String name1 = name.toLowerCase(Locale.ENGLISH); validateName(name1); configurations.put(name1, conf); }
@Override public PublishedConfigSet getOrCreatePublishedConfigSet(String name) { PublishedConfigSet set = publishedConfigSets.get(name); if (set == null) { validator.validate(name); synchronized (publishedConfigSets) { // synchronized double check to ensure that there is never an overridden // config set created set = publishedConfigSets.get(name); if (set == null) { set = new PublishedConfigSet(); publishedConfigSets.put(name, set); } } } return set; }
/** * Get a complete configuration, with all values * @param configSet config set to ask for * @param name name of the configuration * @param external flag to indicate that it is an external configuration * @return the retrieved config * @throws IOException IO problems */ public PublishedConfiguration retrieveConfiguration(PublishedConfigSet configSet, String name, boolean external) throws IOException { String confURL = getConfigurationURL(external); if (!configSet.contains(name)) { throw new FileNotFoundException("Unknown configuration " + name); } confURL = SliderUtils.appendToURL(confURL, name); WebResource webResource = resource(confURL); return get(webResource, PublishedConfiguration.class); }
private void registerHBaseServiceEntry() throws IOException { String name = amState.getApplicationName() ; ServiceRecord serviceRecord = new ServiceRecord(); // bond lifespan to the application serviceRecord.set(YarnRegistryAttributes.YARN_ID, yarnRegistry.getApplicationAttemptId() .getApplicationId().toString()); serviceRecord.set(YarnRegistryAttributes.YARN_PERSISTENCE, PersistencePolicies.APPLICATION); try { URL configURL = new URL(amWebAPI, SLIDER_PATH_PUBLISHER + "/" + HBASE_SERVICE_TYPE); serviceRecord.addExternalEndpoint( RegistryTypeUtils.restEndpoint( CustomRegistryConstants.PUBLISHER_CONFIGURATIONS_API, configURL.toURI())); } catch (URISyntaxException e) { log.warn("failed to create config URL: {}", e, e); } log.info("registering {}/{}", name, HBASE_SERVICE_TYPE); yarnRegistry.putService(HBASE_SERVICE_TYPE, name, serviceRecord, true); PublishedConfiguration publishedSite = new PublishedConfiguration("HBase site", siteConf); PublishedConfigSet configSet = amState.getOrCreatePublishedConfigSet(HBASE_SERVICE_TYPE); configSet.put(HBASE_SITE_PUBLISHED_CONFIG, publishedSite); }
public PublishedConfigSet shallowCopy() { PublishedConfigSet that = new PublishedConfigSet(); for (Map.Entry<String, PublishedConfiguration> entry : configurations.entrySet()) { that.put(entry.getKey(), entry.getValue().shallowCopy()); } return that; } }
@GET @Path("/"+ SETNAME_PATTERN) @Produces({MediaType.APPLICATION_JSON}) public PublishedConfigSet getPublishedConfiguration( @PathParam(SETNAME) String setname, @Context UriInfo uriInfo, @Context HttpServletResponse res) { init(res, uriInfo); logRequest(uriInfo); PublishedConfigSet publishedConfigSet = getConfigSet(setname); log.debug("Number of configurations: {}", publishedConfigSet.size()); return publishedConfigSet.shallowCopy(); }
/** * Get a configuration * @param setname name of the config set * @param config config * @return null if there was a config, but not a set * @throws NotFoundException if there was no matching set */ public PublishedConfiguration getPublishedConfiguration(String setname, String config) { return getConfigSet(setname).get(config); }
amState.getPublishedSliderConfigurations().put( PublishedArtifacts.COMPLETE_CONFIG, new PublishedConfiguration( "Complete slider application settings", getConfig(), getConfig())); amState.getPublishedSliderConfigurations().put( PublishedArtifacts.YARN_SITE_CONFIG, new PublishedConfiguration( defaultYarnConfig) ); amState.getPublishedSliderConfigurations().put( PublishedArtifacts.CORE_SITE_CONFIG, new PublishedConfiguration( ConfigHelper.loadFromResource("core-site.xml"), defaultYarnConfig) ); amState.getPublishedSliderConfigurations().put( PublishedArtifacts.HDFS_SITE_CONFIG, new PublishedConfiguration(
amState.getPublishedSliderConfigurations().put( PublishedArtifacts.COMPLETE_CONFIG, new PublishedConfiguration( "Complete slider application settings", getConfig(), getConfig())); amState.getPublishedSliderConfigurations().put( PublishedArtifacts.YARN_SITE_CONFIG, new PublishedConfiguration( defaultYarnConfig) ); amState.getPublishedSliderConfigurations().put( PublishedArtifacts.CORE_SITE_CONFIG, new PublishedConfiguration( ConfigHelper.loadFromResource("core-site.xml"), defaultYarnConfig) ); amState.getPublishedSliderConfigurations().put( PublishedArtifacts.HDFS_SITE_CONFIG, new PublishedConfiguration(
new PublishedConfiguration(configFile.getDictionaryName(), config.entrySet()); getAmState().getPublishedSliderConfigurations().put( configFile.getDictionaryName(), publishedConfiguration); log.info("Publishing AM configuration {}", configFile.getDictionaryName());