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

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

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

VertxOptions.getMaxEventLoopExecuteTime介绍

[英]Get the value of max event loop execute time, in VertxOptions#setMaxEventLoopExecuteTimeUnit.

Vert.x will automatically log a warning if it detects that event loop threads haven't returned within this time.

This can be used to detect where the user is blocking an event loop thread, contrary to the Golden Rule of the holy Event Loop.

The default value of VertxOptions#setMaxEventLoopExecuteTimeUnit is TimeUnit#NANOSECONDS
[中]获取最大事件循环执行时间的值,单位为VertxOptions#setMaxEventLoopExecuteTimeUnit。
维特。如果x检测到事件循环线程在此时间内没有返回,它将自动记录警告。
这可以用来检测用户在哪里阻止事件循环线程,这与神圣事件循环的黄金法则相反。
VertxOptions#setMaxEventLoopExecuteTimeUnit的默认值为时间单位#纳秒

代码示例

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

json.put("maxEventLoopExecuteTime", obj.getMaxEventLoopExecuteTime());
if (obj.getMaxEventLoopExecuteTimeUnit() != null) {
 json.put("maxEventLoopExecuteTimeUnit", obj.getMaxEventLoopExecuteTimeUnit().name());

代码示例来源: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: io.vertx/vertx-core

/**
 * 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(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

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

eventLoopThreadFactory = new VertxThreadFactory("vert.x-eventloop-thread-", checker, false, options.getMaxEventLoopExecuteTime(), options.getMaxEventLoopExecuteTimeUnit());
eventLoopGroup = transport.eventLoopGroup(options.getEventLoopPoolSize(), eventLoopThreadFactory, NETTY_IO_RATIO);
ThreadFactory acceptorEventLoopThreadFactory = new VertxThreadFactory("vert.x-acceptor-thread-", checker, false, options.getMaxEventLoopExecuteTime(), options.getMaxEventLoopExecuteTimeUnit());

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

assertNull(options.getClusterPublicHost());
assertEquals(null, options.getClusterManager());
assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime());
assertEquals(1l * 60 * 1000 * 1000000, options.getMaxWorkerExecuteTime());
assertFalse(options.isHAEnabled());
assertEquals(clusterHost, options.getClusterHost());
assertEquals(null, options.getClusterManager());
assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
assertEquals(haEnabled, options.isHAEnabled());

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

@Test
public void testDefaultJsonOptions() {
 VertxOptions def = new VertxOptions();
 VertxOptions json = new VertxOptions(new JsonObject());
 assertEquals(def.getEventLoopPoolSize(), json.getEventLoopPoolSize());
 assertEquals(def.getWorkerPoolSize(), json.getWorkerPoolSize());
 assertEquals(def.isClustered(), json.isClustered());
 assertEquals(def.getClusterHost(), json.getClusterHost());
 assertEquals(def.getClusterPublicHost(), json.getClusterPublicHost());
 assertEquals(def.getClusterPublicPort(), json.getClusterPublicPort());
 assertEquals(def.getClusterPingInterval(), json.getClusterPingInterval());
 assertEquals(def.getClusterPingReplyInterval(), json.getClusterPingReplyInterval());
 assertEquals(def.getBlockedThreadCheckInterval(), json.getBlockedThreadCheckInterval());
 assertEquals(def.getMaxEventLoopExecuteTime(), json.getMaxEventLoopExecuteTime());
 assertEquals(def.getMaxWorkerExecuteTime(), json.getMaxWorkerExecuteTime());
 assertEquals(def.getInternalBlockingPoolSize(), json.getInternalBlockingPoolSize());
 assertEquals(def.isHAEnabled(), json.isHAEnabled());
 assertEquals(def.getQuorumSize(), json.getQuorumSize());
 assertEquals(def.getHAGroup(), json.getHAGroup());
 assertEquals(def.getWarningExceptionTime(), json.getWarningExceptionTime());
 assertEquals(def.isFileResolverCachingEnabled(), json.isFileResolverCachingEnabled());
 assertEquals(def.getMaxEventLoopExecuteTimeUnit(), json.getMaxEventLoopExecuteTimeUnit());
 assertEquals(def.getMaxWorkerExecuteTimeUnit(), json.getMaxWorkerExecuteTimeUnit());
 assertEquals(def.getWarningExceptionTimeUnit(), json.getWarningExceptionTimeUnit());
 assertEquals(def.getBlockedThreadCheckIntervalUnit(), json.getBlockedThreadCheckIntervalUnit());
}

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

assertEquals(clusterHost, options.getClusterHost());
assertEquals(clusterPublicHost, options.getClusterPublicHost());
assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
assertEquals(haEnabled, options.isHAEnabled());

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

json.put("maxEventLoopExecuteTime", obj.getMaxEventLoopExecuteTime());
if (obj.getMaxEventLoopExecuteTimeUnit() != null) {
 json.put("maxEventLoopExecuteTimeUnit", obj.getMaxEventLoopExecuteTimeUnit().name());

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

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: io.vertx/vertx-core

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: io.vertx/vertx-core

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: io.vertx/vertx-core

eventLoopThreadFactory = new VertxThreadFactory("vert.x-eventloop-thread-", checker, false, options.getMaxEventLoopExecuteTime(), options.getMaxEventLoopExecuteTimeUnit());
eventLoopGroup = transport.eventLoopGroup(options.getEventLoopPoolSize(), eventLoopThreadFactory, NETTY_IO_RATIO);
ThreadFactory acceptorEventLoopThreadFactory = new VertxThreadFactory("vert.x-acceptor-thread-", checker, false, options.getMaxEventLoopExecuteTime(), options.getMaxEventLoopExecuteTimeUnit());

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

assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime()); // 2 seconds in nano seconds
rand = TestUtils.randomPositiveInt();
assertEquals(options, options.setMaxEventLoopExecuteTime(rand));
assertEquals(rand, options.getMaxEventLoopExecuteTime());
try {
 options.setMaxEventLoopExecuteTime(0);

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

assertNull(options.getClusterPublicHost());
assertEquals(null, options.getClusterManager());
assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime());
assertEquals(1l * 60 * 1000 * 1000000, options.getMaxWorkerExecuteTime());
assertFalse(options.isHAEnabled());
assertEquals(clusterHost, options.getClusterHost());
assertEquals(null, options.getClusterManager());
assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
assertEquals(haEnabled, options.isHAEnabled());

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

@Test
public void testDefaultJsonOptions() {
 VertxOptions def = new VertxOptions();
 VertxOptions json = new VertxOptions(new JsonObject());
 assertEquals(def.getEventLoopPoolSize(), json.getEventLoopPoolSize());
 assertEquals(def.getWorkerPoolSize(), json.getWorkerPoolSize());
 assertEquals(def.isClustered(), json.isClustered());
 assertEquals(def.getClusterHost(), json.getClusterHost());
 assertEquals(def.getClusterPublicHost(), json.getClusterPublicHost());
 assertEquals(def.getClusterPublicPort(), json.getClusterPublicPort());
 assertEquals(def.getClusterPingInterval(), json.getClusterPingInterval());
 assertEquals(def.getClusterPingReplyInterval(), json.getClusterPingReplyInterval());
 assertEquals(def.getBlockedThreadCheckInterval(), json.getBlockedThreadCheckInterval());
 assertEquals(def.getMaxEventLoopExecuteTime(), json.getMaxEventLoopExecuteTime());
 assertEquals(def.getMaxWorkerExecuteTime(), json.getMaxWorkerExecuteTime());
 assertEquals(def.getInternalBlockingPoolSize(), json.getInternalBlockingPoolSize());
 assertEquals(def.isHAEnabled(), json.isHAEnabled());
 assertEquals(def.getQuorumSize(), json.getQuorumSize());
 assertEquals(def.getHAGroup(), json.getHAGroup());
 assertEquals(def.getWarningExceptionTime(), json.getWarningExceptionTime());
 assertEquals(def.isFileResolverCachingEnabled(), json.isFileResolverCachingEnabled());
 assertEquals(def.getMaxEventLoopExecuteTimeUnit(), json.getMaxEventLoopExecuteTimeUnit());
 assertEquals(def.getMaxWorkerExecuteTimeUnit(), json.getMaxWorkerExecuteTimeUnit());
 assertEquals(def.getWarningExceptionTimeUnit(), json.getWarningExceptionTimeUnit());
 assertEquals(def.getBlockedThreadCheckIntervalUnit(), json.getBlockedThreadCheckIntervalUnit());
}

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

assertEquals(clusterHost, options.getClusterHost());
assertEquals(clusterPublicHost, options.getClusterPublicHost());
assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
assertEquals(haEnabled, options.isHAEnabled());

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

assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime()); // 2 seconds in nano seconds
rand = TestUtils.randomPositiveInt();
assertEquals(options, options.setMaxEventLoopExecuteTime(rand));
assertEquals(rand, options.getMaxEventLoopExecuteTime());
try {
 options.setMaxEventLoopExecuteTime(0);

相关文章

VertxOptions类方法