use of com.linkedin.drelephant.analysis.HadoopMetricsAggregator in project dr-elephant by linkedin.
the class ElephantContext method loadAggregators.
private void loadAggregators() {
Document document = Utils.loadXMLDoc(AGGREGATORS_CONF);
_aggregatorConfData = new AggregatorConfiguration(document.getDocumentElement()).getAggregatorsConfigurationData();
for (AggregatorConfigurationData data : _aggregatorConfData) {
try {
Class<?> aggregatorClass = Class.forName(data.getClassName());
Object instance = aggregatorClass.getConstructor(AggregatorConfigurationData.class).newInstance(data);
if (!(instance instanceof HadoopMetricsAggregator)) {
throw new IllegalArgumentException("Class " + aggregatorClass.getName() + " is not an implementation of " + HadoopMetricsAggregator.class.getName());
}
ApplicationType type = data.getAppType();
if (_typeToAggregator.get(type) == null) {
_typeToAggregator.put(type, (HadoopMetricsAggregator) instance);
}
logger.info("Load Aggregator : " + data.getClassName());
} catch (ClassNotFoundException e) {
throw new RuntimeException("Could not find class " + data.getClassName(), e);
} catch (InstantiationException e) {
throw new RuntimeException("Could not instantiate class " + data.getClassName(), e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Could not access constructor for class" + data.getClassName(), e);
} catch (RuntimeException e) {
throw new RuntimeException(data.getClassName() + " is not a valid Aggregator class.", e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Could not invoke class " + data.getClassName(), e);
} catch (NoSuchMethodException e) {
throw new RuntimeException("Could not find constructor for class " + data.getClassName(), e);
}
}
}
Aggregations