Java 类io.vertx.core.metrics.MetricsOptions 实例源码

项目:statful-client-vertx    文件:StatfulMetricsFactoryImpl.java   
@Override
public final VertxMetrics metrics(@Nonnull final Vertx vertx, @Nonnull final VertxOptions options) {
    final MetricsOptions metricsOptions = options.getMetricsOptions();

    final StatfulMetricsOptions statfulMetricsOptions;
    if (metricsOptions instanceof StatfulMetricsOptions) {
        statfulMetricsOptions = (StatfulMetricsOptions) metricsOptions;
    } else {
        statfulMetricsOptions = new StatfulMetricsOptions();
    }

    // check if there is a configuration path set, if so, load configuration from file
    final StatfulMetricsOptions effective;
    String configPath = statfulMetricsOptions.getConfigPath();
    if (Strings.isNullOrEmpty(configPath)) {
        effective = statfulMetricsOptions;
    } else {
        effective = buildFromFile(vertx, configPath);
    }

    return new VertxMetricsImpl(vertx, effective);
}
项目:runrightfast-vertx    文件:VertxServiceImplTest.java   
@Test
public void test_vertx_metrics_options() {
    log.info("test_vertx_metrics_options");
    service = new VertxServiceImpl(config.getConfig(ConfigUtils.configPath(CONFIG_NAMESPACE, "vertx-with-metrics")), deployments, appEventLogger);
    ServiceUtils.start(service);
    services.add(service);
    final Vertx vertx = service.getVertx();
    log.log(Level.INFO, "vertx.isClustered() = {0}", vertx.isClustered());
    log.log(Level.INFO, "vertx.isMetricsEnabled() = {0}", vertx.isMetricsEnabled());
    assertThat(vertx.isClustered(), is(false));
    assertThat(vertx.isMetricsEnabled(), is(true));

    final VertxOptions vertxOptions = service.getVertxOptions();
    final MetricsOptions metricsOptions = vertxOptions.getMetricsOptions();
    log.log(INFO, "metricsOptions class : {0}", metricsOptions.getClass().getName());
    final DropwizardMetricsOptions dropwizardMetricsOptions = (DropwizardMetricsOptions) metricsOptions;
    assertThat(dropwizardMetricsOptions.isJmxEnabled(), is(true));
    assertThat(dropwizardMetricsOptions.getJmxDomain(), is("co.runrightfast.vertx.metrics"));
    assertThat(dropwizardMetricsOptions.getRegistryName(), is(VERTX_METRIC_REGISTRY_NAME));
    assertThat(dropwizardMetricsOptions.getMonitoredEventBusHandlers().size(), is(2));
    assertThat(dropwizardMetricsOptions.getMonitoredHttpServerUris().size(), is(3));
    assertThat(dropwizardMetricsOptions.getMonitoredHttpClientUris().size(), is(4));

}
项目:vertx-spring    文件:SpringVertx.java   
public SpringVertx build() {

            if (!listeners.isEmpty()) {
                metricsFactories.add(new VertxListenerAwareMetricsFactory(listeners));
            }

            if (!metricsFactories.isEmpty()) {
                VertxMetricsFactory singleMetricsFactory;
                if (metricsFactories.size() > 1) {
                    singleMetricsFactory = new DispatchingVertxMetricsFactory(metricsFactories);
                } else {
                    singleMetricsFactory = metricsFactories.get(0);
                }
                MetricsOptions metricsOptions = getOrCreateOptions().getMetricsOptions();
                metricsOptions.setEnabled(true);
                metricsOptions.setFactory(singleMetricsFactory);
            }

            return new SpringVertx(
                    factory,
                    getOrCreateOptions(),
                    verticleRegistrations,
                    listeners,
                    verticleFactoryPrefix,
                    startupPhase,
                    autoStartup);
        }
项目:ninja-vertx-standalone    文件:VertxInitializer.java   
public VertxInitializer(NinjaProperties ninjaProperties) {
    options = new VertxOptions()
            .setClustered(ninjaProperties.getBooleanWithDefault(VERTX_IS_CLUSTERED, false))
            .setEventLoopPoolSize(ninjaProperties.getIntegerWithDefault(VERTX_EVENT_LOOP_SIZE,DEFAULT_EVENT_LOOP_POOL_SIZE))
            .setMaxEventLoopExecuteTime(Long.valueOf(ninjaProperties.getWithDefault(VERTX_MAX_EVENTLOOP_EXECUTE_TIME,"2000000000")))
            .setWorkerPoolSize(ninjaProperties.getIntegerWithDefault(VERTX_WORKER_POOL_SIZE, 20))
            .setMaxWorkerExecuteTime(Long.valueOf(ninjaProperties.getWithDefault(VERTX_MAX_WORKER_EXECITE_TIME,"60000000000")));


    if (ninjaProperties.getBooleanWithDefault(VERTX_IS_METRICS_ENABLED, false)) {
        options.setMetricsOptions(new MetricsOptions().setEnabled(true));
    }

    deploymentOptions = new DeploymentOptions().setInstances(ninjaProperties.getIntegerWithDefault(VERTX_INSTANCES, 1));

    if (ninjaProperties.getBooleanWithDefault(VERTX_IS_WORKER, true)) {
        deploymentOptions
                .setWorker(true)
                .setWorkerPoolName("ninja-vertx");
    }
    if (options.isClustered()) {
        CountDownLatch countDownLatch = new CountDownLatch(1);
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                vertx = res.result();
                countDownLatch.countDown();
            } else {
                log.error(res.cause().getMessage(), res.cause());
            }
        });
        await(countDownLatch);
    } else {
        vertx = Vertx.vertx(options);
    }
}
项目:hono    文件:MetricConfig.java   
@Bean
@ConditionalOnProperty(prefix = "hono.metric", name = "vertx", havingValue = "true")
public MetricsOptions vertxMetricsOptions() {
    LOG.info("metrics - vertx activated");
    SharedMetricRegistries.add(HONO, metricRegistry);
    SharedMetricRegistries.setDefault(HONO, metricRegistry);
    return new DropwizardMetricsOptions().setEnabled(true).setRegistryName(HONO)
            .setBaseName(prefix + ".vertx").setJmxEnabled(true);
}
项目:vertx-warp10-metrics    文件:VertxMetricsFactoryImpl.java   
@Override
public VertxMetrics metrics(Vertx vertx, VertxOptions options) {
  MetricsOptions metricsOptions = options.getMetricsOptions();
  VertxWarp10Options vertxWarp10Options;
  if (metricsOptions instanceof VertxWarp10Options) {
    vertxWarp10Options = (VertxWarp10Options) metricsOptions;
  } else {
    vertxWarp10Options = new VertxWarp10Options(metricsOptions.toJson());
  }
  return new VertxMetricsImpl(vertx, vertxWarp10Options);
}
项目:runrightfast-vertx    文件:VertxServiceImpl.java   
/**
 *
 * @return a copy of the VertxOptions that was used to create the Vertx instance
 */
@Override
public VertxOptions getVertxOptions() {
    final VertxOptions copy = new VertxOptions(vertxOptions);
    final MetricsOptions metricsOptions = vertxOptions.getMetricsOptions();
    if (metricsOptions != null) {
        if (metricsOptions instanceof DropwizardMetricsOptions) {
            copy.setMetricsOptions(new DropwizardMetricsOptions((DropwizardMetricsOptions) metricsOptions));
        } else {
            copy.setMetricsOptions(new DropwizardMetricsOptions(metricsOptions));
        }
    }
    return copy;
}
项目:runrightfast-vertx    文件:VertxServiceImpl.java   
private void logVertxOptions() {
    LOG.logp(CONFIG, getClass().getName(), "logVertxOptions", () -> {
        final JsonObject json = new JsonObject()
                .put("BlockedThreadCheckInterval", vertxOptions.getBlockedThreadCheckInterval())
                .put("ClusterHost", vertxOptions.getClusterHost())
                .put("ClusterPingInterval", vertxOptions.getClusterPingInterval())
                .put("ClusterPingReplyInterval", vertxOptions.getClusterPingReplyInterval())
                .put("ClusterPort", vertxOptions.getClusterPort())
                .put("EventLoopPoolSize", vertxOptions.getEventLoopPoolSize())
                .put("HAGroup", vertxOptions.getHAGroup())
                .put("InternalBlockingPoolSize", vertxOptions.getInternalBlockingPoolSize())
                .put("MaxEventLoopExecuteTime", vertxOptions.getMaxEventLoopExecuteTime())
                .put("MaxWorkerExecuteTime", vertxOptions.getMaxWorkerExecuteTime())
                .put("QuorumSize", vertxOptions.getQuorumSize())
                .put("WarningExceptionTime", vertxOptions.getWarningExceptionTime())
                .put("WorkerPoolSize", vertxOptions.getWorkerPoolSize());

        final ClusterManager clusterManager = vertxOptions.getClusterManager();
        if (clusterManager != null) {
            json.put("clusterManagerClass", clusterManager.getClass().getName());
        }

        final MetricsOptions metricsOptions = vertxOptions.getMetricsOptions();
        if (metricsOptions != null) {
            json.put("MetricsOptions", toJsonObject(metricsOptions));
        }
        return json.encodePrettily();
    });
}
项目:runrightfast-vertx    文件:VertxServiceImpl.java   
private JsonObject toJsonObject(final MetricsOptions metricsOptions) {
    if (metricsOptions instanceof DropwizardMetricsOptions) {
        final DropwizardMetricsOptions dropwizardMetricsOptions = (DropwizardMetricsOptions) metricsOptions;
        final JsonObject json = new JsonObject().put("enabled", metricsOptions.isEnabled())
                .put("jmxEnabled", dropwizardMetricsOptions.isJmxEnabled());

        toJsonObject(dropwizardMetricsOptions.getMonitoredEventBusHandlers()).ifPresent(jsonArray -> json.put("MonitoredEventBusHandlers", jsonArray));
        toJsonObject(dropwizardMetricsOptions.getMonitoredHttpClientUris()).ifPresent(jsonArray -> json.put("MonitoredHttpClientUris", jsonArray));
        toJsonObject(dropwizardMetricsOptions.getMonitoredHttpServerUris()).ifPresent(jsonArray -> json.put("MonitoredHttpServerUris", jsonArray));

        return json;
    } else {
        return new JsonObject().put("enabled", metricsOptions.isEnabled());
    }
}
项目:vertx-hawkular-metrics    文件:VertxMetricsFactoryImpl.java   
@Override
public VertxMetrics metrics(Vertx vertx, VertxOptions vertxOptions) {
  MetricsOptions metricsOptions = vertxOptions.getMetricsOptions();
  VertxHawkularOptions vertxHawkularOptions;
  if (metricsOptions instanceof VertxHawkularOptions) {
    vertxHawkularOptions = (VertxHawkularOptions) metricsOptions;
  } else {
    vertxHawkularOptions = new VertxHawkularOptions(metricsOptions.toJson());
  }
  return new VertxMetricsImpl(vertx, vertxHawkularOptions);
}
项目:vertx-dropwizard-metrics    文件:DropwizardMetricsOptions.java   
/**
 * Copy constructor with base metrics options
 *
 * @param other The other {@link MetricsOptions} to copy when creating this
 */
public DropwizardMetricsOptions(MetricsOptions other) {
  super(other);
  jmxEnabled = DEFAULT_JMX_ENABLED;
  monitoredEventBusHandlers = new ArrayList<>(DEFAULT_MONITORED_HANDLERS);
  monitoredHttpServerUris = new ArrayList<>(DEFAULT_MONITORED_HTTP_SERVER_URIS);
  monitoredHttpClientUris = new ArrayList<>(DEFAULT_MONITORED_HTTP_CLIENT_URIS);
  monitoredHttpClientEndpoints = new ArrayList<>(DEFAULT_MONITORED_HTTP_CLIENT_ENDPOINTS);
}
项目:vertx-spring    文件:VertxProperties.java   
public MetricsOptions getMetricsOptions() {
    return vertxOptions.getMetricsOptions();
}
项目:vertx-spring    文件:VertxProperties.java   
public void setMetricsOptions(MetricsOptions metrics) {
    vertxOptions.setMetricsOptions(metrics);
}
项目:vertx-prometheus-metrics    文件:VertxPrometheusMetricsFactory.java   
@Override
public @NotNull MetricsOptions newOptions() {
  return new VertxPrometheusOptions();
}
项目:vertx-prometheus-metrics    文件:VertxPrometheusMetricsFactory.java   
private static @NotNull VertxPrometheusOptions asPrometheusOptions(@NotNull VertxOptions vertxOptions) {
  final MetricsOptions metricsOptions = vertxOptions.getMetricsOptions();
  return metricsOptions instanceof VertxPrometheusOptions
      ? (VertxPrometheusOptions) metricsOptions
      : new VertxPrometheusOptions(metricsOptions.toJson());
}
项目:chili-core    文件:SystemSettings.java   
/**
 * @return a set of VertxOptions used for deployment.
 */
@JsonIgnore
public VertxOptions getOptions() {
    return new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(metrics));
}
项目:statful-client-vertx    文件:StatfulMetricsFactoryImpl.java   
@Override
public final MetricsOptions newOptions() {
    return new StatfulMetricsOptions();
}
项目:vertx-warp10-metrics    文件:VertxMetricsFactoryImpl.java   
@Override
public MetricsOptions newOptions() {
  return new VertxWarp10Options();
}
项目:vertx-hawkular-metrics    文件:VertxMetricsFactoryImpl.java   
@Override
public MetricsOptions newOptions() {
  return new VertxHawkularOptions();
}
项目:vertx-dropwizard-metrics    文件:VertxMetricsFactoryImpl.java   
@Override
public MetricsOptions newOptions() {
  return new DropwizardMetricsOptions();
}
项目:statful-client-vertx    文件:StatfulMetricsFactoryImplTest.java   
@Test
public void testCreationWithNonStatfulOptionsShouldBeDisabledByDefault() {

    when(vertxOptions.getMetricsOptions()).thenReturn(mock(MetricsOptions.class));

    assertFalse(victim.metrics(vertx, vertxOptions).isEnabled());
}
项目:hono    文件:HonoMessagingApplicationConfig.java   
/**
 * Vert.x metrics options, if configured
 *
 * @param metricsOptions Vert.x metrics options
 * @see MetricConfig
 */
@Autowired(required = false)
public void setMetricsOptions(final MetricsOptions metricsOptions) {
    this.metricsOptions = metricsOptions;
}
项目:hono    文件:AbstractAdapterConfig.java   
/**
 * Vert.x metrics options, if configured
 *
 * @param metricsOptions Vert.x metrics options
 * @see MetricConfig
 */
@Autowired(required = false)
public void setMetricsOptions(final MetricsOptions metricsOptions) {
    this.metricsOptions = metricsOptions;
}