/** * Register the FSDataset MBean using the name * "hadoop:service=DataNode,name=FSDatasetState-<datanodeUuid>" */ void registerMBean(final String datanodeUuid) { // We wrap to bypass standard mbean naming convetion. // This wraping can be removed in java 6 as it is more flexible in // package naming for mbeans and their impl. try { StandardMBean bean = new StandardMBean(this,FSDatasetMBean.class); mbeanName = MBeans.register("DataNode", "FSDatasetState-" + datanodeUuid, bean); } catch (NotCompliantMBeanException e) { LOG.warn("Error registering FSDatasetState MBean", e); } LOG.info("Registered FSDatasetState MBean"); }
/** * Get metrics helper provides Helper function for * metrics2 interface to act as a Metric source * * @param collector Metrics Collector that is passed in * @param beanClass The Class that currently impliments the metric functions * @param context A string that idenitifies the context * * @throws IOException */ public static void getMetrics(MetricsCollector collector, FSDatasetMBean beanClass, String context) throws IOException { if (beanClass == null) { throw new IOException("beanClass cannot be null"); } String className = beanClass.getClass().getName(); collector.addRecord(className) .setContext(context) .addGauge(Interns.info("Capacity", "Total storage capacity"), beanClass.getCapacity()) .addGauge(Interns.info("DfsUsed", "Total bytes used by dfs datanode"), beanClass.getDfsUsed()) .addGauge(Interns.info("Remaining", "Total bytes of free storage"), beanClass.getRemaining()) .add(new MetricsTag(Interns.info("StorageInfo", "Storage ID"), beanClass.getStorageInfo())) .addGauge(Interns.info("NumFailedVolumes", "Number of failed Volumes" + " in the data Node"), beanClass.getNumFailedVolumes()) .addGauge(Interns.info("LastVolumeFailureDate", "Last Volume failure in" + " milliseconds from epoch"), beanClass.getLastVolumeFailureDate()) .addGauge(Interns.info("EstimatedCapacityLostTotal", "Total capacity lost" + " due to volume failure"), beanClass.getEstimatedCapacityLostTotal()) .addGauge(Interns.info("CacheUsed", "Datanode cache used in bytes"), beanClass.getCacheUsed()) .addGauge(Interns.info("CacheCapacity", "Datanode cache capacity"), beanClass.getCacheCapacity()) .addGauge(Interns.info("NumBlocksCached", "Datanode number" + " of blocks cached"), beanClass.getNumBlocksCached()) .addGauge(Interns.info("NumBlocksFailedToCache", "Datanode number of " + "blocks failed to cache"), beanClass.getNumBlocksFailedToCache()) .addGauge(Interns.info("NumBlocksFailedToUnCache", "Datanode number of" + " blocks failed in cache eviction"), beanClass.getNumBlocksFailedToUncache()); }