本文整理汇总了Java中org.apache.hadoop.metrics2.MetricsRecordBuilder.addGauge方法的典型用法代码示例。如果您正苦于以下问题:Java MetricsRecordBuilder.addGauge方法的具体用法?Java MetricsRecordBuilder.addGauge怎么用?Java MetricsRecordBuilder.addGauge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.metrics2.MetricsRecordBuilder
的用法示例。
在下文中一共展示了MetricsRecordBuilder.addGauge方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: snapshot
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
@Override
public synchronized void snapshot(MetricsRecordBuilder builder, boolean all) {
if (all || changed()) {
builder.addGauge(numInfo, previousCount);
for (int i = 0; i < quantiles.length; i++) {
long newValue = 0;
// If snapshot is null, we failed to update since the window was empty
if (previousSnapshot != null) {
newValue = previousSnapshot.get(quantiles[i]);
}
builder.addGauge(quantileInfos[i], newValue);
}
if (changed()) {
clearChanged();
}
}
}
示例2: newGauge
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
MutableMetric newGauge(final Class<?> t) {
if (isInt(t) || isLong(t) || isFloat(t) || isDouble(t)) {
return new MutableMetric() {
@Override public void snapshot(MetricsRecordBuilder rb, boolean all) {
try {
Object ret = method.invoke(obj, (Object[]) null);
if (isInt(t)) rb.addGauge(info, ((Integer) ret).intValue());
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) {
LOG.error("Error invoking method "+ method.getName(), ex);
}
}
};
}
throw new MetricsException("Unsupported gauge type: "+ t.getName());
}
示例3: getMetrics
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
StartupProgressView prog = startupProgress.createView();
MetricsRecordBuilder builder = collector.addRecord(
STARTUP_PROGRESS_METRICS_INFO);
builder.addCounter(info("ElapsedTime", "overall elapsed time"),
prog.getElapsedTime());
builder.addGauge(info("PercentComplete", "overall percent complete"),
prog.getPercentComplete());
for (Phase phase: prog.getPhases()) {
addCounter(builder, phase, "Count", " count", prog.getCount(phase));
addCounter(builder, phase, "ElapsedTime", " elapsed time",
prog.getElapsedTime(phase));
addCounter(builder, phase, "Total", " total", prog.getTotal(phase));
addGauge(builder, phase, "PercentComplete", " percent complete",
prog.getPercentComplete(phase));
}
}
示例4: newGauge
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
MutableMetric newGauge(final Class<?> t) {
if (isInt(t) || isLong(t) || isFloat(t) || isDouble(t)) {
return new MutableMetric() {
@Override public void snapshot(MetricsRecordBuilder rb, boolean all) {
try {
Object ret = method.invoke(obj, (Object[]) null);
if (isInt(t)) rb.addGauge(info, ((Integer) ret).intValue());
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) {
LOG.error("Error invoking method "+ method.getName(), ex);
}
}
};
}
throw new MetricsException("Unsupported gauge type: "+ t.getName());
}
示例5: updateSnapshotMetrics
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
public void updateSnapshotMetrics(MetricsRecordBuilder metricsRecordBuilder) {
final Snapshot s = sample.getSnapshot();
metricsRecordBuilder.addCounter(Interns.info(name + NUM_OPS_METRIC_NAME, desc), count.get());
metricsRecordBuilder.addGauge(Interns.info(name + MIN_METRIC_NAME, desc), getMin());
metricsRecordBuilder.addGauge(Interns.info(name + MAX_METRIC_NAME, desc), getMax());
metricsRecordBuilder.addGauge(Interns.info(name + MEAN_METRIC_NAME, desc), getMean());
metricsRecordBuilder.addGauge(Interns.info(name + MEDIAN_METRIC_NAME, desc), s.getMedian());
metricsRecordBuilder.addGauge(Interns.info(name + SEVENTY_FIFTH_PERCENTILE_METRIC_NAME, desc),
s.get75thPercentile());
metricsRecordBuilder.addGauge(Interns.info(name + NINETIETH_PERCENTILE_METRIC_NAME, desc),
s.getValue(0.90));
metricsRecordBuilder.addGauge(Interns.info(name + NINETY_FIFTH_PERCENTILE_METRIC_NAME, desc),
s.get95thPercentile());
metricsRecordBuilder.addGauge(Interns.info(name + NINETY_NINETH_PERCENTILE_METRIC_NAME, desc),
s.get99thPercentile());
}
示例6: snapshot
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
@Override
public void snapshot(MetricsRecordBuilder builder, boolean all) {
if (all || changed()) {
builder.addGauge(info(), value());
clearChanged();
}
}
示例7: getMetrics
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
MetricsRecordBuilder rb =
collector.addRecord("purgablesource")
.setContext("test");
lastKeyName = "key" + nextKey++;
rb.addGauge(info(lastKeyName, "desc"), 1);
}
示例8: getMetrics
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
/**
* Yes this is a get function that doesn't return anything. Thanks Hadoop for breaking all
* expectations of java programmers. Instead of returning anything Hadoop metrics expects
* getMetrics to push the metrics into the collector.
*
* @param collector the collector
* @param all get all the metrics regardless of when they last changed.
*/
@Override
public void getMetrics(MetricsCollector collector, boolean all) {
MetricsRecordBuilder mrb = collector.addRecord(metricsName);
if (regionSources != null) {
for (MetricsRegionSource regionMetricSource : regionSources) {
if (regionMetricSource instanceof MetricsRegionSourceImpl) {
((MetricsRegionSourceImpl) regionMetricSource).snapshot(mrb, all);
}
}
mrb.addGauge(Interns.info(NUM_REGIONS, NUMBER_OF_REGIONS_DESC), regionSources.size());
metricsRegistry.snapshot(mrb, all);
}
}
示例9: snapshot
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
public void snapshot(MetricsRecordBuilder builder, boolean all) {
if (all || changed()) {
builder.addGauge(info(), value());
clearChanged();
}
}
示例10: snapshot
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
void snapshot(MetricsRecordBuilder mrb, boolean ignored) {
// If there is a close that started be double extra sure
// that we're not getting any locks and not putting data
// into the metrics that should be removed. So early out
// before even getting the lock.
if (closed.get()) {
return;
}
// Grab the read
// This ensures that removes of the metrics
// can't happen while we are putting them back in.
synchronized (this) {
// It's possible that a close happened between checking
// the closed variable and getting the lock.
if (closed.get()) {
return;
}
mrb.addGauge(
Interns.info(
regionNamePrefix + MetricsRegionServerSource.STORE_COUNT,
MetricsRegionServerSource.STORE_COUNT_DESC),
this.regionWrapper.getNumStores());
mrb.addGauge(Interns.info(
regionNamePrefix + MetricsRegionServerSource.STOREFILE_COUNT,
MetricsRegionServerSource.STOREFILE_COUNT_DESC),
this.regionWrapper.getNumStoreFiles());
mrb.addGauge(Interns.info(
regionNamePrefix + MetricsRegionServerSource.MEMSTORE_SIZE,
MetricsRegionServerSource.MEMSTORE_SIZE_DESC),
this.regionWrapper.getMemstoreSize());
mrb.addGauge(Interns.info(
regionNamePrefix + MetricsRegionServerSource.STOREFILE_SIZE,
MetricsRegionServerSource.STOREFILE_SIZE_DESC),
this.regionWrapper.getStoreFileSize());
mrb.addCounter(Interns.info(
regionNamePrefix + MetricsRegionSource.COMPACTIONS_COMPLETED_COUNT,
MetricsRegionSource.COMPACTIONS_COMPLETED_DESC),
this.regionWrapper.getNumCompactionsCompleted());
mrb.addCounter(Interns.info(
regionNamePrefix + MetricsRegionSource.NUM_BYTES_COMPACTED_COUNT,
MetricsRegionSource.NUM_BYTES_COMPACTED_DESC),
this.regionWrapper.getNumBytesCompacted());
mrb.addCounter(Interns.info(
regionNamePrefix + MetricsRegionSource.NUM_FILES_COMPACTED_COUNT,
MetricsRegionSource.NUM_FILES_COMPACTED_DESC),
this.regionWrapper.getNumFilesCompacted());
mrb.addCounter(Interns.info(
regionNamePrefix + MetricsRegionServerSource.READ_REQUEST_COUNT,
MetricsRegionServerSource.READ_REQUEST_COUNT_DESC),
this.regionWrapper.getReadRequestCount());
mrb.addCounter(Interns.info(
regionNamePrefix + MetricsRegionServerSource.WRITE_REQUEST_COUNT,
MetricsRegionServerSource.WRITE_REQUEST_COUNT_DESC),
this.regionWrapper.getWriteRequestCount());
mrb.addCounter(Interns.info(regionNamePrefix + MetricsRegionSource.REPLICA_ID,
MetricsRegionSource.REPLICA_ID_DESC),
this.regionWrapper.getReplicaId());
}
}
示例11: addGauge
import org.apache.hadoop.metrics2.MetricsRecordBuilder; //导入方法依赖的package包/类
/**
* Adds a gauge with a name built by using the specified phase's name as prefix
* and then appending the specified suffix.
*
* @param builder MetricsRecordBuilder to receive counter
* @param phase Phase to add
* @param nameSuffix String suffix of metric name
* @param descSuffix String suffix of metric description
* @param value float gauge value
*/
private static void addGauge(MetricsRecordBuilder builder, Phase phase,
String nameSuffix, String descSuffix, float value) {
MetricsInfo metricsInfo = info(phase.getName() + nameSuffix,
phase.getDescription() + descSuffix);
builder.addGauge(metricsInfo, value);
}