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


Java SlidingTimeWindowReservoir类代码示例

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


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

示例1: RollingWindowTimerBuilder

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
@DataProvider(value = {
    "42     |   DAYS",
    "123    |   SECONDS",
    "999    |   MILLISECONDS",
    "3      |   HOURS"
}, splitBy = "\\|")
@Test
public void RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowReservoir_with_expected_values(
    long amount, TimeUnit timeUnit
) {
    // given
    RollingWindowTimerBuilder rwtb = new RollingWindowTimerBuilder(amount, timeUnit);

    // when
    Timer timer = rwtb.newMetric();

    // then
    Histogram histogram = (Histogram) getInternalState(timer, "histogram");
    Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
    assertThat(reservoir).isInstanceOf(SlidingTimeWindowReservoir.class);
    // The expected value here comes from logic in the SlidingTimeWindowReservoir constructor.
    assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:24,代码来源:SignalFxEndpointMetricsHandlerTest.java

示例2: RollingWindowHistogramBuilder

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
@DataProvider(value = {
    "42     |   DAYS",
    "123    |   SECONDS",
    "999    |   MILLISECONDS",
    "3      |   HOURS"
}, splitBy = "\\|")
@Test
public void RollingWindowHistogramBuilder_newMetric_creates_new_histogram_with_SlidingTimeWindowReservoir_with_expected_values(
    long amount, TimeUnit timeUnit
) {
    // given
    RollingWindowHistogramBuilder rwhb = new RollingWindowHistogramBuilder(amount, timeUnit);

    // when
    Histogram histogram = rwhb.newMetric();

    // then
    Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
    assertThat(reservoir).isInstanceOf(SlidingTimeWindowReservoir.class);
    // The expected value here comes from logic in the SlidingTimeWindowReservoir constructor.
    assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:23,代码来源:SignalFxEndpointMetricsHandlerTest.java

示例3: testCreateTimer

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
@Test
public void testCreateTimer() throws ReflectiveOperationException {
    final SlidingTimeWindowTimingStrategy strategy = new SlidingTimeWindowTimingStrategy();
    final Timer timer = strategy.createTimer(new MapConfig());
    SlidingTimeWindowReservoir reservoir = reservoir(timer);
    assertNotNull(reservoir);
    assertEquals("timeWindow", strategy.name());
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:9,代码来源:SlidingTimeWindowTimingStrategyTest.java

示例4: addStatElement

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
/** add a metric (time) to a specific resource - for example
 * type = PostgresClient.get
 * time = single operation time in nanoseconds
 */
public static void addStatElement(String type, long time){
  if(!registeredStatRequesters.contains(type)){
    METRICS.register(type, new Histogram(new SlidingTimeWindowReservoir(60,
      TimeUnit.SECONDS)));
    registeredStatRequesters.add(type);
  }
  METRICS.histogram(type).update(time/1000000);
}
 
开发者ID:folio-org,项目名称:raml-module-builder,代码行数:13,代码来源:StatsTracker.java

示例5: getReservoir

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
/**
 * Get reservoir implementation based on the reservoir type
 *
 * @return The {@link Reservoir} implementation
 */
private Reservoir getReservoir() {
    // The Reservoir implementation is selected using a switch statement.
    // The ReservoirType enum is a part of YAML configuration
    // and foreign imports are not supported by Carbon Configuration Maven Plugin.
    // Therefore, the Reservoir class cannot be imported and the Reservoir
    // creation logic cannot be written inside ReservoirType enum.
    switch (reservoirType) {
        case EXPONENTIALLY_DECAYING:
            return new ExponentiallyDecayingReservoir();
        case UNIFORM:
            return new UniformReservoir(reservoirParametersConfig.getSize());
        case SLIDING_WINDOW:
            return new SlidingWindowReservoir(reservoirParametersConfig.getSize());
        case SLIDING_TIME_WINDOW:
            return new SlidingTimeWindowReservoir(reservoirParametersConfig.getWindow(),
                    reservoirParametersConfig.getWindowUnit());
        case HDR_HISTOGRAM:
            Recorder recorder = new Recorder(reservoirParametersConfig.getNumberOfSignificantValueDigits());
            if (reservoirParametersConfig.isResetOnSnapshot()) {
                return new HdrHistogramResetOnSnapshotReservoir(recorder);
            } else {
                return new HdrHistogramReservoir(recorder);
            }
        default:
            throw new RuntimeException("Invalid Reservoir Type");

    }
}
 
开发者ID:wso2,项目名称:carbon-metrics,代码行数:34,代码来源:MetricManager.java

示例6: createTimer

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
public static Timer createTimer(MetricRegistry metrics, String name, final String pipelineName, final String pipelineRev) {
  return create(
    metrics,
    new Timer(new SlidingTimeWindowReservoir(60, TimeUnit.SECONDS)),
    metricName(name, TIMER_SUFFIX),
    pipelineName,
    pipelineRev
  );
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:10,代码来源:MetricsConfigurator.java

示例7: ReducerStateBackupComponent

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
/**
 * Constructor.
 * @param metricRegistry Metrics registry used to log various metrics.
 * @param flakeId       Flake's id to which this component belongs.
 * @param componentName Unique name of the component.
 * @param ctx           Shared zmq context.
 * @param fieldName     The fieldName used by the reducer for grouping.
 */
public ReducerStateBackupComponent(final MetricRegistry metricRegistry,
                                   final String flakeId,
                                   final String componentName,
                                   final ZMQ.Context ctx,
                                   final String fieldName) {
    super(metricRegistry, flakeId, componentName, ctx);
    this.messageBackup = new HashMap<>();
    this.tupleSerializer = SerializerFactory.getSerializer();
    this.keyFieldName = fieldName;
    this.stateBackup = new HashMap<>();
    this.recoveringFlakes = new HashMap<>();

    Gauge<Integer> lenMonitor = metricRegistry.register("BACkUPLEN",
            new Gauge<Integer>() {

                @Override
                public Integer getValue() {
                    Integer sum = 0;
                    for (String key : messageBackup.keySet()) {
                        sum += messageBackup.get(key).size();
                    }
                    return sum;
                }
            });

    Histogram qhist
            = getMetricRegistry() .register(
            MetricRegistry.name(QueueLenMonitor.class, "bkp.len.histo"),
            new Histogram(new SlidingTimeWindowReservoir(2,
                    TimeUnit.SECONDS)));

    BackupLenMonitor mon = new BackupLenMonitor(lenMonitor, qhist);
    mon.start();
    //metricRegistry.meter(MetricRegistry.name
     //       (ReducerStateBackupComponent.class,
     //               "msg-q-len"));
}
 
开发者ID:usc-cloud,项目名称:floe2,代码行数:46,代码来源:ReducerStateBackupComponent.java

示例8: testJsonMetricsTypes

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
@Test
public void testJsonMetricsTypes() {
  assertMetricType("counter", new Counter());
  assertMetricType("histogram", new Histogram(new SlidingTimeWindowReservoir(10, TimeUnit.SECONDS)));
  assertMetricType("gauge", (Gauge<String>) () -> "whatever");
  assertMetricType("meter", new Meter());
  assertMetricType("timer", new Timer());
}
 
开发者ID:vert-x3,项目名称:vertx-dropwizard-metrics,代码行数:9,代码来源:MetricsTest.java

示例9: InnerHistogram

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
InnerHistogram(MetricContext context, String name, ContextAwareHistogram contextAwareHistogram, long windowSize, TimeUnit unit) {
  super(new SlidingTimeWindowReservoir(windowSize, unit));

  this.name = name;

  Optional<MetricContext> parentContext = context.getParent();
  if (parentContext.isPresent()) {
    this.parentHistogram = Optional.fromNullable(parentContext.get().contextAwareHistogram(name, windowSize, unit));
  } else {
    this.parentHistogram = Optional.absent();
  }

  this.contextAwareHistogram = new WeakReference<>(contextAwareHistogram);
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:15,代码来源:InnerHistogram.java

示例10: InnerTimer

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
InnerTimer(MetricContext context, String name, ContextAwareTimer contextAwareTimer, long windowSize, TimeUnit unit) {
  super(new SlidingTimeWindowReservoir(windowSize, unit));
  this.name = name;

  Optional<MetricContext> parentContext = context.getParent();
  if (parentContext.isPresent()) {
    this.parentTimer = Optional.fromNullable(parentContext.get().contextAwareTimer(name, windowSize, unit));
  } else {
    this.parentTimer = Optional.absent();
  }
  this.timer = new WeakReference<>(contextAwareTimer);
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:13,代码来源:InnerTimer.java

示例11: markUsage

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
@Override
public void markUsage(Table table)
{
    Histogram window = usageMap.get(table);

    if (window == null) {
        final SlidingTimeWindowReservoir reservoir = new SlidingTimeWindowReservoir(
                usageTrackTime.getQuantity(),
                usageTrackTime.getUnit());
        window = new Histogram(reservoir);
        usageMap.put(table, window);
    }

    window.update(1);
}
 
开发者ID:airbnb,项目名称:airpal,代码行数:16,代码来源:LocalUsageStore.java

示例12: generateCodahaleMetricsListenerWithSignalFxSupport

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
public CodahaleMetricsListener generateCodahaleMetricsListenerWithSignalFxSupport(
        SignalFxReporterFactory signalFxReporterFactory,
        CodahaleMetricsCollector metricsCollector,
        MetricDimensionConfigurator<Timer> customRequestTimerDimensionConfigurator,
        ExtraRequestLogicHandler extraRequestLogicHandler
) {
    MetricRegistry metricRegistry = metricsCollector.getMetricRegistry();

    // Use the identity function if customRequestTimerDimensionConfigurator is null.
    if (customRequestTimerDimensionConfigurator == null)
        customRequestTimerDimensionConfigurator = METRIC_DIMENSION_CONFIGURATOR_IDENTITY;

    // Create the SignalFxEndpointMetricsHandler with the customRequestTimerDimensionConfigurator and
    //     extraRequestLogicHandler specifics.
    EndpointMetricsHandler endpointMetricsHandler = new SignalFxEndpointMetricsHandler(
            signalFxReporterFactory.getReporter(metricRegistry).getMetricMetadata(),
            metricRegistry,
            // Use a rolling window reservoir with the same window as the reporting frequency,
            //      to prevent the dashboards from producing false or misleading data.
            new SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder(signalFxReporterFactory.getInterval(),
                    signalFxReporterFactory.getTimeUnit()),
            // Do the default request latency timer dimensions, chained with customRequestTimerDimensionConfigurator
            //      for any custom logic desired.
            DEFAULT_REQUEST_LATENCY_TIMER_DIMENSION_CONFIGURATOR
                    .chainedWith(customRequestTimerDimensionConfigurator)
    ) {
        @Override
        public void handleRequest(RequestInfo<?> requestInfo, ResponseInfo<?> responseInfo,
                                  HttpProcessingState httpState,
                                  int responseHttpStatusCode, int responseHttpStatusCodeXXValue,
                                  long requestElapsedTimeMillis) {

            // Do the normal endpoint stuff.
            super.handleRequest(requestInfo, responseInfo, httpState, responseHttpStatusCode,
                    responseHttpStatusCodeXXValue,
                    requestElapsedTimeMillis);

            // Do any extra logic (if desired).
            if (extraRequestLogicHandler != null) {
                extraRequestLogicHandler.handleExtraRequestLogic(
                        requestInfo, responseInfo, httpState, responseHttpStatusCode, responseHttpStatusCodeXXValue,
                        requestElapsedTimeMillis
                );
            }
        }
    };

    return CodahaleMetricsListener
            .newBuilder(metricsCollector)
            .withEndpointMetricsHandler(endpointMetricsHandler)
            // The metric names should be basic with no prefix - SignalFx dimensions do the job normally covered
            //      by metric name prefixes.
            .withServerStatsMetricNamingStrategy(CodahaleMetricsListener.MetricNamingStrategy.defaultNoPrefixImpl())
            .withServerConfigMetricNamingStrategy(CodahaleMetricsListener.MetricNamingStrategy.defaultNoPrefixImpl())
            // Histograms should use a rolling window reservoir with the same window as the reporting frequency,
            //      otherwise the dashboards will produce false or misleading data.
            .withRequestAndResponseSizeHistogramSupplier(
                    () -> new Histogram(
                            new SlidingTimeWindowReservoir(signalFxReporterFactory.getInterval(),
                                    signalFxReporterFactory.getTimeUnit())
                    )
            )
            .build();
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:65,代码来源:MetricsConfigurationHelper.java

示例13: newMetric

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
@Override
public Timer newMetric() {
    return new Timer(new SlidingTimeWindowReservoir(amount, timeUnit));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:5,代码来源:SignalFxEndpointMetricsHandler.java

示例14: createTimer

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
@Override
public Timer createTimer(Config config) {
    return new Timer(new SlidingTimeWindowReservoir(
            config.longValue(WINDOW_PROP).orElse(DEFAULT_WINDOW),
            config.enumValue(WINDOW_UNIT_PROP, TimeUnit.class).orElse(DEFAULT_WINDOW_UNIT)));
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:7,代码来源:SlidingTimeWindowTimingStrategy.java

示例15: TryThisOut

import com.codahale.metrics.SlidingTimeWindowReservoir; //导入依赖的package包/类
public TryThisOut() {
    registry = new MetricRegistry();
    gauge = new Gauge<Integer>() {
        @Override
        public Integer getValue() {
            return gaugeValue;
        }
    };
    registry.register("gauge", gauge);
    counter = new Counter();
    registry.register("counter", counter);
    histogram = new Histogram(new SlidingTimeWindowReservoir(10, TimeUnit.SECONDS));
    registry.register("histogram", histogram);
    meter = new Meter();
    registry.register("meter", meter);
    timer = new Timer();
    registry.register("timer", timer);

    String instanceId = EC2MetadataUtils.getInstanceId();
    // try out the default constructor.
    AmazonCloudWatchClient client = new AmazonCloudWatchClient();
    reporter = new CloudWatchReporter.Builder(registry, client)
            .dimension("instanceId", instanceId)
            .namespace("some-namespace")
            .build();
    reporter.start(5, TimeUnit.SECONDS);

    executorService = Executors.newSingleThreadScheduledExecutor();
    executorService.scheduleAtFixedRate(new Runnable() {
        private int counterVal;
        private Random random = new Random();

        @Override
        public void run() {
            gaugeValue = counterVal++;
            counter.inc();
            Timer.Context context = timer.time();
            meter.mark();
            histogram.update((int)(random.nextGaussian() * 10));
            context.stop();
        }
    }, 0, 1, TimeUnit.SECONDS);
}
 
开发者ID:basis-technology-corp,项目名称:metrics-cloudwatch-reporter,代码行数:44,代码来源:TryThisOut.java


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