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


Java SharedMetricRegistries.getOrCreate方法代码示例

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


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

示例1: config

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
public static void config(String graphiteHost, int port, TimeUnit tu,
        int period, VertxOptions vopt, String hostName) {
  final String registryName = "okapi";
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(registryName);

  DropwizardMetricsOptions metricsOpt = new DropwizardMetricsOptions();
  metricsOpt.setEnabled(true).setRegistryName(registryName);
  vopt.setMetricsOptions(metricsOpt);
  Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, port));
  final String prefix = "folio.okapi." + hostName ;
  GraphiteReporter reporter = GraphiteReporter.forRegistry(registry)
          .prefixedWith(prefix)
          .build(graphite);
  reporter.start(period, tu);

  logger.info("Metrics remote:" + graphiteHost + ":"
          + port + " this:" + prefix);
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:19,代码来源:DropwizardHelper.java

示例2: EventSchedulerService

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Inject
public EventSchedulerService(EventSchedulerDao eventSchedulerDao, EventSchedulerRegistry eventSchedulerRegistry,
                             @Named("eventScheduler.batchRead.intervalms") Integer batchReadInterval,
                             @Named("eventScheduler.batchRead.batchSize") Integer batchSize,
                             ObjectMapper objectMapper) {
    this.eventSchedulerDao = eventSchedulerDao;
    this.eventSchedulerRegistry = eventSchedulerRegistry;
    this.batchReadInterval = batchReadInterval;
    this.batchSize = batchSize;
    this.objectMapper = objectMapper;

    ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
    // remove the task from scheduler on cancel
    executor.setRemoveOnCancelPolicy(true);
    scheduledExecutorService =
            new InstrumentedScheduledExecutorService(Executors.unconfigurableScheduledExecutorService(executor),
                    SharedMetricRegistries.getOrCreate(METRIC_REGISTRY_NAME), scheduledExectorSvcName);
}
 
开发者ID:flipkart-incubator,项目名称:flux,代码行数:19,代码来源:EventSchedulerService.java

示例3: RedriverService

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Inject
public RedriverService(MessageManagerService messageService,
                       RedriverRegistry redriverRegistry,
                       @Named("redriver.batchRead.intervalms") Integer batchReadInterval,
                       @Named("redriver.batchRead.batchSize") Integer batchSize) {
    this.redriverRegistry = redriverRegistry;
    this.batchReadInterval = batchReadInterval;
    this.batchSize = batchSize;
    this.messageService = messageService;
    asyncRedriveService = Executors.newFixedThreadPool(10);

    ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1);
    // remove the task from scheduler on cancel
    executor.setRemoveOnCancelPolicy(true);
    scheduledExecutorService =
            new InstrumentedScheduledExecutorService(Executors.unconfigurableScheduledExecutorService(executor),
                    SharedMetricRegistries.getOrCreate(METRIC_REGISTRY_NAME), scheduledExectorSvcName);
}
 
开发者ID:flipkart-incubator,项目名称:flux,代码行数:19,代码来源:RedriverService.java

示例4: test_eventBus_GetVerticleDeployments

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Test
public void test_eventBus_GetVerticleDeployments() throws InterruptedException, ExecutionException, TimeoutException {
    log.info("test_eventBus_GetVerticleDeployments");
    final Vertx vertx = vertxService.getVertx();

    final RunRightFastVerticleId verticleManagerId = RunRightFastVerticleManager.VERTICLE_ID;
    final CompletableFuture<GetVerticleDeployments.Response> future = new CompletableFuture<>();
    final String address = EventBusAddress.eventBusAddress(verticleManagerId, "get-verticle-deployments");
    vertx.eventBus().send(
            address,
            GetVerticleDeployments.Request.newBuilder().build(),
            new DeliveryOptions().setSendTimeout(2000L),
            responseHandler(future, GetVerticleDeployments.Response.class)
    );
    final GetVerticleDeployments.Response result = future.get(2000L, TimeUnit.MILLISECONDS);
    assertThat(result.getDeploymentsCount(), is(2));

    final MetricRegistry metricRegistryTestVerticle1 = SharedMetricRegistries.getOrCreate(TestVerticle.VERTICLE_ID.toString());
    assertThat(metricRegistryTestVerticle1.getCounters().get(RunRightFastVerticleMetrics.Counters.INSTANCE_STARTED.metricName).getCount(), is(1L));

    final MetricRegistry metricRegistryTestVerticle2 = SharedMetricRegistries.getOrCreate(TestVerticle2.VERTICLE_ID.toString());
    assertThat(metricRegistryTestVerticle2.getCounters().get(RunRightFastVerticleMetrics.Counters.INSTANCE_STARTED.metricName).getCount(), is(5L));
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:24,代码来源:RunRightFastVertxApplicationTest.java

示例5: test_eventBus_GetVerticleDeployments_usingProtobufMessageProducer

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Test
public void test_eventBus_GetVerticleDeployments_usingProtobufMessageProducer() throws InterruptedException, ExecutionException, TimeoutException {
    log.info("test_eventBus_GetVerticleDeployments");
    final Vertx vertx = vertxService.getVertx();

    final RunRightFastVerticleId verticleManagerId = RunRightFastVerticleManager.VERTICLE_ID;
    final CompletableFuture future = new CompletableFuture();
    final String address = EventBusAddress.eventBusAddress(verticleManagerId, "get-verticle-deployments");

    final ProtobufMessageProducer producer = new ProtobufMessageProducer(
            vertx.eventBus(),
            address,
            getVerticleDeploymentsResponseCodec,
            SharedMetricRegistries.getOrCreate(getClass().getSimpleName())
    );
    producer.send(
            GetVerticleDeployments.Request.newBuilder().build(),
            new DeliveryOptions().setSendTimeout(2000L),
            responseHandler(future, GetVerticleDeployments.Response.class)
    );
    final Object result = future.get(2000L, TimeUnit.MILLISECONDS);
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:23,代码来源:RunRightFastVertxApplicationTest.java

示例6: forTestSetMetricsRegistryName

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@VisibleForTesting
@SuppressWarnings("unused")
public static void forTestSetMetricsRegistryName(String metricsRegistryName) {
  if (imStarted) {
    throw new IllegalStateException("Unit tests only!!!");
  }
  MetricRegistry metrics = SharedMetricRegistries.getOrCreate(metricsRegistryName);
  bambooReadTimer = new Timer();
  metrics.register("bambooReadTimer", bambooReadTimer);
  bambooParseTimer = new Timer();
  metrics.register("bambooParseTimer", bambooParseTimer);
  warcDocCountHistogram = new Histogram(new UniformReservoir());
  metrics.register("warcDocCountHistogram", warcDocCountHistogram);
  warcSizeHistogram = new Histogram(new UniformReservoir());
  metrics.register("warcSizeHistogram", warcSizeHistogram);
}
 
开发者ID:nla,项目名称:bamboo,代码行数:17,代码来源:BaseWarcDomainManager.java

示例7: testConnectionLife

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Test
public void testConnectionLife() throws SQLException {
    // Act
    Connection connection = DriverManager.getConnection(URL + ";metrics_registry=life", H2DbUtil.USERNAME, H2DbUtil.PASSWORD);
    Statement statement = connection.createStatement();
    H2DbUtil.close(statement, connection);
    // Assert
    assertNotNull(connection);
    assertTrue(Proxy.isProxyClass(connection.getClass()));
    MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate("life");
    Timer lifeTimer = metricRegistry.timer("java.sql.Connection");
    assertNotNull(lifeTimer);
    assertThat(lifeTimer.getCount(), equalTo(1L));
    Timer getTimer = metricRegistry.timer("java.sql.Connection.get");
    assertNotNull(getTimer);
    assertThat(getTimer.getCount(), equalTo(1L));
}
 
开发者ID:gquintana,项目名称:metrics-sql,代码行数:18,代码来源:DriverTest.java

示例8: callExceptionMeteredMethodOnceWithThrowingNonExpectedException

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Test
public void callExceptionMeteredMethodOnceWithThrowingNonExpectedException() {
    assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
    MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
    assertThat("Meters are not registered correctly", registry.getMeters().keySet(), is(equalTo(absoluteMetricNames())));

    final RuntimeException exception = new IllegalStateException("message");
    Runnable runnableThatThrowsIllegalStateException = new Runnable() {
        @Override
        public void run() {
            throw exception;
        }
    };

    // Call the metered method and assert it hasn't been marked and that the original exception has been rethrown
    try {
        instance.illegalArgumentExceptionMeteredMethod(runnableThatThrowsIllegalStateException);
    } catch (RuntimeException cause) {
        assertThat("Meter counts are incorrect", registry.getMeters().values(), everyItem(Matchers.<Meter>hasProperty("count", equalTo(0L))));
        assertSame("Exception thrown is incorrect", cause, exception);
        return;
    }

    fail("No exception has been re-thrown!");
}
 
开发者ID:astefanutti,项目名称:metrics-aspectj,代码行数:26,代码来源:MeteredMethodWithExceptionsTest.java

示例9: callExceptionMeteredStaticMethodsOnceWithoutThrowing

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Test
public void callExceptionMeteredStaticMethodsOnceWithoutThrowing() {
    Runnable runnableThatDoesNoThrowExceptions = new Runnable() {
        @Override
        public void run() {
        }
    };

    // Call the metered methods and assert they haven't been marked
    MeteredStaticMethodWithExceptions.illegalArgumentExceptionMeteredStaticMethod(runnableThatDoesNoThrowExceptions);
    MeteredStaticMethodWithExceptions.exceptionMeteredStaticMethod(runnableThatDoesNoThrowExceptions);

    assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
    MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
    assertThat("Meters are not registered correctly", registry.getMeters().keySet(), is(equalTo(absoluteMetricNames())));
    assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(0)).getCount(), is(equalTo(METER_COUNTS[0].get())));
    assertThat("Meter count is incorrect", registry.getMeters().get(absoluteMetricName(1)).getCount(), is(equalTo(METER_COUNTS[1].get())));
}
 
开发者ID:astefanutti,项目名称:metrics-aspectj,代码行数:19,代码来源:MeteredStaticMethodWithExceptionsTest.java

示例10: resolveMetricRegistry

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Override
public MetricRegistry resolveMetricRegistry(String registry) {
    Matcher matcher = EL_PATTERN.matcher(registry);
    if (matcher.matches()) {
        Object evaluation = processor.eval(matcher.group(1));
        if (evaluation instanceof String)
            return SharedMetricRegistries.getOrCreate((String) evaluation);
        else if (evaluation instanceof MetricRegistry)
            return (MetricRegistry) evaluation;
        else
            throw new IllegalStateException("Unable to resolve metrics registry from expression [" + registry + "]");
    } else if (!matcher.find()) {
        return SharedMetricRegistries.getOrCreate(registry);
    } else {
        return SharedMetricRegistries.getOrCreate(evaluateCompositeExpression(matcher));
    }
}
 
开发者ID:astefanutti,项目名称:metrics-aspectj,代码行数:18,代码来源:JavaxElMetricStrategy.java

示例11: callGaugesAfterSetterCalls

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Test
public void callGaugesAfterSetterCalls() {
    assertThat("Shared metric registry is not created", SharedMetricRegistries.names(), hasItem(REGISTRY_NAME));
    MetricRegistry registry = SharedMetricRegistries.getOrCreate(REGISTRY_NAME);
    assertThat("Gauges are not registered correctly", registry.getGauges().keySet(), is(equalTo(absoluteMetricNames())));

    long value = Math.round(Math.random() * Long.MAX_VALUE);
    // Call the setter methods
    instance.setPublicGauge(value);
    instance.setPackagePrivateGauge(value);
    instance.setProtectedGauge(value);
    method("setPrivateGauge").withParameterTypes(long.class).in(instance).invoke(value);

    // And assert the gauges are up-to-date
    assertThat("Gauge values are incorrect", registry.getGauges().values(), everyItem(Matchers.<Gauge>hasProperty("value", equalTo(value))));
}
 
开发者ID:astefanutti,项目名称:metrics-aspectj,代码行数:17,代码来源:GaugeMethodWithVisibilityModifiersTest.java

示例12: MetricHandler

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param store
 *            Metric store
 */
public MetricHandler(@Nonnull final MetricStore store) {
    this.store = Objects.requireNonNull(store);

    final MetricRegistry registry = SharedMetricRegistries
            .getOrCreate("default");
    this.metricMeter = registry
            .meter(MetricRegistry.name(MetricHandler.class, "metric-rate"));
}
 
开发者ID:smoketurner,项目名称:graphiak,代码行数:15,代码来源:MetricHandler.java

示例13: MetricStore

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param client
 *            Riak client
 */
public MetricStore(@Nonnull final RiakClient client) {
    this.client = Objects.requireNonNull(client);

    final MetricRegistry registry = SharedMetricRegistries
            .getOrCreate("default");
    this.queryTimer = registry
            .timer(MetricRegistry.name(MetricStore.class, "query"));
    this.storeTimer = registry
            .timer(MetricRegistry.name(MetricStore.class, "store"));
    this.deleteTimer = registry
            .timer(MetricRegistry.name(MetricStore.class, "delete"));
}
 
开发者ID:smoketurner,项目名称:graphiak,代码行数:19,代码来源:MetricStore.java

示例14: getMetricRegistry

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
private MetricRegistry getMetricRegistry() {
  MetricRegistry registry = environment.metrics();

  if (registry == null) {
    LOG.warn("No environment metrics found!");
    registry = SharedMetricRegistries.getOrCreate("com.hubspot");
  }

  return registry;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:11,代码来源:GuicePropertyFilteringMessageBodyWriter.java

示例15: setUp

import com.codahale.metrics.SharedMetricRegistries; //导入方法依赖的package包/类
@Before
public void setUp(TestContext context) {
  String graphiteHost = System.getProperty("graphiteHost");

  final String registryName = "okapi";
  MetricRegistry registry = SharedMetricRegistries.getOrCreate(registryName);

  // Note the setEnabled (true or false)
  DropwizardMetricsOptions metricsOpt = new DropwizardMetricsOptions().
          setEnabled(false).setRegistryName(registryName);

  vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(metricsOpt));

  reporter1 = ConsoleReporter.forRegistry(registry).build();
  reporter1.start(1, TimeUnit.SECONDS);

  if (graphiteHost != null) {
    Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, 2003));
    reporter2 = GraphiteReporter.forRegistry(registry)
            .prefixedWith("okapiserver")
            .build(graphite);
    reporter2.start(1, TimeUnit.MILLISECONDS);
  }

  DeploymentOptions opt = new DeploymentOptions()
    .setConfig(new JsonObject().put("port", Integer.toString(port)));


  vertx.deployVerticle(MainVerticle.class.getName(),
          opt, context.asyncAssertSuccess());
  httpClient = vertx.createHttpClient();
}
 
开发者ID:folio-org,项目名称:okapi,代码行数:33,代码来源:MetricsTest.java


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