当前位置: 首页>>代码示例>>Java>>正文


Java Meter类代码示例

本文整理汇总了Java中com.codahale.metrics.Meter的典型用法代码示例。如果您正苦于以下问题:Java Meter类的具体用法?Java Meter怎么用?Java Meter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Meter类属于com.codahale.metrics包,在下文中一共展示了Meter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMetricEncode

import com.codahale.metrics.Meter; //导入依赖的package包/类
/**
 * Tests encoding of a Metric object.
 */
@Test
public void testMetricEncode() {
    Counter counter = new Counter();
    Meter meter = new Meter();
    Timer timer = new Timer();

    counter.inc();
    meter.mark();
    timer.update(1, TimeUnit.MILLISECONDS);

    ObjectNode counterJson = metricCodec.encode(counter, context);
    assertThat(counterJson.get("counter"), matchesMetric(counter));

    ObjectNode meterJson = metricCodec.encode(meter, context);
    assertThat(meterJson.get("meter"), matchesMetric(meter));

    ObjectNode timerJson = metricCodec.encode(timer, context);
    assertThat(timerJson.get("timer"), matchesMetric(timer));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:MetricCodecTest.java

示例2: AnomalyDetector

import com.codahale.metrics.Meter; //导入依赖的package包/类
/**
 * Package private constructor for unit test.
 */
AnomalyDetector(LinkedBlockingDeque<Anomaly> anomalies,
                long anomalyDetectionIntervalMs,
                KafkaCruiseControl kafkaCruiseControl,
                AnomalyNotifier anomalyNotifier,
                GoalViolationDetector goalViolationDetector,
                BrokerFailureDetector brokerFailureDetector,
                ScheduledExecutorService detectorScheduler) {
  _anomalies = anomalies;
  _anomalyDetectionIntervalMs = anomalyDetectionIntervalMs;
  _anomalyNotifier = anomalyNotifier;
  _goalViolationDetector = goalViolationDetector;
  _brokerFailureDetector = brokerFailureDetector;
  _kafkaCruiseControl = kafkaCruiseControl;
  _detectorScheduler = detectorScheduler;
  _shutdown = false;
  _brokerFailureRate = new Meter();
  _goalViolationRate = new Meter();
}
 
开发者ID:linkedin,项目名称:cruise-control,代码行数:22,代码来源:AnomalyDetector.java

示例3: TrainingFetcher

import com.codahale.metrics.Meter; //导入依赖的package包/类
TrainingFetcher(MetricSampler metricSampler,
                Cluster cluster,
                SampleStore sampleStore,
                Set<TopicPartition> assignedPartitions,
                long startTimeMs,
                long endTimeMs,
                Timer fetcherTimer,
                Meter fetcherFailureRate) {
  _cluster = cluster;
  _sampleStore = sampleStore;
  _metricSampler = metricSampler;
  _startTimeMs = startTimeMs;
  _endTimeMs = endTimeMs;
  _assignedPartitions = assignedPartitions;
  _fetcherTimer = fetcherTimer;
  _fetcherFailureRate = fetcherFailureRate;
}
 
开发者ID:linkedin,项目名称:cruise-control,代码行数:18,代码来源:TrainingFetcher.java

示例4: SamplingFetcher

import com.codahale.metrics.Meter; //导入依赖的package包/类
SamplingFetcher(MetricSampler metricSampler,
                Cluster cluster,
                MetricSampleAggregator metricSampleAggregator,
                SampleStore sampleStore,
                Set<TopicPartition> assignedPartitions,
                long startTimeMs,
                long endTimeMs,
                boolean leaderValidation,
                boolean useLinearRegressionModel,
                Timer fetchTimer,
                Meter fetchFailureRate) {
  _metricSampler = metricSampler;
  _cluster = cluster;
  _metricSampleAggregator = metricSampleAggregator;
  _sampleStore = sampleStore;
  _assignedPartitions = assignedPartitions;
  _startTimeMs = startTimeMs;
  _endTimeMs = endTimeMs;
  _leaderValidation = leaderValidation;
  _useLinearRegressionModel = useLinearRegressionModel;
  _fetchTimer = fetchTimer;
  _fetchFailureRate = fetchFailureRate;
}
 
开发者ID:linkedin,项目名称:cruise-control,代码行数:24,代码来源:SamplingFetcher.java

示例5: testMetersRetrievedAndMarkIsDelegated

import com.codahale.metrics.Meter; //导入依赖的package包/类
@Test
public void testMetersRetrievedAndMarkIsDelegated() throws Exception {
    // ARRANGE
    SystemStatus systemStatus = mock(SystemStatus.class);

    Meter meter = mock(Meter.class);
    doReturn(meter).when(systemStatus).meter(anyString(), any());

    AbstractMeteredLoadProcessorImpl processor = spy(new AbstractMeteredLoadProcessorImpl(0, null, 0, null));
    processor.setSystemStatus(systemStatus);

    // ACT
    processor.succeeded();
    processor.failed();
    processor.authenticationFailure();

    // ASSERT
    verify(processor, times(3)).meterName(); // FindBugs: RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT - IGNORE
    verify(systemStatus, times(3)).meter(anyString(), any());
    verify(meter, times(3)).mark();
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:22,代码来源:AbstractMeteredLoadProcessorTest.java

示例6: testMetersRetrievedAndMarkIsDelegated

import com.codahale.metrics.Meter; //导入依赖的package包/类
@Test
public void testMetersRetrievedAndMarkIsDelegated() throws Exception {
    // ARRANGE
    SystemStatus systemStatus = mock(SystemStatus.class);

    Meter meter = mock(Meter.class);
    doReturn(meter).when(systemStatus).meter(anyString(), any());
    processor.setSystemStatus(systemStatus);


    // ACT
    processor.succeeded();
    processor.failed();
    processor.noData();
    processor.authenticationFailure();

    // ASSERT
    verify(processor, times(4)).meterName(); // FindBugs: RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT - IGNORE
    verify(systemStatus, times(4)).meter(anyString(), any());
    verify(meter, times(4)).mark();
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:22,代码来源:AbstractMeteredExtractProcessorTest.java

示例7: exception

import com.codahale.metrics.Meter; //导入依赖的package包/类
@Test(expected = FeignException.class)
public void exception() {
    stubFor(post(anyUrl()).willReturn(aResponse().withStatus(400)));
    MyClientWithAnnotationOnMethodLevel target = Feign.builder().invocationHandlerFactory(
            new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry))
            .target(MyClientWithAnnotationOnMethodLevel.class,
                    String.format("http://localhost:%d", wireMockRule.port()));
    try {
        target.myMethod();
    } finally {

        assertMetrics();

        Set<Map.Entry<String, Meter>> entries = metricRegistry.getMeters().entrySet();

        entries.forEach(entry -> {
            if (entry.getKey().endsWith(ExceptionMetered.DEFAULT_NAME_SUFFIX)) {
                assertEquals(String.format("wrong number of invocations in metric %s", entry.getKey()), 1,
                        entry.getValue().getCount());
            }
        });
    }
}
 
开发者ID:mwiede,项目名称:metrics-feign,代码行数:24,代码来源:FeignOutboundMetricsMethodHandlerTest.java

示例8: assertMetrics

import com.codahale.metrics.Meter; //导入依赖的package包/类
private void assertMetrics() {
    Timer timer = metricRegistry.getTimers().values().iterator().next();
    assertEquals("wrong number of invocations in metric.", 1, timer.getCount());

    assertTrue("wrong value of mean in metric.", timer.getMeanRate() > 0);

    assertEquals("wrong number of meter metrics.", 2, metricRegistry.getMeters().values().size());

    Set<Map.Entry<String, Meter>> entries = metricRegistry.getMeters().entrySet();

    entries.forEach(entry -> {
        if (entry.getKey().endsWith("Metered")) {
            assertEquals(String.format("wrong number of invocations in metric %s", entry.getKey()), 1,
                    entry.getValue().getCount());
        }
    });

}
 
开发者ID:mwiede,项目名称:metrics-feign,代码行数:19,代码来源:FeignOutboundMetricsMethodHandlerTest.java

示例9: report

import com.codahale.metrics.Meter; //导入依赖的package包/类
@Override
public void report(final SortedMap<String, Gauge> gauges,
                   final SortedMap<String, Counter> counters,
                   final SortedMap<String, Histogram> histograms,
                   final SortedMap<String, Meter> meters,
                   final SortedMap<String, Timer> timers) {
  final long timestamp = clock.instant().toEpochMilli();

  final ImmutableList<InfluxDbMeasurement> influxDbMeasurements = ImmutableList.<InfluxDbMeasurement>builder()
    .addAll(transformer.fromGauges(gauges, timestamp))
    .addAll(transformer.fromCounters(counters, timestamp))
    .addAll(transformer.fromHistograms(histograms, timestamp))
    .addAll(transformer.fromMeters(meters, timestamp))
    .addAll(transformer.fromTimers(timers, timestamp))
    .build();

  sender.send(influxDbMeasurements);
}
 
开发者ID:kickstarter,项目名称:dropwizard-influxdb-reporter,代码行数:19,代码来源:InfluxDbMeasurementReporter.java

示例10: fromMeter

import com.codahale.metrics.Meter; //导入依赖的package包/类
/**
 * Build an {@link InfluxDbMeasurement} from a meter.
 */
@VisibleForTesting InfluxDbMeasurement fromMeter(final String metricName, final Meter mt, final long timestamp) {
  final DropwizardMeasurement measurement = parser.parse(metricName);

  final Map<String, String> tags = new HashMap<>(baseTags);
  tags.putAll(measurement.tags());

  return new InfluxDbMeasurement.Builder(measurement.name(), timestamp)
    .putTags(tags)
    .putField("count", mt.getCount())
    .putField("one-minute", convertRate(mt.getOneMinuteRate()))
    .putField("five-minute", convertRate(mt.getFiveMinuteRate()))
    .putField("fifteen-minute", convertRate(mt.getFifteenMinuteRate()))
    .putField("mean-minute", convertRate(mt.getMeanRate()))
    .build();
}
 
开发者ID:kickstarter,项目名称:dropwizard-influxdb-reporter,代码行数:19,代码来源:DropwizardTransformer.java

示例11: serialize

import com.codahale.metrics.Meter; //导入依赖的package包/类
@Override
public void serialize(JsonMeter jsonMeter,
                      JsonGenerator json,
                      SerializerProvider provider) throws IOException {
    json.writeStartObject();
    json.writeStringField("name", jsonMeter.name());
    json.writeObjectField(timestampFieldname, jsonMeter.timestampAsDate());
    Meter meter = jsonMeter.value();
    json.writeNumberField("count", meter.getCount());
    json.writeNumberField("m1_rate", meter.getOneMinuteRate() * rateFactor);
    json.writeNumberField("m5_rate", meter.getFiveMinuteRate() * rateFactor);
    json.writeNumberField("m15_rate", meter.getFifteenMinuteRate() * rateFactor);
    json.writeNumberField("mean_rate", meter.getMeanRate() * rateFactor);
    json.writeStringField("units", rateUnit);
    addOneOpsMetadata(json);
    json.writeEndObject();
}
 
开发者ID:oneops,项目名称:oneops,代码行数:18,代码来源:MetricsElasticsearchModule.java

示例12: interceptCall

import com.codahale.metrics.Meter; //导入依赖的package包/类
/**
 * Intercept all GRPC calls
 * @param serverCall
 * @param metadata
 * @param serverCallHandler
 * @param <ReqT>
 * @param <RespT>
 * @return
 */
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(final ServerCall<ReqT, RespT> serverCall, Metadata metadata, ServerCallHandler<ReqT, RespT> serverCallHandler) {

    Timer.Context timer = metricRegistry.timer(metricName(M_REQ_TIME, serverCall.getMethodDescriptor().getFullMethodName().replace("/", "."))).time();
    Histogram histogram = metricRegistry.histogram(metricName(M_RESPONSE_SIZE, serverCall.getMethodDescriptor().getFullMethodName().replace("/", ".")));

    SimpleForwardingServerCall<ReqT, RespT> nextCall = new SimpleForwardingServerCall<ReqT, RespT>(serverCall) {
        @Override
        public void close(Status status, Metadata trailers) {
            Meter errorMeter = metricRegistry.meter(metricName(ERROR_METRIC, getMethodDescriptor().getFullMethodName().replace("/", ".")));
            if (!status.isOk()) {
                errorMeter.mark();
                log.error("An error occured with {}", serverCall.getMethodDescriptor());
            }

            timer.stop();

            super.close(status, trailers);
        }

        @Override
        public void sendMessage(RespT message) {
            super.sendMessage(message);

            if (message instanceof MessageLite) {
                histogram.update(((MessageLite) message).getSerializedSize());
                log.info("Message sent size = {}", ((MessageLite) message).getSerializedSize());
            }
        }

    };
    return serverCallHandler.startCall(nextCall, metadata);
}
 
开发者ID:husseincoder,项目名称:dockerized-microservices,代码行数:43,代码来源:GrpcServerInterceptor.java

示例13: OpenFlowControlMessageAggregator

import com.codahale.metrics.Meter; //导入依赖的package包/类
/**
 * Generates an OpenFlow message aggregator instance.
 * The instance is for aggregating a specific OpenFlow message
 * type of an OpenFlow switch.
 *
 * @param metricsService metrics service reference object
 * @param providerService control message provider service reference object
 * @param deviceId device identification
 */
public OpenFlowControlMessageAggregator(MetricsService metricsService,
                                        ControlMessageProviderService providerService,
                                        DeviceId deviceId) {
    MetricsComponent mc = metricsService.registerComponent(deviceId.toString());

    OF_TYPE_SET.forEach(type -> {
        MetricsFeature metricsFeature = mc.registerFeature(type.toString());
        Meter rateMeter = metricsService.createMeter(mc, metricsFeature, RATE_NAME);
        Meter countMeter = metricsService.createMeter(mc, metricsFeature, COUNT_NAME);
        rateMeterMap.put(type, rateMeter);
        countMeterMap.put(type, countMeter);
    });

    this.deviceId = deviceId;
    this.providerService = providerService;
    metricsService.notifyReporters();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:OpenFlowControlMessageAggregator.java

示例14: printEventMetric

import com.codahale.metrics.Meter; //导入依赖的package包/类
/**
 * Prints an Event Metric.
 *
 * @param operationStr the string with the intent operation to print
 * @param eventMetric the Event Metric to print
 */
private void printEventMetric(String operationStr,
                              EventMetric eventMetric) {
    Gauge<Long> gauge = eventMetric.lastEventTimestampGauge();
    Meter meter = eventMetric.eventRateMeter();
    TimeUnit rateUnit = TimeUnit.SECONDS;
    double rateFactor = rateUnit.toSeconds(1);

    // Print the Gauge
    print(FORMAT_GAUGE, operationStr, gauge.getValue());

    // Print the Meter
    print(FORMAT_METER, operationStr, meter.getCount(),
          meter.getMeanRate() * rateFactor,
          meter.getOneMinuteRate() * rateFactor,
          meter.getFiveMinuteRate() * rateFactor,
          meter.getFifteenMinuteRate() * rateFactor);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:IntentEventsMetricsCommand.java

示例15: defaultCleanupExecutor

import com.codahale.metrics.Meter; //导入依赖的package包/类
private static ExecutorService defaultCleanupExecutor(String metricsGroup, LifeCycleRegistry lifeCycle, MetricRegistry metricRegistry) {
    final Meter meter = metricRegistry.meter(MetricRegistry.name(metricsGroup, "AstyanaxEventReaderDAO", "discarded_slab_cleanup"));
    String nameFormat = "Events Slab Reader Cleanup-" + metricsGroup.substring(metricsGroup.lastIndexOf('.') + 1) + "-%d";
    ExecutorService executor = new ThreadPoolExecutor(
            NUM_CLEANUP_THREADS, NUM_CLEANUP_THREADS,
            0L, TimeUnit.MILLISECONDS,
            new LinkedBlockingQueue<Runnable>(MAX_CLEANUP_QUEUE_LENGTH),
            new ThreadFactoryBuilder().setNameFormat(nameFormat).build(),
            new ThreadPoolExecutor.DiscardPolicy() {
                @Override
                public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
                    meter.mark();
                }
            });
    lifeCycle.manage(new ExecutorServiceManager(executor, Duration.seconds(5), nameFormat));
    return executor;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:18,代码来源:AstyanaxEventReaderDAO.java


注:本文中的com.codahale.metrics.Meter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。