private ClusterManager getClusterManager(VertxOptions options) { ClusterManager mgr = options.getClusterManager(); if (mgr == null) { String clusterManagerClassName = System.getProperty("vertx.cluster.managerClass"); if (clusterManagerClassName != null) { // We allow specify a sys prop for the cluster manager factory which overrides ServiceLoader try { Class<?> clazz = Class.forName(clusterManagerClassName); mgr = (ClusterManager) clazz.newInstance(); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate " + clusterManagerClassName, e); } } else { mgr = ServiceHelper.loadFactoryOrNull(ClusterManager.class); if (mgr == null) { throw new IllegalStateException("No ClusterManagerFactory instances found on classpath"); } } } return mgr; }
/** * 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("localhost", options.getClusterHost()); assertNull(options.getClusterPublicHost()); assertEquals(null, options.getClusterManager()); assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime()); assertEquals(1l * 60 * 1000 * 1000000, options.getMaxWorkerExecuteTime()); assertEquals(blockedThreadCheckInterval, options.getBlockedThreadCheckInterval()); assertEquals(clusterHost, options.getClusterHost()); assertEquals(null, options.getClusterManager()); assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime()); assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
private ClusterManager getClusterManager(VertxOptions options) { ClusterManager mgr = options.getClusterManager(); if (mgr == null) { String clusterManagerClassName = System.getProperty("vertx.cluster.managerClass"); if (clusterManagerClassName != null) { // We allow specify a sys prop for the cluster manager factory which overrides ServiceLoader try { Class<?> clazz = Class.forName(clusterManagerClassName); mgr = (ClusterManager) clazz.newInstance(); } catch (Exception e) { throw new IllegalStateException("Failed to instantiate " + clusterManagerClassName, e); } } else { mgr = ServiceHelper.loadFactoryOrNull(ClusterManager.class); if (mgr == null) { throw new IllegalStateException("No ClusterManagerFactory instances found on classpath"); } } } return mgr; }
assertNull(options.getClusterManager()); assertEquals(options, options.setClusterManager(mgr)); assertSame(mgr, options.getClusterManager()); assertFalse(options.isHAEnabled()); assertEquals(options, options.setHAEnabled(true));
/** * 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("localhost", options.getClusterHost()); assertNull(options.getClusterPublicHost()); assertEquals(null, options.getClusterManager()); assertEquals(2000l * 1000000, options.getMaxEventLoopExecuteTime()); assertEquals(1l * 60 * 1000 * 1000000, options.getMaxWorkerExecuteTime()); assertEquals(blockedThreadCheckInterval, options.getBlockedThreadCheckInterval()); assertEquals(clusterHost, options.getClusterHost()); assertEquals(null, options.getClusterManager()); assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime()); assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
assertNull(options.getClusterManager()); assertEquals(options, options.setClusterManager(mgr)); assertSame(mgr, options.getClusterManager()); assertFalse(options.isHAEnabled()); assertEquals(options, options.setHAEnabled(true));