public static float getConfiguredLoadValue(@SuppressWarnings("rawtypes") Dictionary bundleProperties, String configKey, Float defaultValue, ServiceRegistry registry) { String jobLoad = StringUtils.trimToNull((String) bundleProperties.get(configKey)); float loadValue = defaultValue; if (jobLoad != null) { try { loadValue = Float.parseFloat(jobLoad); if (loadValue < 0) { logger.warn("Load value for key {} set to less than 0, defaulting to 0", configKey); loadValue = 0.0f; } logger.info("Set load for key {} to {}", configKey, loadValue); } catch (NumberFormatException e) { logger.warn("Can not set job loads to {}. {} must be a float", jobLoad, configKey); loadValue = defaultValue; logger.info("Set load for key {} to default of {}", configKey, loadValue); } } else { logger.info("No job load configuration found for key {}, load to default of {}", configKey, loadValue); } try { checkJobFitsCluster(loadValue, configKey, registry.getHostRegistrations()); } catch (ServiceRegistryException e) { logger.warn("Unable to verify that {} will run on this cluster due to load of {}", configKey, loadValue); } return loadValue; }
@GET @Path("hosts.xml") @Produces(MediaType.TEXT_XML) @RestQuery(name = "hostsasxml", description = "Returns a host registraton or list of available host registrations as XML.", returnDescription = "The host list as XML", reponses = { @RestResponse(responseCode = SC_OK, description = "Returned the available hosts.") }) public JaxbHostRegistrationList getHostsAsXml() throws NotFoundException { JaxbHostRegistrationList registrations = new JaxbHostRegistrationList(); try { for (HostRegistration reg : serviceRegistry.getHostRegistrations()) registrations.add(new JaxbHostRegistration(reg)); return registrations; } catch (ServiceRegistryException e) { throw new WebApplicationException(e); } }