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
This commit is contained in:
parent
4b519219de
commit
2799d9659d
@ -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)
|
||||
|
@ -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 });
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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();
|
||||
|
@ -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<String,String> 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<String, Collection<OutputRecord>> getAllRecords() {
|
||||
Map<String, Collection<OutputRecord>> out = new TreeMap<String, Collection<OutputRecord>>();
|
||||
for (String recordName : bufferedData.keySet()) {
|
||||
@ -449,6 +458,7 @@ protected void remove(MetricsRecordImpl record) {
|
||||
/**
|
||||
* Returns the timer period.
|
||||
*/
|
||||
@Override
|
||||
public int getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
}
|
||||
|
@ -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) {
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ public synchronized int get() {
|
||||
*
|
||||
* @param mr
|
||||
*/
|
||||
@Override
|
||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||
if (changed) {
|
||||
try {
|
||||
|
@ -82,6 +82,7 @@ public synchronized long get() {
|
||||
*
|
||||
* @param mr
|
||||
*/
|
||||
@Override
|
||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||
if (changed)
|
||||
mr.setMetric(getName(), value);
|
||||
|
@ -101,6 +101,7 @@ private synchronized void intervalHeartBeat() {
|
||||
*
|
||||
* @param mr
|
||||
*/
|
||||
@Override
|
||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||
intervalHeartBeat();
|
||||
try {
|
||||
|
@ -97,6 +97,7 @@ private synchronized void intervalHeartBeat() {
|
||||
*
|
||||
* @param mr
|
||||
*/
|
||||
@Override
|
||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||
intervalHeartBeat();
|
||||
try {
|
||||
|
@ -144,6 +144,7 @@ private synchronized void intervalHeartBeat() {
|
||||
*
|
||||
* @param mr
|
||||
*/
|
||||
@Override
|
||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||
intervalHeartBeat();
|
||||
try {
|
||||
|
@ -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 extends MetricsPlugin> 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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -192,8 +192,7 @@ Iterable<MetricsRecordImpl> 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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user