json.put("eventBusOptions", obj.getEventBusOptions().toJson()); json.put("eventLoopPoolSize", obj.getEventLoopPoolSize()); json.put("fileResolverCachingEnabled", obj.isFileResolverCachingEnabled()); if (obj.getFileSystemOptions() != null) {
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()); }
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()); }
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); }
/** * 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; }
assertEquals(20000, options.getClusterPingInterval()); assertEquals(20000, options.getClusterPingReplyInterval()); assertEquals(2 * Runtime.getRuntime().availableProcessors(), options.getEventLoopPoolSize()); assertEquals(20, options.getInternalBlockingPoolSize()); assertEquals(20, options.getWorkerPoolSize()); assertEquals(clusterPingInterval, options.getClusterPingInterval()); assertEquals(clusterPingReplyInterval, options.getClusterPingReplyInterval()); assertEquals(eventLoopPoolSize, options.getEventLoopPoolSize()); assertEquals(internalBlockingPoolSize, options.getInternalBlockingPoolSize()); assertEquals(workerPoolSize, options.getWorkerPoolSize());
checker = new BlockedThreadChecker(options.getBlockedThreadCheckInterval(), options.getBlockedThreadCheckIntervalUnit(), options.getWarningExceptionTime(), options.getWarningExceptionTimeUnit()); 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());
.setInstances(vertxOptions.getEventLoopPoolSize()) .setConfig(new JsonObject().put("helper", key)); vertx.deployVerticle(Verticle.class.getName(), deploymentOptions, ar -> {
@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()); }
assertEquals(clusterPingInterval, options.getClusterPingInterval()); assertEquals(clusterPingReplyInterval, options.getClusterPingReplyInterval()); assertEquals(eventLoopPoolSize, options.getEventLoopPoolSize()); assertEquals(internalBlockingPoolSize, options.getInternalBlockingPoolSize()); assertEquals(workerPoolSize, options.getWorkerPoolSize());
json.put("eventBusOptions", obj.getEventBusOptions().toJson()); json.put("eventLoopPoolSize", obj.getEventLoopPoolSize()); json.put("fileResolverCachingEnabled", obj.isFileResolverCachingEnabled()); if (obj.getFileSystemOptions() != null) {
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()); }
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()); }
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); }
@Test public void testOptions() { VertxOptions options = new VertxOptions(); assertEquals(2 * Runtime.getRuntime().availableProcessors(), options.getEventLoopPoolSize()); int rand = TestUtils.randomPositiveInt(); assertEquals(options, options.setEventLoopPoolSize(rand)); assertEquals(rand, options.getEventLoopPoolSize()); try { options.setEventLoopPoolSize(0);
/** * 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; }
assertEquals(20000, options.getClusterPingInterval()); assertEquals(20000, options.getClusterPingReplyInterval()); assertEquals(2 * Runtime.getRuntime().availableProcessors(), options.getEventLoopPoolSize()); assertEquals(20, options.getInternalBlockingPoolSize()); assertEquals(20, options.getWorkerPoolSize()); assertEquals(clusterPingInterval, options.getClusterPingInterval()); assertEquals(clusterPingReplyInterval, options.getClusterPingReplyInterval()); assertEquals(eventLoopPoolSize, options.getEventLoopPoolSize()); assertEquals(internalBlockingPoolSize, options.getInternalBlockingPoolSize()); assertEquals(workerPoolSize, options.getWorkerPoolSize());
checker = new BlockedThreadChecker(options.getBlockedThreadCheckInterval(), options.getBlockedThreadCheckIntervalUnit(), options.getWarningExceptionTime(), options.getWarningExceptionTimeUnit()); 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());
@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()); }
assertEquals(clusterPingInterval, options.getClusterPingInterval()); assertEquals(clusterPingReplyInterval, options.getClusterPingReplyInterval()); assertEquals(eventLoopPoolSize, options.getEventLoopPoolSize()); assertEquals(internalBlockingPoolSize, options.getInternalBlockingPoolSize()); assertEquals(workerPoolSize, options.getWorkerPoolSize());