diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 3434f104ce..ab46e0f71f 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/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) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsServlet.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsServlet.java index af469f9a34..6cb641d7b5 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsServlet.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsServlet.java @@ -60,12 +60,14 @@ public TagsMetricsPair(TagMap tagMap, MetricMap metricMap) { 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 }); } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsUtil.java index 14510aef22..5117d1b294 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/MetricsUtil.java @@ -93,8 +93,7 @@ private static String getHostName() { String hostName = null; try { hostName = InetAddress.getLocalHost().getHostName(); - } - catch (UnknownHostException ex) { + } catch (UnknownHostException ex) { LOG.info("Unable to obtain hostName", ex); hostName = "unknown"; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/file/FileContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/file/FileContext.java index f0aafa1c3a..fc76e21801 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/file/FileContext.java +++ b/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 String getFileName() { * if specified. Otherwise the data will be written to standard * output. */ + @Override @InterfaceAudience.Private public void startMonitoring() throws IOException @@ -108,6 +110,7 @@ public void startMonitoring() * Stops monitoring, closing the file. * @see #close() */ + @Override @InterfaceAudience.Private public void stopMonitoring() { super.stopMonitoring(); @@ -121,6 +124,7 @@ public void stopMonitoring() { /** * 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 void emitRecord(String contextName, String recordName, OutputRecord outRe /** * Flushes the output writer, forcing updates to disk. */ + @Override @InterfaceAudience.Private public void flush() { writer.flush(); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext.java index 18dc7a0da7..c4fa203c61 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext.java +++ b/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 void init(String contextName, ContextFactory factory) { try { datagramSocket = new DatagramSocket(); - } - catch (SocketException se) { + } catch (SocketException se) { se.printStackTrace(); } } @@ -123,6 +123,7 @@ public void close() { } } + @Override @InterfaceAudience.Private public void emitRecord(String contextName, String recordName, OutputRecord outRec) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java index 56444d219b..39509f0c89 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/ganglia/GangliaContext31.java +++ b/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 void init(String contextName, ContextFactory factory) { } } + @Override protected void emitMetric(String name, String type, String value) throws IOException { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/jvm/JvmMetrics.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/jvm/JvmMetrics.java index a518d72d91..ec8a9c2a63 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/jvm/JvmMetrics.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/jvm/JvmMetrics.java @@ -94,6 +94,7 @@ private JvmMetrics(String processName, String sessionId, * This will be called periodically (with the period being configuration * dependent). */ + @Override public void doUpdates(MetricsContext context) { doMemoryUpdates(); doGarbageCollectionUpdates(); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java index 947b0a1295..e5396b8e33 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java @@ -116,6 +116,7 @@ protected AbstractMetricsContext() { /** * Initializes the context. */ + @Override public void init(String contextName, ContextFactory factory) { this.contextName = contextName; @@ -152,6 +153,7 @@ protected Map getAttributeTable(String tableName) { /** * Returns the context name. */ + @Override public String getContextName() { return contextName; } @@ -166,6 +168,7 @@ public ContextFactory getContextFactory() { /** * Starts or restarts monitoring, the emitting of metrics records. */ + @Override public synchronized void startMonitoring() throws IOException { if (!isMonitoring) { @@ -178,6 +181,7 @@ public synchronized void startMonitoring() * Stops monitoring. This does not free buffered data. * @see #close() */ + @Override public synchronized void stopMonitoring() { if (isMonitoring) { stopTimer(); @@ -188,6 +192,7 @@ public synchronized void stopMonitoring() { /** * Returns true if monitoring is currently in progress. */ + @Override public boolean isMonitoring() { return isMonitoring; } @@ -196,6 +201,7 @@ public boolean isMonitoring() { * 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 synchronized void close() { * @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 @@ protected MetricsRecord newRecord(String recordName) { * @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 synchronized void registerUpdater(final Updater updater) { * * @param updater object to be removed from the callback list */ + @Override public synchronized void unregisterUpdater(Updater updater) { updaters.remove(updater); } @@ -259,11 +268,11 @@ private synchronized void startTimer() { 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 @@ private void timerEvent() throws IOException { for (Updater updater : myUpdaters) { try { updater.doUpdates(this); - } - catch (Throwable throwable) { + } catch (Throwable throwable) { throwable.printStackTrace(); } } @@ -328,6 +336,7 @@ private synchronized void emitRecords() throws IOException { * Useful for monitoring systems that are polling-based. * @return A non-null collection of all monitoring records. */ + @Override public synchronized Map> getAllRecords() { Map> out = new TreeMap>(); for (String recordName : bufferedData.keySet()) { @@ -449,6 +458,7 @@ protected void remove(MetricsRecordImpl record) { /** * Returns the timer period. */ + @Override public int getPeriod() { return period; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/CompositeContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/CompositeContext.java index 0c9fb4e152..1e2ee39814 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/CompositeContext.java +++ b/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 @@ private static Method initMethod() { } } + @Override public Object invoke(Object p, Method m, Object[] args) throws Throwable { if (m_getRecordName.equals(m)) { return recordName; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java index 85cf00e091..918b3202b7 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/MetricsRecordImpl.java @@ -57,6 +57,7 @@ protected MetricsRecordImpl(String recordName, AbstractMetricsContext context) * * @return the record name */ + @Override public String getRecordName() { return recordName; } @@ -68,6 +69,7 @@ public String getRecordName() { * @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 void setTag(String tagName, String tagValue) { * @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 void setTag(String tagName, int tagValue) { * @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 void setTag(String tagName, long tagValue) { * @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 void setTag(String tagName, short tagValue) { * @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 void setTag(String tagName, byte tagValue) { /** * Removes any tag of the specified name. */ + @Override public void removeTag(String tagName) { tagTable.remove(tagName); } @@ -134,6 +141,7 @@ public void removeTag(String tagName) { * @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 void setMetric(String metricName, int metricValue) { * @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 void setMetric(String metricName, long metricValue) { * @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 void setMetric(String metricName, short metricValue) { * @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 void setMetric(String metricName, byte metricValue) { * @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 void setMetric(String metricName, float metricValue) { * @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 void incrMetric(String metricName, int metricValue) { * @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 void incrMetric(String metricName, long metricValue) { * @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 void incrMetric(String metricName, short metricValue) { * @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 void incrMetric(String metricName, byte metricValue) { * @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 @@ private void setIncrement(String metricName, Number metricValue) { * 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 void update() { * 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); } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NoEmitMetricsContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NoEmitMetricsContext.java index e7f40c6d4f..7d992ab314 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NoEmitMetricsContext.java +++ b/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 void init(String contextName, ContextFactory factory) { /** * Do-nothing version of emitRecord */ + @Override @InterfaceAudience.Private protected void emitRecord(String contextName, String recordName, OutputRecord outRec) { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContext.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContext.java index a3ddda4bc6..39b58cf49f 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContext.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContext.java @@ -40,6 +40,7 @@ public NullContext() { /** * Do-nothing version of startMonitoring */ + @Override @InterfaceAudience.Private public void startMonitoring() { } @@ -47,6 +48,7 @@ public void startMonitoring() { /** * Do-nothing version of emitRecord */ + @Override @InterfaceAudience.Private protected void emitRecord(String contextName, String recordName, OutputRecord outRec) @@ -55,6 +57,7 @@ protected void emitRecord(String contextName, String recordName, /** * Do-nothing version of update */ + @Override @InterfaceAudience.Private protected void update(MetricsRecordImpl record) { } @@ -62,6 +65,7 @@ protected void update(MetricsRecordImpl record) { /** * Do-nothing version of remove */ + @Override @InterfaceAudience.Private protected void remove(MetricsRecordImpl record) { } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContextWithUpdateThread.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContextWithUpdateThread.java index c3210e31cb..63f7ddaacd 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/spi/NullContextWithUpdateThread.java +++ b/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 void init(String contextName, ContextFactory factory) { /** * Do-nothing version of emitRecord */ + @Override @InterfaceAudience.Private protected void emitRecord(String contextName, String recordName, OutputRecord outRec) @@ -64,6 +66,7 @@ protected void emitRecord(String contextName, String recordName, /** * Do-nothing version of update */ + @Override @InterfaceAudience.Private protected void update(MetricsRecordImpl record) { } @@ -71,6 +74,7 @@ protected void update(MetricsRecordImpl record) { /** * Do-nothing version of remove */ + @Override @InterfaceAudience.Private protected void remove(MetricsRecordImpl record) { } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsIntValue.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsIntValue.java index 5f89008e79..a84ebc9898 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsIntValue.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsIntValue.java @@ -92,6 +92,7 @@ public synchronized int get() { * * @param mr */ + @Override public synchronized void pushMetric(final MetricsRecord mr) { if (changed) { try { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsLongValue.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsLongValue.java index 90e74192b5..c122636575 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsLongValue.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsLongValue.java @@ -82,6 +82,7 @@ public synchronized long get() { * * @param mr */ + @Override public synchronized void pushMetric(final MetricsRecord mr) { if (changed) mr.setMetric(getName(), value); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java index a427142af2..790397fd4b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingInt.java @@ -101,6 +101,7 @@ private synchronized void intervalHeartBeat() { * * @param mr */ + @Override public synchronized void pushMetric(final MetricsRecord mr) { intervalHeartBeat(); try { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingLong.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingLong.java index 049411d50a..ad431395eb 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingLong.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingLong.java @@ -97,6 +97,7 @@ private synchronized void intervalHeartBeat() { * * @param mr */ + @Override public synchronized void pushMetric(final MetricsRecord mr) { intervalHeartBeat(); try { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java index f77256d7a1..73f7ef3011 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics/util/MetricsTimeVaryingRate.java @@ -144,6 +144,7 @@ private synchronized void intervalHeartBeat() { * * @param mr */ + @Override public synchronized void pushMetric(final MetricsRecord mr) { intervalHeartBeat(); try { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java index 5d8329ac40..230a9f00f0 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsConfig.java @@ -114,8 +114,7 @@ static MetricsConfig loadFirst(String prefix, String... fileNames) { 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 @@ T getPlugin(String name) { 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 @@ ClassLoader getPluginLoader() { 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 @@ static String toString(Configuration c) { 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(); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSinkAdapter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSinkAdapter.java index fbb57bd86b..688eca4e99 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSinkAdapter.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSinkAdapter.java @@ -107,11 +107,9 @@ void publishMetricsFromQueue() { 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 @@ void publishMetricsFromQueue() { 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 @@ void stop() { sinkThread.interrupt(); try { sinkThread.join(); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { LOG.warn("Stop interrupted", e); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java index 8fe92d86d6..23c4492663 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java @@ -192,8 +192,7 @@ Iterable getMetrics(MetricsCollectorImpl builder, } try { source.getMetrics(builder, all); - } - catch (Exception e) { + } catch (Exception e) { LOG.error("Error getting metrics from source "+ name, e); } for (MetricsRecordBuilderImpl rb : builder) { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java index 54ac00489a..61aa73f9cb 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSystemImpl.java @@ -287,8 +287,7 @@ public Object invoke(Object proxy, Method method, Object[] args) 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 @@ private synchronized void startTimer() { 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 @@ private synchronized void configureSinks() { 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 @@ private void clearConfigs() { 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 synchronized boolean shutdown() { return true; } + @Override public MetricsSource getSource(String name) { return allSources.get(name); } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MethodMetric.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MethodMetric.java index 9ab9243c0b..51b2e6613b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MethodMetric.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MethodMetric.java @@ -76,8 +76,7 @@ MutableMetric newCounter(final Class type) { 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 @@ MutableMetric newGauge(final Class t) { 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 @@ MutableMetric newTag(Class resType) { 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); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsSourceBuilder.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsSourceBuilder.java index 9430260da1..9e393c9086 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsSourceBuilder.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MetricsSourceBuilder.java @@ -95,8 +95,7 @@ private MetricsRegistry initRegistry(Object source) { 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 @@ private void add(Object source, Field field) { // 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 @@ private void add(Object source, Field field) { try { field.set(source, mutable); hasAtMetric = true; - } - catch (Exception e) { + } catch (Exception e) { throw new MetricsException("Error setting field "+ field + " annotated with "+ annotation, e); } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableGaugeLong.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableGaugeLong.java index 61be2a970e..69df4304e9 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableGaugeLong.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableGaugeLong.java @@ -80,6 +80,7 @@ public void set(long value) { setChanged(); } + @Override public void snapshot(MetricsRecordBuilder builder, boolean all) { if (all || changed()) { builder.addGauge(info(), value); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java index 38a7959779..b8ba435bf4 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/lib/MutableStat.java @@ -109,6 +109,7 @@ public synchronized void add(long value) { setChanged(); } + @Override public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) { if (all || changed()) { numSamples += intervalStat.numSamples(); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/FileSink.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/FileSink.java index 980351d6cb..929590f467 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/FileSink.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/FileSink.java @@ -48,8 +48,7 @@ public void init(SubsetConfiguration conf) { 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); } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java index afea7dc555..b3581f9e8d 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/AbstractGangliaSink.java @@ -109,6 +109,7 @@ public enum GangliaConfType { * 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 void init(SubsetConfiguration conf) { * * @see org.apache.hadoop.metrics2.MetricsSink#flush() */ + @Override public void flush() { // nothing to do as we are not buffering data } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/GangliaSink31.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/GangliaSink31.java index c8315e8e14..1d92177cd0 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/sink/ganglia/GangliaSink31.java +++ b/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 {