io.vertx.core.VertxOptions.getMetricsOptions()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(15.6k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中io.vertx.core.VertxOptions.getMetricsOptions()方法的一些代码示例,展示了VertxOptions.getMetricsOptions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。VertxOptions.getMetricsOptions()方法的具体详情如下:
包路径:io.vertx.core.VertxOptions
类名称:VertxOptions
方法名:getMetricsOptions

VertxOptions.getMetricsOptions介绍

暂无

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

private VertxMetrics initialiseMetrics(VertxOptions options) {
 if (options.getMetricsOptions() != null && options.getMetricsOptions().isEnabled()) {
  VertxMetricsFactory factory = options.getMetricsOptions().getFactory();
  if (factory == null) {
   factory = ServiceHelper.loadFactoryOrNull(VertxMetricsFactory.class);
   if (factory == null) {
    log.warn("Metrics has been set to enabled but no VertxMetricsFactory found on classpath");
   }
  }
  if (factory != null) {
   VertxMetrics metrics = factory.metrics(options);
   Objects.requireNonNull(metrics, "The metric instance created from " + factory + " cannot be null");
   return metrics;
  }
 }
 return null;
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testCustomMetricsOptions() throws Exception {
 System.setProperty(RunCommand.METRICS_OPTIONS_PROP_PREFIX + "enabled", "true");
 System.setProperty(RunCommand.METRICS_OPTIONS_PROP_PREFIX + "customProperty", "customPropertyValue");
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
 Thread.currentThread().setContextClassLoader(MetricsOptionsTest.createMetricsFromMetaInfLoader("io.vertx.core.CustomMetricsFactory"));
 try {
  launcher.dispatch(args);
 } finally {
  Thread.currentThread().setContextClassLoader(oldCL);
 }
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 CustomMetricsOptions custom = (CustomMetricsOptions) opts.getMetricsOptions();
 assertEquals("customPropertyValue", custom.getCustomProperty());
}

代码示例来源:origin: eclipse-vertx/vert.x

json.put("maxWorkerExecuteTimeUnit", obj.getMaxWorkerExecuteTimeUnit().name());
if (obj.getMetricsOptions() != null) {
 json.put("metricsOptions", obj.getMetricsOptions().toJson());

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testCustomMetricsOptions() throws Exception {
 System.setProperty(Starter.METRICS_OPTIONS_PROP_PREFIX + "enabled", "true");
 System.setProperty(Starter.METRICS_OPTIONS_PROP_PREFIX + "customProperty", "customPropertyValue");
 MyStarter starter = new MyStarter();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
 Thread.currentThread().setContextClassLoader(MetricsOptionsTest.createMetricsFromMetaInfLoader("io.vertx.core.CustomMetricsFactory"));
 try {
  starter.run(args);
 } finally {
  Thread.currentThread().setContextClassLoader(oldCL);
 }
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = starter.getVertxOptions();
 CustomMetricsOptions custom = (CustomMetricsOptions) opts.getMetricsOptions();
 assertEquals("customPropertyValue", custom.getCustomProperty());
 cleanup(starter);
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testConfigureFromSystemPropertiesInvalidPropertyName() throws Exception {
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "nosuchproperty", "123");
 // Should be ignored
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 VertxOptions def = new VertxOptions();
 if (opts.getMetricsOptions().isEnabled()) {
  def.getMetricsOptions().setEnabled(true);
 }
 assertEquals(def, opts);
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testConfigureFromSystemPropertiesInvalidPropertyType() throws Exception {
 // One for each type that we support
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "eventLoopPoolSize", "sausages");
 // Should be ignored
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 VertxOptions def = new VertxOptions();
 if (opts.getMetricsOptions().isEnabled()) {
  def.getMetricsOptions().setEnabled(true);
 }
 assertEquals(def, opts);
}

代码示例来源:origin: eclipse-vertx/vert.x

private void testCustomMetricsOptionsFromJson(boolean jsonFile) throws Exception {
 JsonObject json = new JsonObject()
  .put("metricsOptions", new JsonObject()
   .put("enabled", true)
   .put("customProperty", "customPropertyValue")
   .put("nestedOptions", new JsonObject().put("nestedProperty", "nestedValue")));
 String optionsArg;
 if (jsonFile) {
  File file = testFolder.newFile();
  Files.write(file.toPath(), json.toBuffer().getBytes());
  optionsArg = file.getPath();
 } else {
  optionsArg = json.toString();
 }
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName(), "-options", optionsArg};
 ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
 Thread.currentThread().setContextClassLoader(MetricsOptionsTest.createMetricsFromMetaInfLoader("io.vertx.core.CustomMetricsFactory"));
 try {
  launcher.dispatch(args);
 } finally {
  Thread.currentThread().setContextClassLoader(oldCL);
 }
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 CustomMetricsOptions custom = (CustomMetricsOptions) opts.getMetricsOptions();
 assertEquals("customPropertyValue", custom.getCustomProperty());
 assertEquals("nestedValue", custom.getNestedOptions().getNestedProperty());
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testConfigureFromSystemPropertiesInvalidPropertyName() throws Exception {
 System.setProperty(Starter.VERTX_OPTIONS_PROP_PREFIX + "nosuchproperty", "123");
 // Should be ignored
 MyStarter starter = new MyStarter();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 starter.run(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = starter.getVertxOptions();
 VertxOptions def = new VertxOptions();
 if (opts.getMetricsOptions().isEnabled()) {
  def.getMetricsOptions().setEnabled(true);
 }
 assertEquals(def, opts);
 cleanup(starter);
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testConfigureFromSystemPropertiesInvalidPropertyType() throws Exception {
 // One for each type that we support
 System.setProperty(Starter.VERTX_OPTIONS_PROP_PREFIX + "eventLoopPoolSize", "sausages");
 // Should be ignored
 MyStarter starter = new MyStarter();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 starter.run(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = starter.getVertxOptions();
 VertxOptions def = new VertxOptions();
 if (opts.getMetricsOptions().isEnabled()) {
  def.getMetricsOptions().setEnabled(true);
 }
 assertEquals(def, opts);
 cleanup(starter);
}

代码示例来源:origin: eclipse-vertx/vert.x

private void testConfigureFromJson(boolean jsonFile) throws Exception {
 JsonObject json = new JsonObject()
  .put("eventLoopPoolSize", 123)
  .put("maxEventLoopExecuteTime", 123767667)
  .put("metricsOptions", new JsonObject().put("enabled", true))
  .put("eventBusOptions", new JsonObject().put("clustered", true).put("clusterPublicHost", "mars"))
  .put("haGroup", "somegroup")
  .put("maxEventLoopExecuteTimeUnit", "SECONDS");
 String optionsArg;
 if (jsonFile) {
  File file = testFolder.newFile();
  Files.write(file.toPath(), json.toBuffer().getBytes());
  optionsArg = file.getPath();
 } else {
  optionsArg = json.toString();
 }
 MyLauncher launcher = new MyLauncher();
 String[] args = new String[]{"run", "java:" + TestVerticle.class.getCanonicalName(), "-options", optionsArg};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 assertEquals(123, opts.getEventLoopPoolSize(), 0);
 assertEquals(123767667L, opts.getMaxEventLoopExecuteTime());
 assertEquals(true, opts.getMetricsOptions().isEnabled());
 assertEquals(true, opts.isClustered());
 assertEquals("mars", opts.getClusterPublicHost());
 assertEquals("somegroup", opts.getHAGroup());
 assertEquals(TimeUnit.SECONDS, opts.getMaxEventLoopExecuteTimeUnit());
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * Copy constructor
 *
 * @param other The other {@code VertxOptions} to copy when creating this
 */
public VertxOptions(VertxOptions other) {
 this.eventLoopPoolSize = other.getEventLoopPoolSize();
 this.workerPoolSize = other.getWorkerPoolSize();
 this.blockedThreadCheckInterval = other.getBlockedThreadCheckInterval();
 this.maxEventLoopExecuteTime = other.getMaxEventLoopExecuteTime();
 this.maxWorkerExecuteTime = other.getMaxWorkerExecuteTime();
 this.internalBlockingPoolSize = other.getInternalBlockingPoolSize();
 this.clusterManager = other.getClusterManager();
 this.haEnabled = other.isHAEnabled();
 this.quorumSize = other.getQuorumSize();
 this.haGroup = other.getHAGroup();
 this.metricsOptions = other.getMetricsOptions() != null ? new MetricsOptions(other.getMetricsOptions()) : null;
 this.fileSystemOptions = other.getFileSystemOptions() != null ? new FileSystemOptions(other.getFileSystemOptions()) : null;
 this.warningExceptionTime = other.warningExceptionTime;
 this.eventBusOptions = new EventBusOptions(other.eventBusOptions);
 this.addressResolverOptions = other.addressResolverOptions != null ? new AddressResolverOptions() : null;
 this.maxEventLoopExecuteTimeUnit = other.maxEventLoopExecuteTimeUnit;
 this.maxWorkerExecuteTimeUnit = other.maxWorkerExecuteTimeUnit;
 this.warningExceptionTimeUnit = other.warningExceptionTimeUnit;
 this.blockedThreadCheckIntervalUnit = other.blockedThreadCheckIntervalUnit;
}

代码示例来源:origin: eclipse-vertx/vert.x

private void testConfigureFromSystemProperties(boolean clustered) throws Exception {
 // One for each type that we support
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "eventLoopPoolSize", "123");
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "maxEventLoopExecuteTime", "123767667");
 System.setProperty(RunCommand.METRICS_OPTIONS_PROP_PREFIX + "enabled", "true");
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "haGroup", "somegroup");
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "maxEventLoopExecuteTimeUnit", "SECONDS");
 MyLauncher launcher = new MyLauncher();
 String[] args;
 if (clustered) {
  args = new String[]{"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster"};
 } else {
  args = new String[]{"run", "java:" + TestVerticle.class.getCanonicalName()};
 }
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 assertEquals(123, opts.getEventLoopPoolSize(), 0);
 assertEquals(123767667L, opts.getMaxEventLoopExecuteTime());
 assertEquals(true, opts.getMetricsOptions().isEnabled());
 assertEquals("somegroup", opts.getHAGroup());
 assertEquals(TimeUnit.SECONDS, opts.getMaxEventLoopExecuteTimeUnit());
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testMetricsEnabledFromCommandLine() throws IOException {
 setManifest("MANIFEST-Launcher-Http-Verticle.MF");
 cli.dispatch(new Launcher(), new String[] {"-Dvertx.metrics.options.enabled=true"});
 assertWaitUntil(() -> {
  try {
   return getHttpCode() == 200;
  } catch (IOException e) {
   return false;
  }
 });
 // Check that the metrics are enabled
 // We cannot use the response from the verticle as it uses the DymmyVertxMetrics (no metrics provider)
 assertThat(((RunCommand)cli.getExistingCommandInstance("run")).options.getMetricsOptions().isEnabled()).isTrue();
}

代码示例来源:origin: eclipse-vertx/vert.x

private void testConfigureFromSystemProperties(boolean clustered) throws Exception {
 // One for each type that we support
 System.setProperty(Starter.VERTX_OPTIONS_PROP_PREFIX + "eventLoopPoolSize", "123");
 System.setProperty(Starter.VERTX_OPTIONS_PROP_PREFIX + "maxEventLoopExecuteTime", "123767667");
 System.setProperty(Starter.METRICS_OPTIONS_PROP_PREFIX + "enabled", "true");
 System.setProperty(Starter.VERTX_OPTIONS_PROP_PREFIX + "haGroup", "somegroup");
 System.setProperty(Starter.VERTX_OPTIONS_PROP_PREFIX + "maxEventLoopExecuteTimeUnit", "SECONDS");
 MyStarter starter = new MyStarter();
 String[] args;
 if (clustered) {
  args = new String[] {"run", "java:" + TestVerticle.class.getCanonicalName(), "-cluster"};
 } else {
  args = new String[] {"run", "java:" + TestVerticle.class.getCanonicalName()};
 }
 starter.run(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = starter.getVertxOptions();
 assertEquals(123, opts.getEventLoopPoolSize(), 0);
 assertEquals(123767667L, opts.getMaxEventLoopExecuteTime());
 assertEquals(true, opts.getMetricsOptions().isEnabled());
 assertEquals("somegroup", opts.getHAGroup());
 assertEquals(TimeUnit.SECONDS, opts.getMaxEventLoopExecuteTimeUnit());
 cleanup(starter);
}

代码示例来源:origin: eclipse-vertx/vert.x

assertEquals(1, options.getQuorumSize());
assertEquals(VertxOptions.DEFAULT_HA_GROUP, options.getHAGroup());
assertNotNull(options.getMetricsOptions());
assertEquals(5000000000l, options.getWarningExceptionTime());
assertEquals(TimeUnit.NANOSECONDS, options.getMaxEventLoopExecuteTimeUnit());
assertEquals(classPathResolvingEnabled, fileSystemOptions.isClassPathResolvingEnabled());
assertEquals(fileResolverCachingEnabled, fileSystemOptions.isFileCachingEnabled());
MetricsOptions metricsOptions = options.getMetricsOptions();
assertEquals(metricsEnabled, metricsOptions.isEnabled());
assertEquals(warningExceptionTime, options.getWarningExceptionTime());

代码示例来源:origin: apache/servicecomb-java-chassis

public DefaultVertxMetrics(Vertx vertx, VertxOptions vertxOptions) {
 this.vertx = vertx;
 this.vertxOptions = vertxOptions;
 this.clientEndpointMetricManager = new DefaultClientEndpointMetricManager(vertx,
   (MetricsOptionsEx) vertxOptions.getMetricsOptions());
}

代码示例来源:origin: eclipse-vertx/vert.x

assertEquals(quorumSize, options.getQuorumSize());
assertEquals(haGroup, options.getHAGroup());
MetricsOptions metricsOptions = options.getMetricsOptions();
assertNotNull(metricsOptions);
assertEquals(metricsEnabled, metricsOptions.isEnabled());

代码示例来源:origin: io.vertx/vertx-core

@Test
public void testConfigureFromSystemPropertiesInvalidPropertyName() throws Exception {
 System.setProperty(RunCommand.VERTX_OPTIONS_PROP_PREFIX + "nosuchproperty", "123");
 // Should be ignored
 MyLauncher launcher = new MyLauncher();
 String[] args = {"run", "java:" + TestVerticle.class.getCanonicalName()};
 launcher.dispatch(args);
 assertWaitUntil(() -> TestVerticle.instanceCount.get() == 1);
 VertxOptions opts = launcher.getVertxOptions();
 VertxOptions def = new VertxOptions();
 if (opts.getMetricsOptions().isEnabled()) {
  def.getMetricsOptions().setEnabled(true);
 }
 assertEquals(def, opts);
}

代码示例来源:origin: io.vertx/vertx-core

@Test
public void testMetricsEnabledFromCommandLine() throws IOException {
 setManifest("MANIFEST-Launcher-Http-Verticle.MF");
 cli.dispatch(new Launcher(), new String[] {"-Dvertx.metrics.options.enabled=true"});
 assertWaitUntil(() -> {
  try {
   return getHttpCode() == 200;
  } catch (IOException e) {
   return false;
  }
 });
 // Check that the metrics are enabled
 // We cannot use the response from the verticle as it uses the DymmyVertxMetrics (no metrics provider)
 assertThat(((RunCommand)cli.getExistingCommandInstance("run")).options.getMetricsOptions().isEnabled()).isTrue();
}

代码示例来源:origin: eclipse-vertx/vert.x

assertNotNull(options.getMetricsOptions());

相关文章

VertxOptions类方法