當前位置: 首頁>>代碼示例>>Java>>正文


Java Meter類代碼示例

本文整理匯總了Java中com.yammer.metrics.core.Meter的典型用法代碼示例。如果您正苦於以下問題:Java Meter類的具體用法?Java Meter怎麽用?Java Meter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Meter類屬於com.yammer.metrics.core包,在下文中一共展示了Meter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getStats

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
@ManagedAttribute
public Map<String, Object> getStats() {
    Map<String, Object> stats = new HashMap<String, Object>();
    
    MetricsRegistry registry = Metrics.defaultRegistry();
    for (Entry<MetricName, Metric> e : registry.allMetrics().entrySet()) {
        MetricName name = e.getKey();
        Metric metric = e.getValue();
        
        if (metric instanceof Meter) {
            Meter m = (Meter) metric;
            stats.put(name.toString(), new MeterPOJO(m));
        } else if (metric instanceof Gauge) {
            Gauge<?> g = (Gauge<?>) metric;
            stats.put(name.toString(), g.value());
        }
    }
    
    return stats;
}
 
開發者ID:pulsarIO,項目名稱:jetstream,代碼行數:21,代碼來源:KafkaMetrics.java

示例2: getProperty

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
public static Property getProperty(final Property propertyOrNull, final Metric metric) {
  if (propertyOrNull != null) {
    return propertyOrNull;
  } else {
    // is null, find a default
    if (metric instanceof Counter) {
      return CounterProperty.COUNT;
    } else if (metric instanceof Gauge) {
      return GaugeProperty.VALUE_GAUGE;
    } else if (metric instanceof Timer) {
      return TimerProperty.MEDIAN;
    } else if (metric instanceof Meter) {
      return MeterProperty.FIVE_MINUTE_RATE;
    } else if (metric instanceof Histogram) {
      return HistogramProperty.MEDIAN;
    } else {
      throw new RuntimeException("Unexpected metric type: " + metric.getClass());
    }
  }
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:21,代碼來源:Property.java

示例3: getNumber

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
public Number getNumber(final Metric metric, final Snapshot none) {
  if (metric instanceof Meter) {
    Meter meter = (Meter) metric;
    switch(this) {
      case COUNT:
        return meter.count();
      case ONE_MINUTE_RATE:
        return meter.oneMinuteRate();
      case FIVE_MINUTE_RATE:
        return meter.fiveMinuteRate();
      case FIFTEEN_MINUTE_RATE:
        return meter.fifteenMinuteRate();
      case MEAN_RATE:
        return meter.meanRate();
      default:
        throw new RuntimeException("Unexpected property");
    }
  } else {
    throw new IllegalArgumentException("Invalid metric for property");
  }
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:22,代碼來源:Property.java

示例4: testFetchMeter

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
@Test
public void testFetchMeter() throws Exception {
  final MetricName name = new MetricName("gr", "t1", "n1");
  Meter meter = metricsRegistry.newMeter(name, "trolls", TimeUnit.SECONDS);
  meter.mark();
  meter.mark();

  final MuninDataSourceFactory dataSourceFactory = new MuninDataSourceFactory();
  Map<String, MuninGraph> graphs = new HashMap<String, MuninGraph>() {{
    put("foo", new MuninGraph("foo", "gr", "t", asList(dataSourceFactory.forMetric(
        name, null, null, new MuninDataSourceConfig()))));
  }};

  MetricsCommandProcessor sut = new MetricsCommandProcessor(metricsRegistry, new StaticMuninGraphProvider(graphs), hostname);

  // rate will be 0.0 in this test
  assertEquals(asList(
    "n1__five_minute_rate.value 0",
    "."
  )
  , sut.processCommand("fetch", asList("foo")));
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:23,代碼來源:MetricsCommandProcessorTest.java

示例5: SimpleQueryParallelCall

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
public SimpleQueryParallelCall(AtomicBoolean running, String table, QueryStatus status, Query query,
    Selector selector, Meter queriesInternalMeter, ShardServerContext shardServerContext, boolean runSlow,
    int fetchCount, int maxHeapPerRowFetch, Similarity similarity, TableContext context, Sort sort,
    DeepPagingCache deepPagingCache, MemoryAllocationWatcher memoryAllocationWatcher) {
  _running = running;
  _table = table;
  _status = status;
  _query = query;
  _selector = selector;
  _queriesInternalMeter = queriesInternalMeter;
  _shardServerContext = shardServerContext;
  _runSlow = runSlow;
  _fetchCount = fetchCount;
  _maxHeapPerRowFetch = maxHeapPerRowFetch;
  _similarity = similarity;
  _context = context;
  _sort = sort;
  _deepPagingCache = deepPagingCache;
  _memoryAllocationWatcher = memoryAllocationWatcher;
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:21,代碼來源:IndexManager.java

示例6: createNewMetricsGroup

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
protected MetricsGroup createNewMetricsGroup(String scope) {
  MetricName readRandomAccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Random Latency in \u00B5s", scope);
  MetricName readStreamAccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Latency in \u00B5s", scope);
  MetricName writeAcccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Write Latency in \u00B5s", scope);
  MetricName readRandomThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Random Throughput", scope);
  MetricName readStreamThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Throughput", scope);
  MetricName readSeekName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Stream Seeks", scope);
  MetricName writeThroughputName = new MetricName(ORG_APACHE_BLUR, HDFS, "Write Throughput", scope);
  MetricName totalHdfsBlocks = new MetricName(ORG_APACHE_BLUR, HDFS, "Hdfs Blocks Total", scope);
  MetricName localHdfsBlocks = new MetricName(ORG_APACHE_BLUR, HDFS, "Hdfs Blocks Local", scope);

  Histogram readRandomAccess = Metrics.newHistogram(readRandomAccessName);
  Histogram readStreamAccess = Metrics.newHistogram(readStreamAccessName);
  Histogram writeAccess = Metrics.newHistogram(writeAcccessName);
  Meter readRandomThroughput = Metrics.newMeter(readRandomThroughputName, "Read Random Bytes", TimeUnit.SECONDS);
  Meter readStreamThroughput = Metrics.newMeter(readStreamThroughputName, "Read Stream Bytes", TimeUnit.SECONDS);
  Meter readStreamSeek = Metrics.newMeter(readSeekName, "Read Stream Seeks", TimeUnit.SECONDS);
  Meter writeThroughput = Metrics.newMeter(writeThroughputName, "Write Bytes", TimeUnit.SECONDS);
  Counter totalHdfsBlock = Metrics.newCounter(totalHdfsBlocks);
  Counter localHdfsBlock = Metrics.newCounter(localHdfsBlocks);

  return new MetricsGroup(readRandomAccess, readStreamAccess, writeAccess, readRandomThroughput,
      readStreamThroughput, readStreamSeek, writeThroughput, totalHdfsBlock, localHdfsBlock);
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:25,代碼來源:HdfsDirectory.java

示例7: copyIndexingMetricsToCounters

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
private void copyIndexingMetricsToCounters(Context context) {
    final String COUNTER_GROUP = "HBase Indexer Metrics";
    SortedMap<String, SortedMap<MetricName, Metric>> groupedMetrics = Metrics.defaultRegistry().groupedMetrics(
            new IndexerMetricsUtil.IndexerMetricPredicate());
    for (Entry<String, SortedMap<MetricName, Metric>> metricsGroupEntry : groupedMetrics.entrySet()) {
        SortedMap<MetricName, Metric> metricsGroupMap = metricsGroupEntry.getValue();
        for (Entry<MetricName, Metric> metricEntry : metricsGroupMap.entrySet()) {
            MetricName metricName = metricEntry.getKey();
            Metric metric = metricEntry.getValue();
            String counterName = metricName.getType() + ": " + metricName.getName();
            if (metric instanceof Counter) {
                Counter counter = (Counter) metric;
                context.getCounter(COUNTER_GROUP, counterName).increment(counter.count());
            } else if (metric instanceof Meter) {
                Meter meter = (Meter) metric;
                context.getCounter(COUNTER_GROUP, counterName).increment(meter.count());
            } else if (metric instanceof Timer) {
                Timer timer = (Timer) metric;
                context.getCounter(COUNTER_GROUP, counterName).increment((long) timer.sum());
            }
        }
    }
}
 
開發者ID:NGDATA,項目名稱:hbase-indexer,代碼行數:24,代碼來源:HBaseIndexerMapper.java

示例8: EchoMessageHandler

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
public EchoMessageHandler(final Meter meter, final int messageSize) {
    this.meter = meter;

    final ByteBuf byteBuf = Unpooled.buffer(messageSize);

    for (int i = 0; i < byteBuf.capacity(); i++) {
        byteBuf.writeByte((byte) i);
    }

    message = new UdtMessage(byteBuf);
}
 
開發者ID:wuyinxian124,項目名稱:netty4.0.27Learn,代碼行數:12,代碼來源:EchoMessageHandler.java

示例9: MeterPOJO

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
public MeterPOJO(Meter m) {
    count = m.count();
    fifteenMinuteRate = m.fifteenMinuteRate();
    fiveMinuteRate = m.fiveMinuteRate();
    meanRate = m.meanRate();
    rateUnit = m.rateUnit().toString();
    oneMinuteRate = m.oneMinuteRate();
}
 
開發者ID:pulsarIO,項目名稱:jetstream,代碼行數:9,代碼來源:KafkaMetrics.java

示例10: meterToJsonObject

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
private static JsonObject meterToJsonObject(Meter meter) {
    return new JsonObject()
            .add("count", meter.count())
            .add("rate", new JsonObject()
                    .add("1", meter.oneMinuteRate())
                    .add("5", meter.fiveMinuteRate())
                    .add("15", meter.fifteenMinuteRate()));
}
 
開發者ID:airbnb,項目名稱:plog,代碼行數:9,代碼來源:KafkaHandler.java

示例11: meter

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
@Test
public final void meter() throws Exception {
  addMetricAndRunReporter(
      new Callable<Meter>() {
        @Override
        public Meter call() throws Exception {
          return createMeter();
        }
      });
  verifyMeter();
}
 
開發者ID:airbnb,項目名稱:kafka-statsd-metrics2,代碼行數:12,代碼來源:StatsDReporterTest.java

示例12: createMeter

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
static Meter createMeter() throws Exception {
  final Meter mock = mock(Meter.class);
  setupMeteredMock(mock);
  return configureMatcher(mock, doAnswer(new MetricsProcessorAction() {
    @Override
    void delegateToProcessor(MetricProcessor<Object> processor, MetricName name, Object context) throws Exception {
      processor.processMeter(name, mock, context);
    }
  }));
}
 
開發者ID:airbnb,項目名稱:kafka-statsd-metrics2,代碼行數:11,代碼來源:StatsDReporterTest.java

示例13: mark

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
public void mark(final Object param) {
  Meter meter = meters.get(param);
  if (meter == null) {
    final MetricName name = paramMetricName.name(param);
    meter = registry.newMeter(name, eventType, timeUnit);
    final Meter existingMeter = meters.putIfAbsent(param, meter);
    if (existingMeter != null) {
      meter = existingMeter;
    }
  }
  meter.mark();
  total.mark();
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:14,代碼來源:ParamMeter.java

示例14: wrap

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
public static MeterWrapper wrap(final Meter meter) {
  return wrap(new SimpleMeter() {
    @Override
    public void mark(long l) {
      meter.mark(l);
    }
  });
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:9,代碼來源:MeterWrapper.java

示例15: setupBuffers

import com.yammer.metrics.core.Meter; //導入依賴的package包/類
private static BlockingQueue<byte[]> setupBuffers(int bufferSize, int count, Meter meter) {
  BlockingQueue<byte[]> queue = new ArrayBlockingQueue<byte[]>(count);
  for (int i = 0; i < count; i++) {
    meter.mark();
    queue.add(new byte[bufferSize]);
  }
  return queue;
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:9,代碼來源:BufferStore.java


注:本文中的com.yammer.metrics.core.Meter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。