return copy;
}
protected void init() {
List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
MBeanInfo parentInfo = super.getMBeanInfo();
List<String> parentAttributes = new ArrayList<String>();
for (MBeanAttributeInfo attr : parentInfo.getAttributes()) {
attributes.add(attr);
parentAttributes.add(attr.getName());
}
this.registryLength = this.registry.getMetricsList().size();
for (MetricsBase metric : this.registry.getMetricsList()) {
if (metric.getName() == null || parentAttributes.contains(metric.getName()))
continue;
// add on custom HBase metric types
if (metric instanceof MetricsRate) {
attributes.add( new MBeanAttributeInfo(metric.getName(),
"java.lang.Float", metric.getDescription(), true, false, false) );
extendedAttributes.put(metric.getName(), metric);
} else if (metric instanceof MetricsString) {
attributes.add( new MBeanAttributeInfo(metric.getName(),
"java.lang.String", metric.getDescription(), true, false, false) );
extendedAttributes.put(metric.getName(), metric);
LOG.info("MetricsString added: " + metric.getName());
} else if (metric instanceof MetricsHistogram) {
String metricName = metric.getName() + MetricsHistogram.NUM_OPS_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Long", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.MIN_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Long", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.MAX_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Long", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.MEAN_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Float", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.STD_DEV_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Float", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.MEDIAN_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Float", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.SEVENTY_FIFTH_PERCENTILE_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Float", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.NINETY_FIFTH_PERCENTILE_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Float", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
metricName = metric.getName() + MetricsHistogram.NINETY_NINETH_PERCENTILE_METRIC_NAME;
attributes.add(new MBeanAttributeInfo(metricName,
"java.lang.Float", metric.getDescription(), true, false, false));
extendedAttributes.put(metricName, metric);
}
// else, its probably a hadoop metric already registered. Skip it.
}
LOG.info("new MBeanInfo");
this.extendedInfo = new MBeanInfo( this.getClass().getName(),
this.description, attributes.toArray( new MBeanAttributeInfo[0] ),
parentInfo.getConstructors(), parentInfo.getOperations(),
parentInfo.getNotifications() );
}