当前位置: 首页>>代码示例>>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;未经允许,请勿转载。