本文整理汇总了Java中org.apache.hadoop.metrics.util.MetricsRegistry类的典型用法代码示例。如果您正苦于以下问题:Java MetricsRegistry类的具体用法?Java MetricsRegistry怎么用?Java MetricsRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricsRegistry类属于org.apache.hadoop.metrics.util包,在下文中一共展示了MetricsRegistry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ExactCounterMetric
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
/**
* Constructor to create a new counter metric
* @param nam the name to publish this metric under
* @param registry where the metrics object will be registered
* @param description metrics description
* @param topN how many 'keys' to publish metrics on
*/
public ExactCounterMetric(final String nam, final MetricsRegistry registry,
final String description, int topN) {
super(nam, description);
this.counts = new MapMaker().makeComputingMap(
new Function<String, Counter>() {
@Override
public Counter apply(String input) {
return new Counter();
}
});
this.lock = new ReentrantReadWriteLock();
this.topN = topN;
if (registry != null) {
registry.add(nam, this);
}
}
示例2: MetricsHistogram
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
/**
* Constructor to create a new histogram metric
* @param nam the name to publish the metric under
* @param registry where the metrics object will be registered
* @param description the metric's description
* @param forwardBiased true if you want this histogram to give more
* weight to recent data,
* false if you want all data to have uniform weight
*/
public MetricsHistogram(final String nam, final MetricsRegistry registry,
final String description, boolean forwardBiased) {
super(nam, description);
this.min = new AtomicLong();
this.max = new AtomicLong();
this.sum = new AtomicLong();
this.sample = forwardBiased ?
new ExponentiallyDecayingSample(DEFAULT_SAMPLE_SIZE, DEFAULT_ALPHA)
: new UniformSample(DEFAULT_SAMPLE_SIZE);
this.variance = new AtomicReference<double[]>(new double[]{-1, 0});
this.count = new AtomicLong();
this.clear();
if (registry != null) {
registry.add(nam, this);
}
}
示例3: incrLogMetrics
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
/**
* Increase logMetrics in the Raidnode metrics
*/
public static void incrLogMetrics(Map<String, Long> incrMetrics) {
if (incrMetrics == null || incrMetrics.size() == 0) {
return;
}
MetricsRegistry registry = RaidNodeMetrics.getInstance(
RaidNodeMetrics.DEFAULT_NAMESPACE_ID).getMetricsRegistry();
Map<String, MetricsTimeVaryingLong> logMetrics = RaidNodeMetrics.getInstance(
RaidNodeMetrics.DEFAULT_NAMESPACE_ID).logMetrics;
synchronized(logMetrics) {
for (String key : incrMetrics.keySet()) {
if (!logMetrics.containsKey(key)) {
logMetrics.put(key, new MetricsTimeVaryingLong(key, registry));
}
((MetricsTimeVaryingLong)logMetrics.get(key)).inc(incrMetrics.get(key));
}
}
}
示例4: MetricsRate
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
public MetricsRate(final String name, final MetricsRegistry registry,
final String description) {
super(name, description);
this.value = 0;
this.prevRate = 0;
this.ts = System.currentTimeMillis();
registry.add(name, this);
}
示例5: HBaseInfoMBean
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
public HBaseInfoMBean(MetricsRegistry registry, String rsName) {
super(registry, "HBase cluster information");
// The name seems wrong to me; should include clusterid IMO.
// That would make it harder to locate and rare we have
// two clusters up on single machine. St.Ack 20120309
mbeanName = MBeanUtil.registerMBean("HBase", "Info", this);
}
示例6: copyMinusHBaseMetrics
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
private static MetricsRegistry copyMinusHBaseMetrics(final MetricsRegistry mr) {
MetricsRegistry copy = new MetricsRegistry();
for (MetricsBase metric : mr.getMetricsList()) {
if (metric instanceof MetricsRate || metric instanceof MetricsString ||
metric instanceof MetricsHistogram || metric instanceof ExactCounterMetric) {
continue;
}
copy.add(metric.getName(), metric);
}
return copy;
}
示例7: HBaseRPCStatistics
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
@SuppressWarnings({"UnusedDeclaration"})
public HBaseRPCStatistics(MetricsRegistry registry,
String hostName, String port) {
super(registry, "Metrics for RPC server instance");
String name = String.format("RPCStatistics-%s",
(port != null ? port : "unknown"));
mbeanName = MBeanUtil.registerMBean("HBase", name, this);
}
示例8: setUp
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
public void setUp() {
this.registry = new MetricsRegistry();
this.metricsRate = new MetricsRate("metricsRate", registry, "test");
this.intValue = new MetricsIntValue("intValue", registry, "test");
this.varyRate = new MetricsTimeVaryingRate("varyRate", registry, "test");
this.stats = new TestStatistics(registry);
MetricsContext context = MetricsUtil.getContext("hbase");
this.metricsRecord = MetricsUtil.createRecord(context, "test");
this.metricsRecord.setTag("TestStatistics", "test");
//context.registerUpdater(this);
}
示例9: TaskErrorCollector
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
public TaskErrorCollector(
Configuration conf, int windowLength, int numWindows) {
this.windowLength = windowLength;
this.numWindows = numWindows;
MetricsContext context = MetricsUtil.getContext("mapred");
metricsRecord = MetricsUtil.createRecord(context, "taskerror");
registry = new MetricsRegistry();
context.registerUpdater(this);
URL configURL = null;
String configFilePath = conf.get(CONFIG_FILE_KEY);
if (configFilePath == null) {
// Search the class path if it is not configured
configURL =
TaskErrorCollector.class.getClassLoader().getResource(ERROR_XML);
} else {
try {
configURL = new URL("file://" +
new File(configFilePath).getAbsolutePath());
} catch (MalformedURLException e) {
LOG.error("Error in creating config URL", e);
}
}
if (configURL == null) {
LOG.warn("Could not get error collector configuration. " +
TaskErrorCollector.class.getSimpleName() +
" will see every error as UNKNOWN_ERROR.");
knownErrors = Collections.emptyMap();
} else {
LOG.info("Parsing configuration from " + configURL);
knownErrors = parseConfigFile(configURL);
}
createMetrics();
sinceStartErrorCounts = createErrorCountsMap();
}
示例10: testBasic
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
@Test
public void testBasic() throws Exception {
MetricsRegistry mr = new MetricsRegistry();
MetricsTimeVaryingRate metric = new MetricsTimeVaryingRate("test", mr);
metric.inc(1, 10);
MetricsContext context = MetricsUtil.getContext("test");
MetricsRecord metricsRecord = MetricsUtil.createRecord(context, "test");
metric.pushMetric(metricsRecord);
assertEquals(10, metric.getMaxTime());
}
示例11: RpcActivityMBean
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
/**
*
* @param mr - the metrics registry that has all the metrics
* @param serviceName - the service name for the rpc service
* @param port - the rpc port.
*/
public RpcActivityMBean(final MetricsRegistry mr, final String serviceName, final String port) {
super(mr, "Rpc layer statistics");
mbeanName = MBeanUtil.registerMBean(serviceName,
"RpcActivityForPort" + port, this);
}
示例12: BalancerActivityMBean
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
public BalancerActivityMBean(MetricsRegistry registry, Configuration conf, InetSocketAddress
namenodeAddress) {
super(registry, "Activity statistics at the Balancer");
String namenodeName = DFSUtil.getNameServiceIdFromAddress(conf,
namenodeAddress, FSConstants.DFS_NAMENODE_RPC_ADDRESS_KEY);
mbeanName = MBeanUtil.registerMBean("Balancer", "BalancerActivity-" + (namenodeName == null ?
"NotAFederation" : namenodeName), this);
}
示例13: DataNodeActivityMBean
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
public DataNodeActivityMBean(final MetricsRegistry mr, final String storageId) {
super(mr, "Activity statistics at the DataNode");
String storageName;
if (storageId.equals("")) {// Temp fix for the uninitialized storage
storageName = "UndefinedStorageId" + rand.nextInt();
} else {
storageName = storageId;
}
mbeanName = MBeanUtil.registerMBean("DataNode", "DataNodeActivity-" + storageName, this);
}
示例14: ExactCounterMetric
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
/**
* Constructor to create a new counter metric
* @param nam the name to publish this metric under
* @param registry where the metrics object will be registered
* @param description metrics description
* @param topN how many 'keys' to publish metrics on
*/
public ExactCounterMetric(final String nam, final MetricsRegistry registry,
final String description, int topN) {
super(nam, description);
this.lock = new ReentrantReadWriteLock();
this.topN = topN;
if (registry != null) {
registry.add(nam, this);
}
}
示例15: copyMinusHBaseMetrics
import org.apache.hadoop.metrics.util.MetricsRegistry; //导入依赖的package包/类
private static MetricsRegistry copyMinusHBaseMetrics(final MetricsRegistry mr) {
MetricsRegistry copy = new MetricsRegistry();
for (MetricsBase metric : mr.getMetricsList()) {
if (metric instanceof MetricsRate || metric instanceof MetricsString) {
continue;
}
copy.add(metric.getName(), metric);
}
return copy;
}