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
|
HADOOP-8521. Port StreamInputFormat to new Map Reduce API (madhukara
|
||||||
phatak via bobby)
|
phatak via bobby)
|
||||||
|
|
||||||
|
HADOOP-8593. Add missed @Override annotations in Metric/Metrics2 package.
|
||||||
|
(Brandon Li via suresh)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-7761. Improve the performance of raw comparisons. (todd)
|
HADOOP-7761. Improve the performance of raw comparisons. (todd)
|
||||||
|
@ -60,12 +60,14 @@ public TagsMetricsPair(TagMap tagMap, MetricMap metricMap) {
|
|||||||
this.metricMap = metricMap;
|
this.metricMap = metricMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void fromJSON(Map map) {
|
public void fromJSON(Map map) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Converts to JSON by providing an array. */
|
/** Converts to JSON by providing an array. */
|
||||||
|
@Override
|
||||||
public void toJSON(Output out) {
|
public void toJSON(Output out) {
|
||||||
out.add(new Object[] { tagMap, metricMap });
|
out.add(new Object[] { tagMap, metricMap });
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,7 @@ private static String getHostName() {
|
|||||||
String hostName = null;
|
String hostName = null;
|
||||||
try {
|
try {
|
||||||
hostName = InetAddress.getLocalHost().getHostName();
|
hostName = InetAddress.getLocalHost().getHostName();
|
||||||
}
|
} catch (UnknownHostException ex) {
|
||||||
catch (UnknownHostException ex) {
|
|
||||||
LOG.info("Unable to obtain hostName", ex);
|
LOG.info("Unable to obtain hostName", ex);
|
||||||
hostName = "unknown";
|
hostName = "unknown";
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public class FileContext extends AbstractMetricsContext {
|
|||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public FileContext() {}
|
public FileContext() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void init(String contextName, ContextFactory factory) {
|
public void init(String contextName, ContextFactory factory) {
|
||||||
super.init(contextName, factory);
|
super.init(contextName, factory);
|
||||||
@ -92,6 +93,7 @@ public String getFileName() {
|
|||||||
* if specified. Otherwise the data will be written to standard
|
* if specified. Otherwise the data will be written to standard
|
||||||
* output.
|
* output.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void startMonitoring()
|
public void startMonitoring()
|
||||||
throws IOException
|
throws IOException
|
||||||
@ -108,6 +110,7 @@ public void startMonitoring()
|
|||||||
* Stops monitoring, closing the file.
|
* Stops monitoring, closing the file.
|
||||||
* @see #close()
|
* @see #close()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void stopMonitoring() {
|
public void stopMonitoring() {
|
||||||
super.stopMonitoring();
|
super.stopMonitoring();
|
||||||
@ -121,6 +124,7 @@ public void stopMonitoring() {
|
|||||||
/**
|
/**
|
||||||
* Emits a metrics record to a file.
|
* Emits a metrics record to a file.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void emitRecord(String contextName, String recordName, OutputRecord outRec) {
|
public void emitRecord(String contextName, String recordName, OutputRecord outRec) {
|
||||||
writer.print(contextName);
|
writer.print(contextName);
|
||||||
@ -147,6 +151,7 @@ public void emitRecord(String contextName, String recordName, OutputRecord outRe
|
|||||||
/**
|
/**
|
||||||
* Flushes the output writer, forcing updates to disk.
|
* Flushes the output writer, forcing updates to disk.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void flush() {
|
public void flush() {
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
@ -91,6 +91,7 @@ public class GangliaContext extends AbstractMetricsContext {
|
|||||||
public GangliaContext() {
|
public GangliaContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void init(String contextName, ContextFactory factory) {
|
public void init(String contextName, ContextFactory factory) {
|
||||||
super.init(contextName, factory);
|
super.init(contextName, factory);
|
||||||
@ -106,8 +107,7 @@ public void init(String contextName, ContextFactory factory) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
datagramSocket = new DatagramSocket();
|
datagramSocket = new DatagramSocket();
|
||||||
}
|
} catch (SocketException se) {
|
||||||
catch (SocketException se) {
|
|
||||||
se.printStackTrace();
|
se.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,6 +123,7 @@ public void close() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void emitRecord(String contextName, String recordName,
|
public void emitRecord(String contextName, String recordName,
|
||||||
OutputRecord outRec)
|
OutputRecord outRec)
|
||||||
|
@ -43,6 +43,7 @@ public class GangliaContext31 extends GangliaContext {
|
|||||||
private static final Log LOG =
|
private static final Log LOG =
|
||||||
LogFactory.getLog("org.apache.hadoop.util.GangliaContext31");
|
LogFactory.getLog("org.apache.hadoop.util.GangliaContext31");
|
||||||
|
|
||||||
|
@Override
|
||||||
public void init(String contextName, ContextFactory factory) {
|
public void init(String contextName, ContextFactory factory) {
|
||||||
super.init(contextName, 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)
|
protected void emitMetric(String name, String type, String value)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -94,6 +94,7 @@ private JvmMetrics(String processName, String sessionId,
|
|||||||
* This will be called periodically (with the period being configuration
|
* This will be called periodically (with the period being configuration
|
||||||
* dependent).
|
* dependent).
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void doUpdates(MetricsContext context) {
|
public void doUpdates(MetricsContext context) {
|
||||||
doMemoryUpdates();
|
doMemoryUpdates();
|
||||||
doGarbageCollectionUpdates();
|
doGarbageCollectionUpdates();
|
||||||
|
@ -116,6 +116,7 @@ protected AbstractMetricsContext() {
|
|||||||
/**
|
/**
|
||||||
* Initializes the context.
|
* Initializes the context.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void init(String contextName, ContextFactory factory)
|
public void init(String contextName, ContextFactory factory)
|
||||||
{
|
{
|
||||||
this.contextName = contextName;
|
this.contextName = contextName;
|
||||||
@ -152,6 +153,7 @@ protected Map<String,String> getAttributeTable(String tableName) {
|
|||||||
/**
|
/**
|
||||||
* Returns the context name.
|
* Returns the context name.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getContextName() {
|
public String getContextName() {
|
||||||
return contextName;
|
return contextName;
|
||||||
}
|
}
|
||||||
@ -166,6 +168,7 @@ public ContextFactory getContextFactory() {
|
|||||||
/**
|
/**
|
||||||
* Starts or restarts monitoring, the emitting of metrics records.
|
* Starts or restarts monitoring, the emitting of metrics records.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void startMonitoring()
|
public synchronized void startMonitoring()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (!isMonitoring) {
|
if (!isMonitoring) {
|
||||||
@ -178,6 +181,7 @@ public synchronized void startMonitoring()
|
|||||||
* Stops monitoring. This does not free buffered data.
|
* Stops monitoring. This does not free buffered data.
|
||||||
* @see #close()
|
* @see #close()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void stopMonitoring() {
|
public synchronized void stopMonitoring() {
|
||||||
if (isMonitoring) {
|
if (isMonitoring) {
|
||||||
stopTimer();
|
stopTimer();
|
||||||
@ -188,6 +192,7 @@ public synchronized void stopMonitoring() {
|
|||||||
/**
|
/**
|
||||||
* Returns true if monitoring is currently in progress.
|
* Returns true if monitoring is currently in progress.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean isMonitoring() {
|
public boolean isMonitoring() {
|
||||||
return isMonitoring;
|
return isMonitoring;
|
||||||
}
|
}
|
||||||
@ -196,6 +201,7 @@ public boolean isMonitoring() {
|
|||||||
* Stops monitoring and frees buffered data, returning this
|
* Stops monitoring and frees buffered data, returning this
|
||||||
* object to its initial state.
|
* object to its initial state.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
stopMonitoring();
|
stopMonitoring();
|
||||||
clearUpdaters();
|
clearUpdaters();
|
||||||
@ -209,6 +215,7 @@ public synchronized void close() {
|
|||||||
* @param recordName the name of the record
|
* @param recordName the name of the record
|
||||||
* @throws MetricsException if recordName conflicts with configuration data
|
* @throws MetricsException if recordName conflicts with configuration data
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final synchronized MetricsRecord createRecord(String recordName) {
|
public final synchronized MetricsRecord createRecord(String recordName) {
|
||||||
if (bufferedData.get(recordName) == null) {
|
if (bufferedData.get(recordName) == null) {
|
||||||
bufferedData.put(recordName, new RecordMap());
|
bufferedData.put(recordName, new RecordMap());
|
||||||
@ -232,6 +239,7 @@ protected MetricsRecord newRecord(String recordName) {
|
|||||||
* @param updater object to be run periodically; it should update
|
* @param updater object to be run periodically; it should update
|
||||||
* some metrics records
|
* some metrics records
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void registerUpdater(final Updater updater) {
|
public synchronized void registerUpdater(final Updater updater) {
|
||||||
if (!updaters.contains(updater)) {
|
if (!updaters.contains(updater)) {
|
||||||
updaters.add(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
|
* @param updater object to be removed from the callback list
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void unregisterUpdater(Updater updater) {
|
public synchronized void unregisterUpdater(Updater updater) {
|
||||||
updaters.remove(updater);
|
updaters.remove(updater);
|
||||||
}
|
}
|
||||||
@ -259,11 +268,11 @@ private synchronized void startTimer() {
|
|||||||
timer = new Timer("Timer thread for monitoring " + getContextName(),
|
timer = new Timer("Timer thread for monitoring " + getContextName(),
|
||||||
true);
|
true);
|
||||||
TimerTask task = new TimerTask() {
|
TimerTask task = new TimerTask() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
timerEvent();
|
timerEvent();
|
||||||
}
|
} catch (IOException ioe) {
|
||||||
catch (IOException ioe) {
|
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,8 +306,7 @@ private void timerEvent() throws IOException {
|
|||||||
for (Updater updater : myUpdaters) {
|
for (Updater updater : myUpdaters) {
|
||||||
try {
|
try {
|
||||||
updater.doUpdates(this);
|
updater.doUpdates(this);
|
||||||
}
|
} catch (Throwable throwable) {
|
||||||
catch (Throwable throwable) {
|
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -328,6 +336,7 @@ private synchronized void emitRecords() throws IOException {
|
|||||||
* Useful for monitoring systems that are polling-based.
|
* Useful for monitoring systems that are polling-based.
|
||||||
* @return A non-null collection of all monitoring records.
|
* @return A non-null collection of all monitoring records.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized Map<String, Collection<OutputRecord>> getAllRecords() {
|
public synchronized Map<String, Collection<OutputRecord>> getAllRecords() {
|
||||||
Map<String, Collection<OutputRecord>> out = new TreeMap<String, Collection<OutputRecord>>();
|
Map<String, Collection<OutputRecord>> out = new TreeMap<String, Collection<OutputRecord>>();
|
||||||
for (String recordName : bufferedData.keySet()) {
|
for (String recordName : bufferedData.keySet()) {
|
||||||
@ -449,6 +458,7 @@ protected void remove(MetricsRecordImpl record) {
|
|||||||
/**
|
/**
|
||||||
* Returns the timer period.
|
* Returns the timer period.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public int getPeriod() {
|
public int getPeriod() {
|
||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public class CompositeContext extends AbstractMetricsContext {
|
|||||||
public CompositeContext() {
|
public CompositeContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void init(String contextName, ContextFactory factory) {
|
public void init(String contextName, ContextFactory factory) {
|
||||||
super.init(contextName, 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 {
|
public Object invoke(Object p, Method m, Object[] args) throws Throwable {
|
||||||
if (m_getRecordName.equals(m)) {
|
if (m_getRecordName.equals(m)) {
|
||||||
return recordName;
|
return recordName;
|
||||||
|
@ -57,6 +57,7 @@ protected MetricsRecordImpl(String recordName, AbstractMetricsContext context)
|
|||||||
*
|
*
|
||||||
* @return the record name
|
* @return the record name
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getRecordName() {
|
public String getRecordName() {
|
||||||
return recordName;
|
return recordName;
|
||||||
}
|
}
|
||||||
@ -68,6 +69,7 @@ public String getRecordName() {
|
|||||||
* @param tagValue new value of the tag
|
* @param tagValue new value of the tag
|
||||||
* @throws MetricsException if the tagName conflicts with the configuration
|
* @throws MetricsException if the tagName conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setTag(String tagName, String tagValue) {
|
public void setTag(String tagName, String tagValue) {
|
||||||
if (tagValue == null) {
|
if (tagValue == null) {
|
||||||
tagValue = "";
|
tagValue = "";
|
||||||
@ -82,6 +84,7 @@ public void setTag(String tagName, String tagValue) {
|
|||||||
* @param tagValue new value of the tag
|
* @param tagValue new value of the tag
|
||||||
* @throws MetricsException if the tagName conflicts with the configuration
|
* @throws MetricsException if the tagName conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setTag(String tagName, int tagValue) {
|
public void setTag(String tagName, int tagValue) {
|
||||||
tagTable.put(tagName, Integer.valueOf(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
|
* @param tagValue new value of the tag
|
||||||
* @throws MetricsException if the tagName conflicts with the configuration
|
* @throws MetricsException if the tagName conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setTag(String tagName, long tagValue) {
|
public void setTag(String tagName, long tagValue) {
|
||||||
tagTable.put(tagName, Long.valueOf(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
|
* @param tagValue new value of the tag
|
||||||
* @throws MetricsException if the tagName conflicts with the configuration
|
* @throws MetricsException if the tagName conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setTag(String tagName, short tagValue) {
|
public void setTag(String tagName, short tagValue) {
|
||||||
tagTable.put(tagName, Short.valueOf(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
|
* @param tagValue new value of the tag
|
||||||
* @throws MetricsException if the tagName conflicts with the configuration
|
* @throws MetricsException if the tagName conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setTag(String tagName, byte tagValue) {
|
public void setTag(String tagName, byte tagValue) {
|
||||||
tagTable.put(tagName, Byte.valueOf(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.
|
* Removes any tag of the specified name.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void removeTag(String tagName) {
|
public void removeTag(String tagName) {
|
||||||
tagTable.remove(tagName);
|
tagTable.remove(tagName);
|
||||||
}
|
}
|
||||||
@ -134,6 +141,7 @@ public void removeTag(String tagName) {
|
|||||||
* @throws MetricsException if the metricName or the type of the metricValue
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMetric(String metricName, int metricValue) {
|
public void setMetric(String metricName, int metricValue) {
|
||||||
setAbsolute(metricName, Integer.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMetric(String metricName, long metricValue) {
|
public void setMetric(String metricName, long metricValue) {
|
||||||
setAbsolute(metricName, Long.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMetric(String metricName, short metricValue) {
|
public void setMetric(String metricName, short metricValue) {
|
||||||
setAbsolute(metricName, Short.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMetric(String metricName, byte metricValue) {
|
public void setMetric(String metricName, byte metricValue) {
|
||||||
setAbsolute(metricName, Byte.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setMetric(String metricName, float metricValue) {
|
public void setMetric(String metricName, float metricValue) {
|
||||||
setAbsolute(metricName, new 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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void incrMetric(String metricName, int metricValue) {
|
public void incrMetric(String metricName, int metricValue) {
|
||||||
setIncrement(metricName, Integer.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void incrMetric(String metricName, long metricValue) {
|
public void incrMetric(String metricName, long metricValue) {
|
||||||
setIncrement(metricName, Long.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void incrMetric(String metricName, short metricValue) {
|
public void incrMetric(String metricName, short metricValue) {
|
||||||
setIncrement(metricName, Short.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void incrMetric(String metricName, byte metricValue) {
|
public void incrMetric(String metricName, byte metricValue) {
|
||||||
setIncrement(metricName, Byte.valueOf(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
|
* @throws MetricsException if the metricName or the type of the metricValue
|
||||||
* conflicts with the configuration
|
* conflicts with the configuration
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void incrMetric(String metricName, float metricValue) {
|
public void incrMetric(String metricName, float metricValue) {
|
||||||
setIncrement(metricName, new 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;
|
* If the tag values match an existing row, that row is updated;
|
||||||
* otherwise, a new row is added.
|
* otherwise, a new row is added.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
context.update(this);
|
context.update(this);
|
||||||
}
|
}
|
||||||
@ -267,6 +285,7 @@ public void update() {
|
|||||||
* Removes the row, if it exists, in the buffered data table having tags
|
* Removes the row, if it exists, in the buffered data table having tags
|
||||||
* that equal the tags that have been set on this record.
|
* that equal the tags that have been set on this record.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
context.remove(this);
|
context.remove(this);
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public class NoEmitMetricsContext extends AbstractMetricsContext {
|
|||||||
public NoEmitMetricsContext() {
|
public NoEmitMetricsContext() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void init(String contextName, ContextFactory factory) {
|
public void init(String contextName, ContextFactory factory) {
|
||||||
super.init(contextName, factory);
|
super.init(contextName, factory);
|
||||||
@ -49,6 +50,7 @@ public void init(String contextName, ContextFactory factory) {
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of emitRecord
|
* Do-nothing version of emitRecord
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
protected void emitRecord(String contextName, String recordName,
|
protected void emitRecord(String contextName, String recordName,
|
||||||
OutputRecord outRec) {
|
OutputRecord outRec) {
|
||||||
|
@ -40,6 +40,7 @@ public NullContext() {
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of startMonitoring
|
* Do-nothing version of startMonitoring
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void startMonitoring() {
|
public void startMonitoring() {
|
||||||
}
|
}
|
||||||
@ -47,6 +48,7 @@ public void startMonitoring() {
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of emitRecord
|
* Do-nothing version of emitRecord
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
protected void emitRecord(String contextName, String recordName,
|
protected void emitRecord(String contextName, String recordName,
|
||||||
OutputRecord outRec)
|
OutputRecord outRec)
|
||||||
@ -55,6 +57,7 @@ protected void emitRecord(String contextName, String recordName,
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of update
|
* Do-nothing version of update
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
protected void update(MetricsRecordImpl record) {
|
protected void update(MetricsRecordImpl record) {
|
||||||
}
|
}
|
||||||
@ -62,6 +65,7 @@ protected void update(MetricsRecordImpl record) {
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of remove
|
* Do-nothing version of remove
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
protected void remove(MetricsRecordImpl record) {
|
protected void remove(MetricsRecordImpl record) {
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ public class NullContextWithUpdateThread extends AbstractMetricsContext {
|
|||||||
public NullContextWithUpdateThread() {
|
public NullContextWithUpdateThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public void init(String contextName, ContextFactory factory) {
|
public void init(String contextName, ContextFactory factory) {
|
||||||
super.init(contextName, factory);
|
super.init(contextName, factory);
|
||||||
@ -56,6 +57,7 @@ public void init(String contextName, ContextFactory factory) {
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of emitRecord
|
* Do-nothing version of emitRecord
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
protected void emitRecord(String contextName, String recordName,
|
protected void emitRecord(String contextName, String recordName,
|
||||||
OutputRecord outRec)
|
OutputRecord outRec)
|
||||||
@ -64,6 +66,7 @@ protected void emitRecord(String contextName, String recordName,
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of update
|
* Do-nothing version of update
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
protected void update(MetricsRecordImpl record) {
|
protected void update(MetricsRecordImpl record) {
|
||||||
}
|
}
|
||||||
@ -71,6 +74,7 @@ protected void update(MetricsRecordImpl record) {
|
|||||||
/**
|
/**
|
||||||
* Do-nothing version of remove
|
* Do-nothing version of remove
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
protected void remove(MetricsRecordImpl record) {
|
protected void remove(MetricsRecordImpl record) {
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ public synchronized int get() {
|
|||||||
*
|
*
|
||||||
* @param mr
|
* @param mr
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||||
if (changed) {
|
if (changed) {
|
||||||
try {
|
try {
|
||||||
|
@ -82,6 +82,7 @@ public synchronized long get() {
|
|||||||
*
|
*
|
||||||
* @param mr
|
* @param mr
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||||
if (changed)
|
if (changed)
|
||||||
mr.setMetric(getName(), value);
|
mr.setMetric(getName(), value);
|
||||||
|
@ -101,6 +101,7 @@ private synchronized void intervalHeartBeat() {
|
|||||||
*
|
*
|
||||||
* @param mr
|
* @param mr
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||||
intervalHeartBeat();
|
intervalHeartBeat();
|
||||||
try {
|
try {
|
||||||
|
@ -97,6 +97,7 @@ private synchronized void intervalHeartBeat() {
|
|||||||
*
|
*
|
||||||
* @param mr
|
* @param mr
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||||
intervalHeartBeat();
|
intervalHeartBeat();
|
||||||
try {
|
try {
|
||||||
|
@ -144,6 +144,7 @@ private synchronized void intervalHeartBeat() {
|
|||||||
*
|
*
|
||||||
* @param mr
|
* @param mr
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public synchronized void pushMetric(final MetricsRecord mr) {
|
public synchronized void pushMetric(final MetricsRecord mr) {
|
||||||
intervalHeartBeat();
|
intervalHeartBeat();
|
||||||
try {
|
try {
|
||||||
|
@ -114,8 +114,7 @@ static MetricsConfig loadFirst(String prefix, String... fileNames) {
|
|||||||
MetricsConfig mc = new MetricsConfig(cf, prefix);
|
MetricsConfig mc = new MetricsConfig(cf, prefix);
|
||||||
LOG.debug(mc);
|
LOG.debug(mc);
|
||||||
return mc;
|
return mc;
|
||||||
}
|
} catch (ConfigurationException e) {
|
||||||
catch (ConfigurationException e) {
|
|
||||||
if (e.getMessage().startsWith("Cannot locate configuration")) {
|
if (e.getMessage().startsWith("Cannot locate configuration")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -198,8 +197,7 @@ <T extends MetricsPlugin> T getPlugin(String name) {
|
|||||||
T plugin = (T) cls.newInstance();
|
T plugin = (T) cls.newInstance();
|
||||||
plugin.init(name.isEmpty() ? this : subset(name));
|
plugin.init(name.isEmpty() ? this : subset(name));
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
throw new MetricsConfigException("Error creating plugin: "+ clsName, e);
|
throw new MetricsConfigException("Error creating plugin: "+ clsName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,8 +227,7 @@ ClassLoader getPluginLoader() {
|
|||||||
LOG.debug(jar);
|
LOG.debug(jar);
|
||||||
urls[i++] = new URL(jar);
|
urls[i++] = new URL(jar);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
throw new MetricsConfigException(e);
|
throw new MetricsConfigException(e);
|
||||||
}
|
}
|
||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
@ -276,8 +273,9 @@ static String toString(Configuration c) {
|
|||||||
PrintStream ps = new PrintStream(buffer);
|
PrintStream ps = new PrintStream(buffer);
|
||||||
PropertiesConfiguration tmp = new PropertiesConfiguration();
|
PropertiesConfiguration tmp = new PropertiesConfiguration();
|
||||||
tmp.copy(c);
|
tmp.copy(c);
|
||||||
try { tmp.save(ps); }
|
try {
|
||||||
catch (Exception e) {
|
tmp.save(ps);
|
||||||
|
} catch (Exception e) {
|
||||||
throw new MetricsConfigException(e);
|
throw new MetricsConfigException(e);
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -107,11 +107,9 @@ void publishMetricsFromQueue() {
|
|||||||
retryDelay = firstRetryDelay;
|
retryDelay = firstRetryDelay;
|
||||||
n = retryCount;
|
n = retryCount;
|
||||||
inError = false;
|
inError = false;
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
catch (InterruptedException e) {
|
|
||||||
LOG.info(name +" thread interrupted.");
|
LOG.info(name +" thread interrupted.");
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
int retryWindow = Math.max(0, 1000 / 2 * retryDelay - minDelay);
|
int retryWindow = Math.max(0, 1000 / 2 * retryDelay - minDelay);
|
||||||
int awhile = rng.nextInt(retryWindow) + minDelay;
|
int awhile = rng.nextInt(retryWindow) + minDelay;
|
||||||
@ -124,8 +122,7 @@ void publishMetricsFromQueue() {
|
|||||||
LOG.info(name +" thread interrupted while waiting for retry", e2);
|
LOG.info(name +" thread interrupted while waiting for retry", e2);
|
||||||
}
|
}
|
||||||
--n;
|
--n;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!inError) {
|
if (!inError) {
|
||||||
LOG.error("Got sink exception and over retry limit, "+
|
LOG.error("Got sink exception and over retry limit, "+
|
||||||
"suppressing further error messages", e);
|
"suppressing further error messages", e);
|
||||||
@ -174,8 +171,7 @@ void stop() {
|
|||||||
sinkThread.interrupt();
|
sinkThread.interrupt();
|
||||||
try {
|
try {
|
||||||
sinkThread.join();
|
sinkThread.join();
|
||||||
}
|
} catch (InterruptedException e) {
|
||||||
catch (InterruptedException e) {
|
|
||||||
LOG.warn("Stop interrupted", e);
|
LOG.warn("Stop interrupted", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,8 +192,7 @@ Iterable<MetricsRecordImpl> getMetrics(MetricsCollectorImpl builder,
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
source.getMetrics(builder, all);
|
source.getMetrics(builder, all);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
LOG.error("Error getting metrics from source "+ name, e);
|
LOG.error("Error getting metrics from source "+ name, e);
|
||||||
}
|
}
|
||||||
for (MetricsRecordBuilderImpl rb : builder) {
|
for (MetricsRecordBuilderImpl rb : builder) {
|
||||||
|
@ -287,8 +287,7 @@ public Object invoke(Object proxy, Method method, Object[] args)
|
|||||||
throws Throwable {
|
throws Throwable {
|
||||||
try {
|
try {
|
||||||
return method.invoke(callback, args);
|
return method.invoke(callback, args);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
// These are not considered fatal.
|
// These are not considered fatal.
|
||||||
LOG.warn("Caught exception in callback "+ method.getName(), e);
|
LOG.warn("Caught exception in callback "+ method.getName(), e);
|
||||||
}
|
}
|
||||||
@ -332,11 +331,11 @@ private synchronized void startTimer() {
|
|||||||
long millis = period * 1000;
|
long millis = period * 1000;
|
||||||
timer = new Timer("Timer for '"+ prefix +"' metrics system", true);
|
timer = new Timer("Timer for '"+ prefix +"' metrics system", true);
|
||||||
timer.scheduleAtFixedRate(new TimerTask() {
|
timer.scheduleAtFixedRate(new TimerTask() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
onTimerEvent();
|
onTimerEvent();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
LOG.warn(e);
|
LOG.warn(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -451,8 +450,7 @@ private synchronized void configureSinks() {
|
|||||||
conf.getString(DESC_KEY, sinkName), conf);
|
conf.getString(DESC_KEY, sinkName), conf);
|
||||||
sa.start();
|
sa.start();
|
||||||
sinks.put(sinkName, sa);
|
sinks.put(sinkName, sa);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
LOG.warn("Error creating sink '"+ sinkName +"'", e);
|
LOG.warn("Error creating sink '"+ sinkName +"'", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -494,8 +492,7 @@ private void clearConfigs() {
|
|||||||
static String getHostname() {
|
static String getHostname() {
|
||||||
try {
|
try {
|
||||||
return InetAddress.getLocalHost().getHostName();
|
return InetAddress.getLocalHost().getHostName();
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
LOG.error("Error getting localhost name. Using 'localhost'...", e);
|
LOG.error("Error getting localhost name. Using 'localhost'...", e);
|
||||||
}
|
}
|
||||||
return "localhost";
|
return "localhost";
|
||||||
@ -555,6 +552,7 @@ public synchronized boolean shutdown() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MetricsSource getSource(String name) {
|
public MetricsSource getSource(String name) {
|
||||||
return allSources.get(name);
|
return allSources.get(name);
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,7 @@ MutableMetric newCounter(final Class<?> type) {
|
|||||||
Object ret = method.invoke(obj, (Object[])null);
|
Object ret = method.invoke(obj, (Object[])null);
|
||||||
if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue());
|
if (isInt(type)) rb.addCounter(info, ((Integer) ret).intValue());
|
||||||
else rb.addCounter(info, ((Long) ret).longValue());
|
else rb.addCounter(info, ((Long) ret).longValue());
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
LOG.error("Error invoking method "+ method.getName(), 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 (isLong(t)) rb.addGauge(info, ((Long) ret).longValue());
|
||||||
else if (isFloat(t)) rb.addGauge(info, ((Float) ret).floatValue());
|
else if (isFloat(t)) rb.addGauge(info, ((Float) ret).floatValue());
|
||||||
else rb.addGauge(info, ((Double) ret).doubleValue());
|
else rb.addGauge(info, ((Double) ret).doubleValue());
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
LOG.error("Error invoking method "+ method.getName(), ex);
|
LOG.error("Error invoking method "+ method.getName(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,8 +128,7 @@ MutableMetric newTag(Class<?> resType) {
|
|||||||
try {
|
try {
|
||||||
Object ret = method.invoke(obj, (Object[]) null);
|
Object ret = method.invoke(obj, (Object[]) null);
|
||||||
rb.tag(info, (String) ret);
|
rb.tag(info, (String) ret);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
LOG.error("Error invoking method "+ method.getName(), ex);
|
LOG.error("Error invoking method "+ method.getName(), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,7 @@ private MetricsRegistry initRegistry(Object source) {
|
|||||||
r = (MetricsRegistry) field.get(source);
|
r = (MetricsRegistry) field.get(source);
|
||||||
hasRegistry = r != null;
|
hasRegistry = r != null;
|
||||||
break;
|
break;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
LOG.warn("Error accessing field "+ field, e);
|
LOG.warn("Error accessing field "+ field, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -123,8 +122,7 @@ private void add(Object source, Field field) {
|
|||||||
// skip fields already set
|
// skip fields already set
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
if (field.get(source) != null) continue;
|
if (field.get(source) != null) continue;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
LOG.warn("Error accessing field "+ field +" annotated with"+
|
LOG.warn("Error accessing field "+ field +" annotated with"+
|
||||||
annotation, e);
|
annotation, e);
|
||||||
continue;
|
continue;
|
||||||
@ -135,8 +133,7 @@ private void add(Object source, Field field) {
|
|||||||
try {
|
try {
|
||||||
field.set(source, mutable);
|
field.set(source, mutable);
|
||||||
hasAtMetric = true;
|
hasAtMetric = true;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
throw new MetricsException("Error setting field "+ field +
|
throw new MetricsException("Error setting field "+ field +
|
||||||
" annotated with "+ annotation, e);
|
" annotated with "+ annotation, e);
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ public void set(long value) {
|
|||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
public void snapshot(MetricsRecordBuilder builder, boolean all) {
|
||||||
if (all || changed()) {
|
if (all || changed()) {
|
||||||
builder.addGauge(info(), value);
|
builder.addGauge(info(), value);
|
||||||
|
@ -109,6 +109,7 @@ public synchronized void add(long value) {
|
|||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) {
|
public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) {
|
||||||
if (all || changed()) {
|
if (all || changed()) {
|
||||||
numSamples += intervalStat.numSamples();
|
numSamples += intervalStat.numSamples();
|
||||||
|
@ -48,8 +48,7 @@ public void init(SubsetConfiguration conf) {
|
|||||||
writer = filename == null
|
writer = filename == null
|
||||||
? new PrintWriter(System.out)
|
? new PrintWriter(System.out)
|
||||||
: new PrintWriter(new FileWriter(new File(filename), true));
|
: new PrintWriter(new FileWriter(new File(filename), true));
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
throw new MetricsException("Error creating "+ filename, 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
|
* org.apache.hadoop.metrics2.MetricsPlugin#init(org.apache.commons.configuration
|
||||||
* .SubsetConfiguration)
|
* .SubsetConfiguration)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void init(SubsetConfiguration conf) {
|
public void init(SubsetConfiguration conf) {
|
||||||
LOG.debug("Initializing the GangliaSink for Ganglia metrics.");
|
LOG.debug("Initializing the GangliaSink for Ganglia metrics.");
|
||||||
|
|
||||||
@ -155,6 +156,7 @@ public void init(SubsetConfiguration conf) {
|
|||||||
*
|
*
|
||||||
* @see org.apache.hadoop.metrics2.MetricsSink#flush()
|
* @see org.apache.hadoop.metrics2.MetricsSink#flush()
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void flush() {
|
public void flush() {
|
||||||
// nothing to do as we are not buffering data
|
// 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
|
* @param gSlope The slope for this metric
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void emitMetric(String groupName, String name, String type,
|
protected void emitMetric(String groupName, String name, String type,
|
||||||
String value, GangliaConf gConf, GangliaSlope gSlope)
|
String value, GangliaConf gConf, GangliaSlope gSlope)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user