Sfoglia il codice sorgente

HADOOP-8593. Add missed @Override annotations in Metric/Metrics2 package. Contributed by Brandon Li.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1362294 13f79535-47bb-0310-9956-ffa450edef68
Suresh Srinivas 13 anni fa
parent
commit
2799d9659d
29 ha cambiato i file con 96 aggiunte e 48 eliminazioni
  1. 3 0
      hadoop-common-project/hadoop-common/CHANGES.txt
  2. 2 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsServlet.java
  3. 1 2
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsUtil.java
  4. 5 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/file/FileContext.java
  5. 3 2
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext.java
  6. 2 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java
  7. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/jvm/JvmMetrics.java
  8. 14 4
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java
  9. 2 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/CompositeContext.java
  10. 19 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java
  11. 2 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NoEmitMetricsContext.java
  12. 4 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContext.java
  13. 4 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContextWithUpdateThread.java
  14. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsIntValue.java
  15. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsLongValue.java
  16. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java
  17. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingLong.java
  18. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java
  19. 6 8
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java
  20. 4 8
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSinkAdapter.java
  21. 1 2
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java
  22. 6 8
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java
  23. 3 6
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MethodMetric.java
  24. 3 6
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsSourceBuilder.java
  25. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableGaugeLong.java
  26. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java
  27. 1 2
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/FileSink.java
  28. 2 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java
  29. 1 0
      hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/GangliaSink31.java

+ 3 - 0
hadoop-common-project/hadoop-common/CHANGES.txt

@@ -178,6 +178,9 @@ Trunk (unreleased changes)
     HADOOP-8521. Port StreamInputFormat to new Map Reduce API (madhukara
     phatak via bobby)
 
+    HADOOP-8593. Add missed @Override annotations in Metric/Metrics2 package.
+    (Brandon Li via suresh)
+
   OPTIMIZATIONS
 
     HADOOP-7761. Improve the performance of raw comparisons. (todd)

+ 2 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsServlet.java

@@ -60,12 +60,14 @@ public class MetricsServlet extends HttpServlet {
       this.metricMap = metricMap;
     }
 
+    @Override
     @SuppressWarnings("unchecked")
     public void fromJSON(Map map) {
       throw new UnsupportedOperationException();
     }
 
     /** Converts to JSON by providing an array. */
+    @Override
     public void toJSON(Output out) {
       out.add(new Object[] { tagMap, metricMap });
     }

+ 1 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsUtil.java

@@ -93,8 +93,7 @@ public class MetricsUtil {
     String hostName = null;
     try {
       hostName = InetAddress.getLocalHost().getHostName();
-    } 
-    catch (UnknownHostException ex) {
+    } catch (UnknownHostException ex) {
       LOG.info("Unable to obtain hostName", ex);
       hostName = "unknown";
     }

+ 5 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/file/FileContext.java

@@ -62,6 +62,7 @@ public class FileContext extends AbstractMetricsContext {
   @InterfaceAudience.Private
   public FileContext() {}
     
+  @Override
   @InterfaceAudience.Private
   public void init(String contextName, ContextFactory factory) {
     super.init(contextName, factory);
@@ -92,6 +93,7 @@ public class FileContext extends AbstractMetricsContext {
    * if specified. Otherwise the data will be written to standard
    * output.
    */
+  @Override
   @InterfaceAudience.Private
   public void startMonitoring()
     throws IOException 
@@ -108,6 +110,7 @@ public class FileContext extends AbstractMetricsContext {
    * Stops monitoring, closing the file.
    * @see #close()
    */
+  @Override
   @InterfaceAudience.Private
   public void stopMonitoring() {
     super.stopMonitoring();
@@ -121,6 +124,7 @@ public class FileContext extends AbstractMetricsContext {
   /**
    * Emits a metrics record to a file.
    */
+  @Override
   @InterfaceAudience.Private
   public void emitRecord(String contextName, String recordName, OutputRecord outRec) {
     writer.print(contextName);
@@ -147,6 +151,7 @@ public class FileContext extends AbstractMetricsContext {
   /**
    * Flushes the output writer, forcing updates to disk.
    */
+  @Override
   @InterfaceAudience.Private
   public void flush() {
     writer.flush();

+ 3 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext.java

@@ -91,6 +91,7 @@ public class GangliaContext extends AbstractMetricsContext {
   public GangliaContext() {
   }
     
+  @Override
   @InterfaceAudience.Private
   public void init(String contextName, ContextFactory factory) {
     super.init(contextName, factory);
@@ -106,8 +107,7 @@ public class GangliaContext extends AbstractMetricsContext {
         
     try {
       datagramSocket = new DatagramSocket();
-    }
-    catch (SocketException se) {
+    } catch (SocketException se) {
       se.printStackTrace();
     }
   }
@@ -123,6 +123,7 @@ public class GangliaContext extends AbstractMetricsContext {
     }
   }
   
+  @Override
   @InterfaceAudience.Private
   public void emitRecord(String contextName, String recordName,
     OutputRecord outRec) 

+ 2 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java

@@ -43,6 +43,7 @@ public class GangliaContext31 extends GangliaContext {
   private static final Log LOG = 
     LogFactory.getLog("org.apache.hadoop.util.GangliaContext31");
 
+  @Override
   public void init(String contextName, ContextFactory factory) {
     super.init(contextName, factory);
 
@@ -66,6 +67,7 @@ public class GangliaContext31 extends GangliaContext {
     }
   }
 
+  @Override
   protected void emitMetric(String name, String type,  String value) 
     throws IOException
   {

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/jvm/JvmMetrics.java

@@ -94,6 +94,7 @@ public class JvmMetrics implements Updater {
      * This will be called periodically (with the period being configuration
      * dependent).
      */
+    @Override
     public void doUpdates(MetricsContext context) {
         doMemoryUpdates();
         doGarbageCollectionUpdates();

+ 14 - 4
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java

@@ -116,6 +116,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
   /**
    * Initializes the context.
    */
+  @Override
   public void init(String contextName, ContextFactory factory) 
   {
     this.contextName = contextName;
@@ -152,6 +153,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
   /**
    * Returns the context name.
    */
+  @Override
   public String getContextName() {
     return contextName;
   }
@@ -166,6 +168,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
   /**
    * Starts or restarts monitoring, the emitting of metrics records.
    */
+  @Override
   public synchronized void startMonitoring()
     throws IOException {
     if (!isMonitoring) {
@@ -178,6 +181,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
    * Stops monitoring.  This does not free buffered data. 
    * @see #close()
    */
+  @Override
   public synchronized void stopMonitoring() {
     if (isMonitoring) {
       stopTimer();
@@ -188,6 +192,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
   /**
    * Returns true if monitoring is currently in progress.
    */
+  @Override
   public boolean isMonitoring() {
     return isMonitoring;
   }
@@ -196,6 +201,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
    * Stops monitoring and frees buffered data, returning this
    * object to its initial state.  
    */
+  @Override
   public synchronized void close() {
     stopMonitoring();
     clearUpdaters();
@@ -209,6 +215,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
    * @param recordName the name of the record
    * @throws MetricsException if recordName conflicts with configuration data
    */
+  @Override
   public final synchronized MetricsRecord createRecord(String recordName) {
     if (bufferedData.get(recordName) == null) {
       bufferedData.put(recordName, new RecordMap());
@@ -232,6 +239,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
    * @param updater object to be run periodically; it should update
    * some metrics records 
    */
+  @Override
   public synchronized void registerUpdater(final Updater updater) {
     if (!updaters.contains(updater)) {
       updaters.add(updater);
@@ -243,6 +251,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
    *
    * @param updater object to be removed from the callback list
    */
+  @Override
   public synchronized void unregisterUpdater(Updater updater) {
     updaters.remove(updater);
   }
@@ -259,11 +268,11 @@ public abstract class AbstractMetricsContext implements MetricsContext {
       timer = new Timer("Timer thread for monitoring " + getContextName(), 
                         true);
       TimerTask task = new TimerTask() {
+          @Override
           public void run() {
             try {
               timerEvent();
-            }
-            catch (IOException ioe) {
+            } catch (IOException ioe) {
               ioe.printStackTrace();
             }
           }
@@ -297,8 +306,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
       for (Updater updater : myUpdaters) {
         try {
           updater.doUpdates(this);
-        }
-        catch (Throwable throwable) {
+        } catch (Throwable throwable) {
           throwable.printStackTrace();
         }
       }
@@ -328,6 +336,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
    * Useful for monitoring systems that are polling-based.
    * @return A non-null collection of all monitoring records.
    */
+  @Override
   public synchronized Map<String, Collection<OutputRecord>> getAllRecords() {
     Map<String, Collection<OutputRecord>> out = new TreeMap<String, Collection<OutputRecord>>();
     for (String recordName : bufferedData.keySet()) {
@@ -449,6 +458,7 @@ public abstract class AbstractMetricsContext implements MetricsContext {
   /**
    * Returns the timer period.
    */
+  @Override
   public int getPeriod() {
     return period;
   }

+ 2 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/CompositeContext.java

@@ -49,6 +49,7 @@ public class CompositeContext extends AbstractMetricsContext {
   public CompositeContext() {
   }
 
+  @Override
   @InterfaceAudience.Private
   public void init(String contextName, ContextFactory factory) {
     super.init(contextName, factory);
@@ -186,6 +187,7 @@ public class CompositeContext extends AbstractMetricsContext {
       }
     }
 
+    @Override
     public Object invoke(Object p, Method m, Object[] args) throws Throwable {
       if (m_getRecordName.equals(m)) {
         return recordName;

+ 19 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java

@@ -57,6 +57,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    *
    * @return the record name
    */
+  @Override
   public String getRecordName() {
     return recordName;
   }
@@ -68,6 +69,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @param tagValue new value of the tag
    * @throws MetricsException if the tagName conflicts with the configuration
    */
+  @Override
   public void setTag(String tagName, String tagValue) {
     if (tagValue == null) {
       tagValue = "";
@@ -82,6 +84,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @param tagValue new value of the tag
    * @throws MetricsException if the tagName conflicts with the configuration
    */
+  @Override
   public void setTag(String tagName, int tagValue) {
     tagTable.put(tagName, Integer.valueOf(tagValue));
   }
@@ -93,6 +96,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @param tagValue new value of the tag
    * @throws MetricsException if the tagName conflicts with the configuration
    */
+  @Override
   public void setTag(String tagName, long tagValue) {
     tagTable.put(tagName, Long.valueOf(tagValue));
   }
@@ -104,6 +108,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @param tagValue new value of the tag
    * @throws MetricsException if the tagName conflicts with the configuration
    */
+  @Override
   public void setTag(String tagName, short tagValue) {
     tagTable.put(tagName, Short.valueOf(tagValue));
   }
@@ -115,6 +120,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @param tagValue new value of the tag
    * @throws MetricsException if the tagName conflicts with the configuration
    */
+  @Override
   public void setTag(String tagName, byte tagValue) {
     tagTable.put(tagName, Byte.valueOf(tagValue));
   }
@@ -122,6 +128,7 @@ public class MetricsRecordImpl implements MetricsRecord {
   /**
    * Removes any tag of the specified name.
    */
+  @Override
   public void removeTag(String tagName) {
     tagTable.remove(tagName);
   }
@@ -134,6 +141,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void setMetric(String metricName, int metricValue) {
     setAbsolute(metricName, Integer.valueOf(metricValue));
   }
@@ -146,6 +154,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void setMetric(String metricName, long metricValue) {
     setAbsolute(metricName, Long.valueOf(metricValue));
   }
@@ -158,6 +167,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void setMetric(String metricName, short metricValue) {
     setAbsolute(metricName, Short.valueOf(metricValue));
   }
@@ -170,6 +180,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void setMetric(String metricName, byte metricValue) {
     setAbsolute(metricName, Byte.valueOf(metricValue));
   }
@@ -182,6 +193,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void setMetric(String metricName, float metricValue) {
     setAbsolute(metricName, new Float(metricValue));
   }
@@ -194,6 +206,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void incrMetric(String metricName, int metricValue) {
     setIncrement(metricName, Integer.valueOf(metricValue));
   }
@@ -206,6 +219,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void incrMetric(String metricName, long metricValue) {
     setIncrement(metricName, Long.valueOf(metricValue));
   }
@@ -218,6 +232,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void incrMetric(String metricName, short metricValue) {
     setIncrement(metricName, Short.valueOf(metricValue));
   }
@@ -230,6 +245,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void incrMetric(String metricName, byte metricValue) {
     setIncrement(metricName, Byte.valueOf(metricValue));
   }
@@ -242,6 +258,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * @throws MetricsException if the metricName or the type of the metricValue 
    * conflicts with the configuration
    */
+  @Override
   public void incrMetric(String metricName, float metricValue) {
     setIncrement(metricName, new Float(metricValue));
   }
@@ -259,6 +276,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * If the tag values match an existing row, that row is updated; 
    * otherwise, a new row is added.
    */
+  @Override
   public void update() {
     context.update(this);
   }
@@ -267,6 +285,7 @@ public class MetricsRecordImpl implements MetricsRecord {
    * Removes the row, if it exists, in the buffered data table having tags 
    * that equal the tags that have been set on this record. 
    */
+  @Override
   public void remove() {
     context.remove(this);
   }

+ 2 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NoEmitMetricsContext.java

@@ -40,6 +40,7 @@ public class NoEmitMetricsContext extends AbstractMetricsContext {
     public NoEmitMetricsContext() {
     }
     
+    @Override
     @InterfaceAudience.Private
     public void init(String contextName, ContextFactory factory) {
       super.init(contextName, factory);
@@ -49,6 +50,7 @@ public class NoEmitMetricsContext extends AbstractMetricsContext {
     /**
      * Do-nothing version of emitRecord
      */
+    @Override
     @InterfaceAudience.Private
     protected void emitRecord(String contextName, String recordName,
                               OutputRecord outRec) {

+ 4 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContext.java

@@ -40,6 +40,7 @@ public class NullContext extends AbstractMetricsContext {
   /**
    * Do-nothing version of startMonitoring
    */
+  @Override
   @InterfaceAudience.Private
   public void startMonitoring() {
   }
@@ -47,6 +48,7 @@ public class NullContext extends AbstractMetricsContext {
   /**
    * Do-nothing version of emitRecord
    */
+  @Override
   @InterfaceAudience.Private
   protected void emitRecord(String contextName, String recordName,
                             OutputRecord outRec) 
@@ -55,6 +57,7 @@ public class NullContext extends AbstractMetricsContext {
   /**
    * Do-nothing version of update
    */
+  @Override
   @InterfaceAudience.Private
   protected void update(MetricsRecordImpl record) {
   }
@@ -62,6 +65,7 @@ public class NullContext extends AbstractMetricsContext {
   /**
    * Do-nothing version of remove
    */
+  @Override
   @InterfaceAudience.Private
   protected void remove(MetricsRecordImpl record) {
   }

+ 4 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContextWithUpdateThread.java

@@ -46,6 +46,7 @@ public class NullContextWithUpdateThread extends AbstractMetricsContext {
   public NullContextWithUpdateThread() {
   }
   
+  @Override
   @InterfaceAudience.Private
   public void init(String contextName, ContextFactory factory) {
     super.init(contextName, factory);
@@ -56,6 +57,7 @@ public class NullContextWithUpdateThread extends AbstractMetricsContext {
   /**
    * Do-nothing version of emitRecord
    */
+  @Override
   @InterfaceAudience.Private
   protected void emitRecord(String contextName, String recordName,
                             OutputRecord outRec) 
@@ -64,6 +66,7 @@ public class NullContextWithUpdateThread extends AbstractMetricsContext {
   /**
    * Do-nothing version of update
    */
+  @Override
   @InterfaceAudience.Private
   protected void update(MetricsRecordImpl record) {
   }
@@ -71,6 +74,7 @@ public class NullContextWithUpdateThread extends AbstractMetricsContext {
   /**
    * Do-nothing version of remove
    */
+  @Override
   @InterfaceAudience.Private
   protected void remove(MetricsRecordImpl record) {
   }

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsIntValue.java

@@ -92,6 +92,7 @@ public class MetricsIntValue extends MetricsBase {
    *
    * @param mr
    */
+  @Override
   public synchronized void pushMetric(final MetricsRecord mr) {
     if (changed) {
       try {

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsLongValue.java

@@ -82,6 +82,7 @@ public class MetricsLongValue extends MetricsBase{
    *
    * @param mr
    */
+  @Override
   public synchronized void pushMetric(final MetricsRecord mr) {
     if (changed) 
       mr.setMetric(getName(), value);

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java

@@ -101,6 +101,7 @@ public class MetricsTimeVaryingInt extends MetricsBase {
    *
    * @param mr
    */
+  @Override
   public synchronized void pushMetric(final MetricsRecord mr) {
     intervalHeartBeat();
     try {

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingLong.java

@@ -97,6 +97,7 @@ public class MetricsTimeVaryingLong extends MetricsBase{
    *
    * @param mr
    */
+  @Override
   public synchronized void pushMetric(final MetricsRecord mr) {
     intervalHeartBeat();
     try {

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java

@@ -144,6 +144,7 @@ public class MetricsTimeVaryingRate extends MetricsBase {
    *
    * @param mr
    */
+  @Override
   public synchronized void pushMetric(final MetricsRecord mr) {
     intervalHeartBeat();
     try {

+ 6 - 8
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java

@@ -114,8 +114,7 @@ class MetricsConfig extends SubsetConfiguration {
         MetricsConfig mc = new MetricsConfig(cf, prefix);
         LOG.debug(mc);
         return mc;
-      }
-      catch (ConfigurationException e) {
+      } catch (ConfigurationException e) {
         if (e.getMessage().startsWith("Cannot locate configuration")) {
           continue;
         }
@@ -198,8 +197,7 @@ class MetricsConfig extends SubsetConfiguration {
       T plugin = (T) cls.newInstance();
       plugin.init(name.isEmpty() ? this : subset(name));
       return plugin;
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       throw new MetricsConfigException("Error creating plugin: "+ clsName, e);
     }
   }
@@ -229,8 +227,7 @@ class MetricsConfig extends SubsetConfiguration {
           LOG.debug(jar);
           urls[i++] = new URL(jar);
         }
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         throw new MetricsConfigException(e);
       }
       if (LOG.isDebugEnabled()) {
@@ -276,8 +273,9 @@ class MetricsConfig extends SubsetConfiguration {
     PrintStream ps = new PrintStream(buffer);
     PropertiesConfiguration tmp = new PropertiesConfiguration();
     tmp.copy(c);
-    try { tmp.save(ps); }
-    catch (Exception e) {
+    try {
+      tmp.save(ps);
+    } catch (Exception e) {
       throw new MetricsConfigException(e);
     }
     return buffer.toString();

+ 4 - 8
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSinkAdapter.java

@@ -107,11 +107,9 @@ class MetricsSinkAdapter implements SinkQueue.Consumer<MetricsBuffer> {
         retryDelay = firstRetryDelay;
         n = retryCount;
         inError = false;
-      }
-      catch (InterruptedException e) {
+      } catch (InterruptedException e) {
         LOG.info(name +" thread interrupted.");
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         if (n > 0) {
           int retryWindow = Math.max(0, 1000 / 2 * retryDelay - minDelay);
           int awhile = rng.nextInt(retryWindow) + minDelay;
@@ -124,8 +122,7 @@ class MetricsSinkAdapter implements SinkQueue.Consumer<MetricsBuffer> {
             LOG.info(name +" thread interrupted while waiting for retry", e2);
           }
           --n;
-        }
-        else {
+        } else {
           if (!inError) {
             LOG.error("Got sink exception and over retry limit, "+
                       "suppressing further error messages", e);
@@ -174,8 +171,7 @@ class MetricsSinkAdapter implements SinkQueue.Consumer<MetricsBuffer> {
     sinkThread.interrupt();
     try {
       sinkThread.join();
-    }
-    catch (InterruptedException e) {
+    } catch (InterruptedException e) {
       LOG.warn("Stop interrupted", e);
     }
   }

+ 1 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java

@@ -192,8 +192,7 @@ class MetricsSourceAdapter implements DynamicMBean {
     }
     try {
       source.getMetrics(builder, all);
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       LOG.error("Error getting metrics from source "+ name, e);
     }
     for (MetricsRecordBuilderImpl rb : builder) {

+ 6 - 8
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java

@@ -287,8 +287,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
               throws Throwable {
             try {
               return method.invoke(callback, args);
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
               // These are not considered fatal.
               LOG.warn("Caught exception in callback "+ method.getName(), e);
             }
@@ -332,11 +331,11 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
     long millis = period * 1000;
     timer = new Timer("Timer for '"+ prefix +"' metrics system", true);
     timer.scheduleAtFixedRate(new TimerTask() {
+          @Override
           public void run() {
             try {
               onTimerEvent();
-            }
-            catch (Exception e) {
+            } catch (Exception e) {
               LOG.warn(e);
             }
           }
@@ -451,8 +450,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
             conf.getString(DESC_KEY, sinkName), conf);
         sa.start();
         sinks.put(sinkName, sa);
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         LOG.warn("Error creating sink '"+ sinkName +"'", e);
       }
     }
@@ -494,8 +492,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
   static String getHostname() {
     try {
       return InetAddress.getLocalHost().getHostName();
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       LOG.error("Error getting localhost name. Using 'localhost'...", e);
     }
     return "localhost";
@@ -555,6 +552,7 @@ public class MetricsSystemImpl extends MetricsSystem implements MetricsSource {
     return true;
   }
 
+  @Override
   public MetricsSource getSource(String name) {
     return allSources.get(name);
   }

+ 3 - 6
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MethodMetric.java

@@ -76,8 +76,7 @@ class MethodMetric extends MutableMetric {
             Object ret = method.invoke(obj, (Object[])null);
             if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue());
             else rb.addCounter(info, ((Long) ret).longValue());
-          }
-          catch (Exception ex) {
+          } catch (Exception ex) {
             LOG.error("Error invoking method "+ method.getName(), ex);
           }
         }
@@ -113,8 +112,7 @@ class MethodMetric extends MutableMetric {
             else if (isLong(t)) rb.addGauge(info, ((Long) ret).longValue());
             else if (isFloat(t)) rb.addGauge(info, ((Float) ret).floatValue());
             else rb.addGauge(info, ((Double) ret).doubleValue());
-          }
-          catch (Exception ex) {
+          } catch (Exception ex) {
             LOG.error("Error invoking method "+ method.getName(), ex);
           }
         }
@@ -130,8 +128,7 @@ class MethodMetric extends MutableMetric {
           try {
             Object ret = method.invoke(obj, (Object[]) null);
             rb.tag(info, (String) ret);
-          }
-          catch (Exception ex) {
+          } catch (Exception ex) {
             LOG.error("Error invoking method "+ method.getName(), ex);
           }
         }

+ 3 - 6
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsSourceBuilder.java

@@ -95,8 +95,7 @@ public class MetricsSourceBuilder {
         r = (MetricsRegistry) field.get(source);
         hasRegistry = r != null;
         break;
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         LOG.warn("Error accessing field "+ field, e);
         continue;
       }
@@ -123,8 +122,7 @@ public class MetricsSourceBuilder {
         // skip fields already set
         field.setAccessible(true);
         if (field.get(source) != null) continue;
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         LOG.warn("Error accessing field "+ field +" annotated with"+
                  annotation, e);
         continue;
@@ -135,8 +133,7 @@ public class MetricsSourceBuilder {
         try {
           field.set(source, mutable);
           hasAtMetric = true;
-        }
-        catch (Exception e) {
+        } catch (Exception e) {
           throw new MetricsException("Error setting field "+ field +
                                      " annotated with "+ annotation, e);
         }

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableGaugeLong.java

@@ -80,6 +80,7 @@ public class MutableGaugeLong extends MutableGauge {
     setChanged();
   }
 
+  @Override
   public void snapshot(MetricsRecordBuilder builder, boolean all) {
     if (all || changed()) {
       builder.addGauge(info(), value);

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java

@@ -109,6 +109,7 @@ public class MutableStat extends MutableMetric {
     setChanged();
   }
 
+  @Override
   public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) {
     if (all || changed()) {
       numSamples += intervalStat.numSamples();

+ 1 - 2
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/FileSink.java

@@ -48,8 +48,7 @@ public class FileSink implements MetricsSink {
       writer = filename == null
           ? new PrintWriter(System.out)
           : new PrintWriter(new FileWriter(new File(filename), true));
-    }
-    catch (Exception e) {
+    } catch (Exception e) {
       throw new MetricsException("Error creating "+ filename, e);
     }
   }

+ 2 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java

@@ -109,6 +109,7 @@ public abstract class AbstractGangliaSink implements MetricsSink {
    * org.apache.hadoop.metrics2.MetricsPlugin#init(org.apache.commons.configuration
    * .SubsetConfiguration)
    */
+  @Override
   public void init(SubsetConfiguration conf) {
     LOG.debug("Initializing the GangliaSink for Ganglia metrics.");
 
@@ -155,6 +156,7 @@ public abstract class AbstractGangliaSink implements MetricsSink {
    *
    * @see org.apache.hadoop.metrics2.MetricsSink#flush()
    */
+  @Override
   public void flush() {
     // nothing to do as we are not buffering data
   }

+ 1 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/GangliaSink31.java

@@ -43,6 +43,7 @@ public class GangliaSink31 extends GangliaSink30 {
    * @param gSlope The slope for this metric
    * @throws IOException
    */
+  @Override
   protected void emitMetric(String groupName, String name, String type,
       String value, GangliaConf gConf, GangliaSlope gSlope) 
     throws IOException {