use of com.hubspot.singularity.runner.base.configuration.Configuration in project Singularity by HubSpot.
the class SingularityRunnerBaseLogging method printProperties.
public void printProperties() {
for (BaseRunnerConfiguration configuration : configurations) {
try {
final Configuration annotation = configuration.getClass().getAnnotation(Configuration.class);
final String filename = consolidatedConfigFilename.or(annotation == null ? "(unknown)" : annotation.filename());
LOG.trace(String.format("Loaded %s from %s:%n%s", configuration.getClass().getSimpleName(), filename, yamlMapper.writeValueAsString(configuration)));
} catch (Exception e) {
LOG.warn(String.format("Exception while attempting to print %s!", configuration.getClass().getName()), e);
}
}
}
use of com.hubspot.singularity.runner.base.configuration.Configuration in project Singularity by HubSpot.
the class SingularityRunnerConfigurationProvider method get.
@Override
public T get() {
final Configuration configuration = clazz.getAnnotation(Configuration.class);
try {
final File baseFile = new File(configuration.filename());
final T baseConfig = baseFile.exists() ? objectMapper.readValue(baseFile, clazz) : clazz.newInstance();
final JsonNode overrideNode = filename.isPresent() ? loadYamlField(filename.get(), configuration.consolidatedField()) : objectMapper.createObjectNode();
final T config = objectMapper.readerForUpdating(baseConfig).readValue(overrideNode);
final Set<ConstraintViolation<T>> violations = validator.validate(config);
if (!violations.isEmpty()) {
throw new ConfigurationValidationException(filename.or(configuration.filename()), violations);
}
return config;
} catch (Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations