/** * Creates a new instance of the ReadIndexConfig class. * * @param properties The TypedProperties object to read Properties from. */ private ReadIndexConfig(TypedProperties properties) throws ConfigurationException { this.storageReadAlignment = properties.getInt(STORAGE_READ_ALIGNMENT); this.memoryReadMinLength = properties.getInt(MEMORY_READ_MIN_LENGTH); this.storageReadDefaultTimeout = Duration.ofMillis(properties.getInt(STORAGE_READ_DEFAULT_TIMEOUT)); }
/** * Creates a new instance of the RocksDBConfig class. * * @param properties The TypedProperties object to read Properties from. */ private RocksDBConfig(TypedProperties properties) throws ConfigurationException { this.databaseDir = properties.get(DATABASE_DIR); this.writeBufferSizeMB = properties.getInt(WRITE_BUFFER_SIZE_MB); this.readCacheSizeMB = properties.getInt(READ_CACHE_SIZE_MB); this.cacheBlockSizeKB = properties.getInt(CACHE_BLOCK_SIZE_KB); }
this.operationCount = properties.getInt(OPERATION_COUNT); this.warmupCount = (int) (this.operationCount * (properties.getInt(WARMUP_PERCENTAGE) / 100.0)); this.containerCount = properties.getInt(CONTAINER_COUNT); this.streamCount = properties.getInt(STREAM_COUNT); this.segmentsPerStream = properties.getInt(SEGMENTS_PER_STREAM); this.transactionFrequency = properties.getInt(TRANSACTION_FREQUENCY); this.maxTransactionAppendCount = properties.getInt(MAX_TRANSACTION_SIZE); this.producerCount = properties.getInt(PRODUCER_COUNT); this.producerParallelism = properties.getInt(PRODUCER_PARALLELISM); this.minAppendSize = properties.getInt(MIN_APPEND_SIZE); this.maxAppendSize = properties.getInt(MAX_APPEND_SIZE); if (this.minAppendSize < Event.HEADER_LENGTH) { throw new ConfigurationException(String.format("Property '%s' (%s) must be at least %s.", MIN_APPEND_SIZE, this.minAppendSize, MAX_APPEND_SIZE, this.maxAppendSize)); this.threadPoolSize = properties.getInt(THREAD_POOL_SIZE); this.timeout = Duration.ofMillis(properties.getInt(TIMEOUT_MILLIS)); this.bookieCount = properties.getInt(BOOKIE_COUNT); this.controllerCount = properties.getInt(CONTROLLER_COUNT); this.segmentStoreCount = properties.getInt(SEGMENT_STORE_COUNT); this.bkBasePort = properties.getInt(BK_BASE_PORT); this.zkPort = properties.getInt(ZK_PORT); this.controllerHost = properties.get(CONTROLLER_HOST); this.controllerBasePort = properties.getInt(CONTROLLER_BASE_PORT); this.segmentStoreBasePort = properties.getInt(SEGMENT_STORE_BASE_PORT); this.testType = TestType.valueOf(properties.get(TEST_TYPE)); this.readsEnabled = properties.getBoolean(READS_ENABLED);
/** * Creates a new instance of the HDFSStorageConfig class. * * @param properties The TypedProperties object to read Properties from. */ private HDFSStorageConfig(TypedProperties properties) throws ConfigurationException { this.hdfsHostURL = properties.get(URL); this.hdfsRoot = properties.get(ROOT); this.replication = (short) properties.getInt(REPLICATION); this.blockSize = properties.getInt(BLOCK_SIZE); this.replaceDataNodesOnFailure = properties.getBoolean(REPLACE_DATANODES_ON_FAILURE); }
private AutoScalerConfig(TypedProperties properties) throws ConfigurationException { this.internalRequestStream = properties.get(REQUEST_STREAM); this.cooldownDuration = Duration.ofSeconds(properties.getInt(COOLDOWN_IN_SECONDS)); this.muteDuration = Duration.ofSeconds(properties.getInt(MUTE_IN_SECONDS)); this.cacheCleanup = Duration.ofSeconds(properties.getInt(CACHE_CLEANUP_IN_SECONDS)); this.cacheExpiry = Duration.ofSeconds(properties.getInt(CACHE_EXPIRY_IN_SECONDS)); this.controllerUri = URI.create(properties.get(CONTROLLER_URI)); this.tlsEnabled = properties.getBoolean(TLS_ENABLED); this.authEnabled = properties.getBoolean(AUTH_ENABLED); this.tlsCertFile = properties.get(TLS_CERT_FILE); this.tokenSigningKey = properties.get(TOKEN_SIGNING_KEY); this.validateHostName = properties.getBoolean(VALIDATE_HOSTNAME); }
/** * Creates a new instance of the DurableLogConfig class. * * @param properties The TypedProperties object to read Properties from. */ private DurableLogConfig(TypedProperties properties) throws ConfigurationException { this.checkpointMinCommitCount = properties.getInt(CHECKPOINT_MIN_COMMIT_COUNT); this.checkpointCommitCountThreshold = properties.getInt(CHECKPOINT_COMMIT_COUNT); if (this.checkpointMinCommitCount > this.checkpointCommitCountThreshold) { throw new InvalidPropertyValueException(String.format("Property '%s' (%d) cannot be larger than Property '%s' (%d).", CHECKPOINT_MIN_COMMIT_COUNT, this.checkpointMinCommitCount, CHECKPOINT_COMMIT_COUNT, this.checkpointCommitCountThreshold)); } this.checkpointTotalCommitLengthThreshold = properties.getLong(CHECKPOINT_TOTAL_COMMIT_LENGTH); int startRetryDelayMillis = properties.getInt(START_RETRY_DELAY_MILLIS); if (startRetryDelayMillis <= 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer.", START_RETRY_DELAY_MILLIS)); } this.startRetryDelay = Duration.ofMillis(startRetryDelayMillis); }
this.zkSessionTimeout = Duration.ofMillis(properties.getInt(ZK_SESSION_TIMEOUT)); this.zkConnectionTimeout = Duration.ofMillis(properties.getInt(ZK_CONNECTION_TIMEOUT)); this.zkMetadataPath = properties.get(ZK_METADATA_PATH); this.zkHierarchyDepth = properties.getInt(ZK_HIERARCHY_DEPTH); if (this.zkHierarchyDepth < 0) { throw new InvalidPropertyValueException(String.format("Property %s (%d) must be a non-negative integer.", this.maxWriteAttempts = properties.getInt(MAX_WRITE_ATTEMPTS); this.bkLedgerPath = properties.get(BK_LEDGER_PATH); this.bkEnsembleSize = properties.getInt(BK_ENSEMBLE_SIZE); this.bkAckQuorumSize = properties.getInt(BK_ACK_QUORUM_SIZE); this.bkWriteQuorumSize = properties.getInt(BK_WRITE_QUORUM_SIZE); if (this.bkWriteQuorumSize < this.bkAckQuorumSize) { throw new InvalidPropertyValueException(String.format("Property %s (%d) must be greater than or equal to %s (%d).", this.bkWriteTimeoutMillis = properties.getInt(BK_WRITE_TIMEOUT); this.bkReadTimeoutMillis = properties.getInt(BK_READ_TIMEOUT); this.bkLedgerMaxSize = properties.getInt(BK_LEDGER_MAX_SIZE); this.bkPassword = properties.get(BK_PASSWORD).getBytes(Charset.forName("UTF-8")); this.isTLSEnabled = properties.getBoolean(BK_TLS_ENABLED);
/** * Creates a new instance of the AttributeIndexConfig class. * * @param properties The TypedProperties object to read Properties from. */ private AttributeIndexConfig(TypedProperties properties) throws ConfigurationException { int rollingSize = properties.getInt(ATTRIBUTE_SEGMENT_ROLLING_SIZE); if (rollingSize <= 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer; found '%d'.", ATTRIBUTE_SEGMENT_ROLLING_SIZE, rollingSize)); } this.attributeSegmentRollingPolicy = new SegmentRollingPolicy(rollingSize); this.maxIndexPageSize = properties.getInt(MAX_INDEX_PAGE_SIZE); if (this.maxIndexPageSize < MIN_INDEX_PAGE_SIZE_VALUE || this.maxIndexPageSize > MAX_INDEX_PAGE_SIZE_VALUE) { throw new ConfigurationException(String.format("Property '%s' must be at least %s and at most %s; found '%d'.", MAX_INDEX_PAGE_SIZE, MIN_INDEX_PAGE_SIZE_VALUE, MAX_INDEX_PAGE_SIZE_VALUE, this.maxIndexPageSize)); } }
int segmentMetadataExpirationSeconds = properties.getInt(SEGMENT_METADATA_EXPIRATION_SECONDS); if (segmentMetadataExpirationSeconds < MINIMUM_SEGMENT_METADATA_EXPIRATION_SECONDS) { throw new ConfigurationException(String.format("Property '%s' must be at least %s.", int metadataStoreInitSeconds = properties.getInt(METADATA_STORE_INIT_TIMEOUT_SECONDS); if (metadataStoreInitSeconds <= 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer.", this.maxActiveSegmentCount = properties.getInt(MAX_ACTIVE_SEGMENT_COUNT); if (this.maxActiveSegmentCount <= 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer.", MAX_ACTIVE_SEGMENT_COUNT)); this.maxConcurrentSegmentEvictionCount = properties.getInt(MAX_CONCURRENT_SEGMENT_EVICTION_COUNT); if (this.maxConcurrentSegmentEvictionCount <= 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer.", MAX_CONCURRENT_SEGMENT_EVICTION_COUNT)); this.maxCachedExtendedAttributeCount = properties.getInt(MAX_CACHED_EXTENDED_ATTRIBUTE_COUNT); if (this.maxCachedExtendedAttributeCount <= 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer.", MAX_CACHED_EXTENDED_ATTRIBUTE_COUNT));
private SingleNodeConfig(TypedProperties properties) { this.zkPort = properties.getInt(ZK_PORT); this.segmentStorePort = properties.getInt(SEGMENTSTORE_PORT); this.controllerPort = properties.getInt(CONTROLLER_PORT); this.restServerPort = properties.getInt(REST_SERVER_PORT); this.certFile = properties.get(CERT_FILE); this.keyFile = properties.get(KEY_FILE); this.passwdFile = properties.get(PASSWD_FILE); this.userName = properties.get(USER_NAME); this.passwd = properties.get(PASSWD); this.enableRestServer = properties.getBoolean(ENABLE_REST_SERVER); this.enableTls = properties.getBoolean(ENABLE_TLS); this.enableAuth = properties.getBoolean(ENABLE_AUTH); keyStoreJKS = properties.get(KEYSTORE_JKS); keyStoreJKSPassword = properties.get(KEYSTORE_JKS_PASSWORD); }
this.flushThresholdBytes = properties.getInt(FLUSH_THRESHOLD_BYTES); if (this.flushThresholdBytes < 0) { throw new ConfigurationException(String.format("Property '%s' must be a non-negative integer.", FLUSH_THRESHOLD_BYTES)); this.maxFlushSizeBytes = properties.getInt(MAX_FLUSH_SIZE_BYTES); this.maxItemsToReadAtOnce = properties.getInt(MAX_ITEMS_TO_READ_AT_ONCE); if (this.maxItemsToReadAtOnce <= 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer.", MAX_ITEMS_TO_READ_AT_ONCE));
this.containerCount = properties.getInt(CONTAINER_COUNT); this.coreThreadPoolSize = properties.getInt(THREAD_POOL_SIZE); this.storageThreadPoolSize = properties.getInt(STORAGE_THREAD_POOL_SIZE); this.listeningPort = properties.getInt(LISTENING_PORT); publishedPort = properties.getInt(PUBLISHED_PORT); } catch (ConfigurationException e) { publishedPort = this.listeningPort; this.zkRetrySleepMs = properties.getInt(ZK_RETRY_SLEEP_MS); this.zkRetryCount = properties.getInt(ZK_RETRY_COUNT); this.zkSessionTimeoutMs = properties.getInt(ZK_SESSION_TIMEOUT_MS); this.clusterName = properties.get(CLUSTER_NAME); this.dataLogTypeImplementation = properties.getEnum(DATALOG_IMPLEMENTATION, DataLogType.class); this.certFile = properties.get(CERT_FILE); long cachePolicyMaxSize = properties.getLong(CACHE_POLICY_MAX_SIZE); int cachePolicyMaxTime = properties.getInt(CACHE_POLICY_MAX_TIME); int cachePolicyGenerationTime = properties.getInt(CACHE_POLICY_GENERATION_TIME); this.cachePolicy = new CachePolicy(cachePolicyMaxSize, Duration.ofSeconds(cachePolicyMaxTime), Duration.ofSeconds(cachePolicyGenerationTime)); this.replyWithStackTraceOnError = properties.getBoolean(REPLY_WITH_STACK_TRACE_ON_ERROR);
/** * Creates a new instance of the MetricsConfig class. * * @param properties The TypedProperties object to read Properties from. */ private MetricsConfig(TypedProperties properties) throws ConfigurationException { this.enableStatistics = properties.getBoolean(ENABLE_STATISTICS); this.dynamicCacheSize = properties.getLong(DYNAMIC_CACHE_SIZE); this.dynamicCacheEvictionDurationMinutes = Duration.ofMinutes(properties.getInt(DYNAMIC_CACHE_EVICTION_DURATION_MINUTES)); this.statsOutputFrequencySeconds = Duration.ofSeconds(properties.getInt(OUTPUT_FREQUENCY)); this.metricsPrefix = properties.get(METRICS_PREFIX); this.csvEndpoint = properties.get(CSV_ENDPOINT); this.statsDHost = properties.get(STATSD_HOST); this.statsDPort = properties.getInt(STATSD_PORT); this.graphiteHost = properties.get(GRAPHITE_HOST); this.graphitePort = properties.getInt(GRAPHITE_PORT); this.jmxDomain = properties.get(JMX_DOMAIN); this.gangliaHost = properties.get(GANGLIA_HOST); this.gangliaPort = properties.getInt(GANGLIA_PORT); this.enableCSVReporter = properties.getBoolean(ENABLE_CSV_REPORTER); this.enableStatsdReporter = properties.getBoolean(ENABLE_STATSD_REPORTER); this.enableGraphiteReporter = properties.getBoolean(ENABLE_GRAPHITE_REPORTER); this.enableJMXReporter = properties.getBoolean(ENABLE_JMX_REPORTER); this.enableGangliaReporter = properties.getBoolean(ENABLE_GANGLIA_REPORTER); this.enableConsoleReporter = properties.getBoolean(ENABLE_CONSOLE_REPORTER); }
for (int i = 0; i < propertyCount; i++) { val p = Property.<Integer>named(Integer.toString(i)); val actual1 = c1.getProperties().getInt(p); val actual2 = c2.getProperties().getInt(p); val actualProp2 = p2.getProperty(namespace + "." + Integer.toString(i)); Assert.assertEquals("Rebased instance modified the original builder.", i, actual1);
/** * Tests the with() method. */ @Test public void testWith() { final String namespace = "ns"; final int propertyCount = 10; val builder = new ConfigBuilder<TestConfig>(namespace, TestConfig::new); for (int i = 0; i < propertyCount; i++) { val result = builder.with(Property.named(Integer.toString(i)), i); Assert.assertEquals("with() did not return this instance.", builder, result); } TestConfig c = builder.build(); for (int i = 0; i < propertyCount; i++) { val p = Property.<Integer>named(Integer.toString(i)); val actual = c.getProperties().getInt(p); Assert.assertEquals("Unexpected value in result.", i, actual); } }