Examples of MetricsRecord


Examples of org.apache.hadoop.metrics2.MetricsRecord

  }

  @Test public void testGet() {
    MetricsCache cache = new MetricsCache();
    assertNull("empty", cache.get("r", Arrays.asList(makeTag("t", "t"))));
    MetricsRecord mr = makeRecord("r",
        Arrays.asList(makeTag("t", "t")),
        Arrays.asList(makeMetric("m", 1)));
    cache.update(mr);
    MetricsCache.Record cr = cache.get("r", (Collection<MetricsTag>)mr.tags());
    LOG.debug("tags="+ (Collection<MetricsTag>)mr.tags() +" cr="+ cr);

    assertNotNull("Got record", cr);
    assertEquals("contains 1 metric", 1, cr.metrics.size());
    assertEquals("new metric value", 1, cr.getMetric("m"));
    assertNotNull("metric not null", cr.getMetricInstance("m"));
View Full Code Here

Examples of org.apache.hadoop.metrics2.MetricsRecord

    assertEquals("new metric value", 1, cr.getMetricInstance("m").value());
  }

  private MetricsRecord makeRecord(String name, Collection<MetricsTag> tags,
                                   Collection<Metric> metrics) {
    MetricsRecord mr = mock(MetricsRecord.class);
    when(mr.name()).thenReturn(name);
    when(mr.tags()).thenReturn(tags);
    when(mr.metrics()).thenReturn(metrics);
    return mr;
  }
View Full Code Here

Examples of org.apache.hadoop.metrics2.MetricsRecord

abstract class AbstractMetricsRecord implements MetricsRecord {

  @Override public boolean equals(Object obj) {
    if (obj instanceof MetricsRecord) {
      final MetricsRecord other = (MetricsRecord) obj;
      return Objects.equal(timestamp(), other.timestamp()) &&
             Objects.equal(name(), other.name()) &&
             Objects.equal(description(), other.description()) &&
             Objects.equal(tags(), other.tags()) &&
             Iterables.elementsEqual(metrics(), other.metrics());
    }
    return false;
  }
View Full Code Here

Examples of org.apache.hadoop.metrics2.MetricsRecord

   * @param tags List<MetricsTag> tags
   * @return MetricsRecord newly created mock
   */
  private static MetricsRecord mockMetricsRecord(String name,
      List<MetricsTag> tags) {
    MetricsRecord record = mock(MetricsRecord.class);
    when(record.name()).thenReturn(name);
    when(record.tags()).thenReturn(tags);
    return record;
  }
View Full Code Here

Examples of org.apache.hadoop.metrics2.MetricsRecord

  }


  private void checkMetricsRecords(List<MetricsRecord> recs) {
    LOG.debug(recs);
    MetricsRecord r = recs.get(0);
    assertEquals("name", "s1rec", r.name());
    assertEquals("tags", new MetricsTag[] {
      tag(MsInfo.Context, "test"),
      tag(MsInfo.Hostname, hostname)}, r.tags());
    assertEquals("metrics", MetricsLists.builder("")
      .addCounter(info("C1", "C1 desc"), 1L)
      .addGauge(info("G1", "G1 desc"), 2L)
      .addCounter(info("S1NumOps", "Number of ops for s1"), 1L)
      .addGauge(info("S1AvgTime", "Average time for s1"), 0.0)
      .metrics(), r.metrics());

    r = recs.get(1);
    assertTrue("NumActiveSinks should be 3", Iterables.contains(r.metrics(),
               new MetricGaugeInt(MsInfo.NumActiveSinks, 3)));
  }
View Full Code Here

Examples of org.apache.hadoop.metrics2.MetricsRecord

    tags.add(new MetricsTag(MsInfo.NumActiveSources, "foo"));
    tags.add(new MetricsTag(MsInfo.NumActiveSinks, "bar"));
    tags.add(new MetricsTag(MsInfo.NumAllSinks, "haa"));
    tags.add(new MetricsTag(MsInfo.Hostname, "host"));
    Set<AbstractMetric> metrics = new HashSet<AbstractMetric>();
    MetricsRecord record = new MetricsRecordImpl(MsInfo.Context, (long) 1, tags, metrics);

    StringBuilder sb = new StringBuilder();
    sink.appendPrefix(record, sb);
    assertEquals(".NumActiveSources=foo.NumActiveSinks=bar.NumAllSinks=haa", sb.toString());
View Full Code Here

Examples of org.apache.hadoop.thriftfs.api.MetricsRecord

    for (Map.Entry<String, Collection<OutputRecord>> entry :
           ctx.getAllRecords().entrySet()) {

      ArrayList<MetricsRecord> recs = new ArrayList<MetricsRecord>();
      for (OutputRecord outputRec : entry.getValue()) {
        MetricsRecord tRec = metricsRecordToThrift(outputRec);
        recs.add(tRec);
      }

      tCtx.records.put(entry.getKey(), recs);
    }
View Full Code Here

Examples of org.apache.hama.monitor.MetricsRecord

        final Act act = new Act(new ZKCollector(zk, "jvm", "Jvm metrics.",
            jvmPath), new CollectorHandler() {
          @Override
          public void handle(@SuppressWarnings("rawtypes") Future future) {
            try {
              MetricsRecord record = (MetricsRecord) future.get();
              if (null != record) {
                if (LOG.isDebugEnabled()) {
                  for (@SuppressWarnings("rawtypes")
                  Metric metric : record.metrics()) {
                    LOG.debug("Metric name:" + metric.name() + " metric value:"
                        + metric.value());
                  }
                }
                repository.put(groom, record);
View Full Code Here

Examples of org.apache.hama.monitor.MetricsRecord

    this.result = new JvmResult();
  }

  @Override
  public Object run() throws TaskException {
    final MetricsRecord record = new MetricsRecord("jvm", "Jvm metrics stats.");
    //record.tag("ProcessName", processName);
    //record.tag("SessionId", sessionId);
    memory(record);
    gc(record);
    threads(record);
View Full Code Here

Examples of org.apache.hama.monitor.MetricsRecord

            jvmPath), new CollectorHandler() {
          @Override
          public void handle(@SuppressWarnings("rawtypes")
          Future future) {
            try {
              MetricsRecord record = (MetricsRecord) future.get();
              if (null != record) {
                if (LOG.isDebugEnabled()) {
                  for (@SuppressWarnings("rawtypes")
                  Metric metric : record.metrics()) {
                    LOG.debug("Metric name:" + metric.name() + " metric value:"
                        + metric.value());
                  }
                }
                repository.put(groom, record);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.