Java Code Examples for org.apache.hadoop.metrics2.MetricsSystem#register()

The following examples show how to use org.apache.hadoop.metrics2.MetricsSystem#register() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FSQueueMetrics.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public synchronized 
static FSQueueMetrics forQueue(String queueName, Queue parent,
    boolean enableUserMetrics, Configuration conf) {
  MetricsSystem ms = DefaultMetricsSystem.instance();
  QueueMetrics metrics = queueMetrics.get(queueName);
  if (metrics == null) {
    metrics = new FSQueueMetrics(ms, queueName, parent, enableUserMetrics, conf)
        .tag(QUEUE_INFO, queueName);
    
    // Register with the MetricsSystems
    if (ms != null) {
      metrics = ms.register(
              sourceName(queueName).toString(), 
              "Metrics for queue: " + queueName, metrics);
    }
    queueMetrics.put(queueName, metrics);
  }

  return (FSQueueMetrics)metrics;
}
 
Example 2
Source File: ContainerMetrics.java    From hadoop with Apache License 2.0 6 votes vote down vote up
synchronized static ContainerMetrics forContainer(
    MetricsSystem ms, ContainerId containerId, long flushPeriodMs) {
  ContainerMetrics metrics = usageMetrics.get(containerId);
  if (metrics == null) {
    metrics = new ContainerMetrics(
        ms, containerId, flushPeriodMs).tag(RECORD_INFO, containerId);

    // Register with the MetricsSystems
    if (ms != null) {
      metrics =
          ms.register(sourceName(containerId),
              "Metrics for container: " + containerId, metrics);
    }
    usageMetrics.put(containerId, metrics);
  }

  return metrics;
}
 
Example 3
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test public void testRegisterSourceWithoutName() {
  MetricsSystem ms = new MetricsSystemImpl();
  TestSource ts = new TestSource("ts");
  TestSource2 ts2 = new TestSource2("ts2");
  ms.register(ts);
  ms.register(ts2);
  ms.init("TestMetricsSystem");
  // if metrics source is registered without name,
  // the class name will be used as the name
  MetricsSourceAdapter sa = ((MetricsSystemImpl) ms)
      .getSourceAdapter("TestSource");
  assertNotNull(sa);
  MetricsSourceAdapter sa2 = ((MetricsSystemImpl) ms)
      .getSourceAdapter("TestSource2");
  assertNotNull(sa2);
  ms.shutdown();
}
 
Example 4
Source File: DataNodeMetrics.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static DataNodeMetrics create(Configuration conf, String dnName) {
  String sessionId = conf.get(DFSConfigKeys.DFS_METRICS_SESSION_ID_KEY);
  MetricsSystem ms = DefaultMetricsSystem.instance();
  JvmMetrics jm = JvmMetrics.create("DataNode", sessionId, ms);
  String name = "DataNodeActivity-"+ (dnName.isEmpty()
      ? "UndefinedDataNodeName"+ DFSUtil.getRandom().nextInt() 
          : dnName.replace(':', '-'));

  // Percentile measurement is off by default, by watching no intervals
  int[] intervals = 
      conf.getInts(DFSConfigKeys.DFS_METRICS_PERCENTILES_INTERVALS_KEY);
  
  return ms.register(name, null, new DataNodeMetrics(name, sessionId,
      intervals, jm));
}
 
Example 5
Source File: ProxyMetrics.java    From nnproxy with Apache License 2.0 5 votes vote down vote up
public static ProxyMetrics create(Configuration conf) {
    String sessionId = conf.get(DFSConfigKeys.DFS_METRICS_SESSION_ID_KEY);
    String processName = "NNPROXY";
    MetricsSystem ms = DefaultMetricsSystem.instance();
    JvmMetrics jm = JvmMetrics.create(processName, sessionId, ms);

    return ms.register(new ProxyMetrics(processName, sessionId, jm));
}
 
Example 6
Source File: CleanerMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
static CleanerMetrics create() {
  MetricsSystem ms = DefaultMetricsSystem.instance();

  CleanerMetrics metricObject = new CleanerMetrics();
  MetricsSourceBuilder sb = MetricsAnnotations.newSourceBuilder(metricObject);
  final MetricsSource s = sb.build();
  ms.register("cleaner", "The cleaner service of truly shared cache", s);
  metricObject.metricSource = s;
  return metricObject;
}
 
Example 7
Source File: NameNodeMetrics.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static NameNodeMetrics create(Configuration conf, NamenodeRole r) {
  String sessionId = conf.get(DFSConfigKeys.DFS_METRICS_SESSION_ID_KEY);
  String processName = r.toString();
  MetricsSystem ms = DefaultMetricsSystem.instance();
  JvmMetrics jm = JvmMetrics.create(processName, sessionId, ms);
  
  // Percentile measurement is off by default, by watching no intervals
  int[] intervals = 
      conf.getInts(DFSConfigKeys.DFS_METRICS_PERCENTILES_INTERVALS_KEY);
  return ms.register(new NameNodeMetrics(processName, sessionId,
      intervals, jm));
}
 
Example 8
Source File: Nfs3Metrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static Nfs3Metrics create(Configuration conf, String gatewayName) {
  String sessionId = conf.get(DFSConfigKeys.DFS_METRICS_SESSION_ID_KEY);
  MetricsSystem ms = DefaultMetricsSystem.instance();
  JvmMetrics jm = JvmMetrics.create(gatewayName, sessionId, ms);

  // Percentile measurement is [50th,75th,90th,95th,99th] currently 
  int[] intervals = conf
      .getInts(NfsConfigKeys.NFS_METRICS_PERCENTILES_INTERVALS_KEY);
  return ms.register(new Nfs3Metrics(gatewayName, sessionId, intervals, jm));
}
 
Example 9
Source File: NameNodeMetrics.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static NameNodeMetrics create(Configuration conf, NamenodeRole r) {
  String sessionId = conf.get(DFSConfigKeys.DFS_METRICS_SESSION_ID_KEY);
  String processName = r.toString();
  MetricsSystem ms = DefaultMetricsSystem.instance();
  JvmMetrics jm = JvmMetrics.create(processName, sessionId, ms);
  
  // Percentile measurement is off by default, by watching no intervals
  int[] intervals = 
      conf.getInts(DFSConfigKeys.DFS_METRICS_PERCENTILES_INTERVALS_KEY);
  return ms.register(new NameNodeMetrics(processName, sessionId,
      intervals, jm));
}
 
Example 10
Source File: ContainerDataScrubberMetrics.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
public static ContainerDataScrubberMetrics create(final String volumeName) {
  MetricsSystem ms = DefaultMetricsSystem.instance();
  String name = "ContainerDataScrubberMetrics-"+ (volumeName.isEmpty()
      ? "UndefinedDataNodeVolume"+ ThreadLocalRandom.current().nextInt()
      : volumeName.replace(':', '-'));

  return ms.register(name, null, new ContainerDataScrubberMetrics(name, ms));
}
 
Example 11
Source File: FSOpDurations.java    From big-c with Apache License 2.0 5 votes vote down vote up
private FSOpDurations() {
  registry = new MetricsRegistry(RECORD_INFO);
  registry.tag(RECORD_INFO, "FSOpDurations");

  MetricsSystem ms = DefaultMetricsSystem.instance();
  if (ms != null) {
    ms.register(RECORD_INFO.name(), RECORD_INFO.description(), this);
  }
}
 
Example 12
Source File: TestFileSink.java    From big-c with Apache License 2.0 4 votes vote down vote up
public MyMetrics2 registerWith(MetricsSystem ms) {
  return ms.register("m2", null, this);
}
 
Example 13
Source File: TajoPullServerService.java    From tajo with Apache License 2.0 4 votes vote down vote up
TajoPullServerService(MetricsSystem ms) {
  super(PullServerConstants.PULLSERVER_SERVICE_NAME);
  metrics = ms.register(new ShuffleMetrics());
}
 
Example 14
Source File: TestFileSink.java    From big-c with Apache License 2.0 4 votes vote down vote up
public MyMetrics1 registerWith(MetricsSystem ms) {
  return ms.register("m1", null, this);
}
 
Example 15
Source File: PullServerAuxService.java    From incubator-tajo with Apache License 2.0 4 votes vote down vote up
PullServerAuxService(MetricsSystem ms) {
  super("httpshuffle");
  metrics = ms.register(new ShuffleMetrics());
}
 
Example 16
Source File: TestMetricsSystemImpl.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Test(expected=MetricsException.class) public void testRegisterDupError() {
  MetricsSystem ms = new MetricsSystemImpl("test");
  TestSource ts = new TestSource("ts");
  ms.register(ts);
  ms.register(ts);
}
 
Example 17
Source File: CSMMetrics.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
public static CSMMetrics create(RaftGroupId gid) {
  MetricsSystem ms = DefaultMetricsSystem.instance();
  return ms.register(SOURCE_NAME + gid.toString(),
      "Container State Machine",
      new CSMMetrics());
}
 
Example 18
Source File: TajoPullServerService.java    From tajo with Apache License 2.0 4 votes vote down vote up
TajoPullServerService(MetricsSystem ms) {
  super(PullServerConstants.PULLSERVER_SERVICE_NAME);
  metrics = ms.register(new ShuffleMetrics());
}
 
Example 19
Source File: ShuffleHandler.java    From hadoop with Apache License 2.0 4 votes vote down vote up
ShuffleHandler(MetricsSystem ms) {
  super("httpshuffle");
  metrics = ms.register(new ShuffleMetrics());
}
 
Example 20
Source File: ContainerMetadataScrubberMetrics.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
public static ContainerMetadataScrubberMetrics create() {
  MetricsSystem ms = DefaultMetricsSystem.instance();
  String name = "ContainerMetadataScrubberMetrics";
  return ms.register(name, null,
      new ContainerMetadataScrubberMetrics(name, ms));
}