List of usage examples for io.vertx.core VertxOptions setMetricsOptions
public VertxOptions setMetricsOptions(MetricsOptions metrics)
From source file:co.runrightfast.vertx.core.impl.VertxServiceImpl.java
License:Apache License
/** * * @return a copy of the VertxOptions that was used to create the Vertx instance *//*from ww w . ja va2 s . com*/ @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; }
From source file:io.github.bckfnn.actioner.Main.java
License:Apache License
public static void deploy(Class<? extends Verticle> verticle, String configName, String[] args, Handler<Vertx> result) throws Exception { if (args.length >= 1 && args[0].equals("stop")) { System.out.println("stopping"); System.exit(1);/* w w w. j av a2 s .c o m*/ } System.setProperty("appConfig", configName); System.setProperty("vertx.logger-delegate-factory-class-name", "io.vertx.core.logging.SLF4JLogDelegateFactory"); System.setProperty("vertx.disableFileCaching", "true"); Config config = loadConfig(); boolean develop = config.getBoolean("develop"); checkEndorsed(config, args); VertxOptions vertxOptions = new VertxOptions(); vertxOptions.setWorkerPoolSize(config.getInt("workerPoolSize")); if (config.hasPath("metrics")) { DropwizardMetricsOptions opt = new DropwizardMetricsOptions(); opt.setEnabled(config.getBoolean("metrics.enabled")); opt.setRegistryName(config.getString("metrics.registryName")); opt.addMonitoredHttpServerUri(new Match().setValue(".*").setType(MatchType.REGEX)); opt.addMonitoredHttpClientUri(new Match().setValue(".*").setType(MatchType.REGEX)); opt.addMonitoredEventBusHandler(new Match().setValue(".*").setType(MatchType.REGEX)); vertxOptions.setMetricsOptions(opt); } Vertx vertx = Vertx.vertx(vertxOptions); /* MetricRegistry registry = SharedMetricRegistries.getOrCreate("vertxRegistry"); ConsoleReporter rep = ConsoleReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); rep.start(10, TimeUnit.SECONDS); */ /* System.out.println(vertx); MetricsService metricsService = MetricsService.create(vertx); JsonObject metrics = metricsService.getMetricsSnapshot(vertx); System.out.println("xx:" + metrics); System.out.println("xx:" + AbstractMetrics.class.getClassLoader()); */ DeploymentOptions opts = new DeploymentOptions(); opts.setInstances(config.getInt("instances")); if (develop) { opts.setIsolatedClasses(config.getStringList("isolatedClasses")); } AtomicReference<String> deploymentId = new AtomicReference<>(); Function<Handler<Vertx>, Void> deploy = h -> { if (develop) { opts.setIsolationGroup("ethics" + System.currentTimeMillis()); } vertx.deployVerticle(verticle.getName(), opts, res -> { if (res.succeeded()) { deploymentId.set(res.result()); h.handle(vertx); } else { res.cause().printStackTrace(); } }); return null; }; deploy.apply(result); if (develop) { redeploy(() -> { vertx.undeploy(deploymentId.get(), r -> { deploy.apply(h -> { System.err.println("redeployed!"); }); }); }); } }
From source file:org.eclipse.hono.messaging.HonoMessagingApplicationConfig.java
License:Open Source License
/** * Gets the singleton Vert.x instance to be used by Hono. * * @return the instance.//w w w . java2s. c o m */ @Bean public Vertx vertx() { VertxOptions options = new VertxOptions().setWarningExceptionTime(1500000000) .setAddressResolverOptions(new AddressResolverOptions().setCacheNegativeTimeToLive(0) // discard failed DNS lookup results immediately .setCacheMaxTimeToLive(0) // support DNS based service resolution .setQueryTimeout(1000)); if (metricsOptions != null) { options.setMetricsOptions(metricsOptions); } return Vertx.vertx(options); }