/** * 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); }
/** * 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); }
/** * 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); }
/** * Creates a new instance of the ExtendedS3StorageConfig class. * * @param properties The TypedProperties object to read Properties from. */ private ExtendedS3StorageConfig(TypedProperties properties) throws ConfigurationException { this.root = properties.get(ROOT); this.accessKey = properties.get(ACCESS_KEY_ID); this.secretKey = properties.get(SECRET_KEY); this.url = java.net.URI.create(properties.get(URI)); this.bucket = properties.get(BUCKET); this.namespace = properties.get(NAMESPACE); this.useNoneMatch = properties.getBoolean(USENONEMATCH); }
/** * 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 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); }
private <T> void testData(Properties props, ExtractorFunction<T> methodToTest, Predicate<String> valueValidator) throws Exception { for (int componentId = 0; componentId < TypedPropertiesTests.COMPONENT_COUNT; componentId++) { String componentCode = getComponentCode(componentId); TypedProperties config = new TypedProperties(props, componentCode); for (String fullyQualifiedPropertyName : props.stringPropertyNames()) { int propertyId = getPropertyId(fullyQualifiedPropertyName); if (fullyQualifiedPropertyName.startsWith(componentCode)) { if (valueValidator.test(config.get(stringProperty))) {
/** * Creates a new instance of the FileSystemStorageConfig class. * * @param properties The TypedProperties object to read Properties from. */ private FileSystemStorageConfig(TypedProperties properties) throws ConfigurationException { this.root = properties.get(ROOT); }
/** * Creates a new instance of the given Configuration class as defined by this builder with the information * contained herein. * * @return The newly created instance. * @throws ConfigurationException When a configuration issue has been detected. This can be: * MissingPropertyException (a required Property is missing from the given properties collection), * NumberFormatException (a Property has a value that is invalid for it). * @throws NullPointerException If any of the arguments are null. * @throws IllegalArgumentException If namespace is an empty string.. */ public T build() throws ConfigurationException { return this.constructor.apply(new TypedProperties(this.properties, this.namespace)); }
/** * Tests the ability to get a property as an Enum. */ @Test public void testGetEnum() throws Exception { Properties props = new Properties(); populateData(props); testData(props, (TypedProperties config, Property<TestEnum> property) -> config.getEnum(property, TestEnum.class), TypedPropertiesTests::isEnum); }
/** * 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)); } }
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.flushThresholdTime = Duration.ofMillis(properties.getLong(FLUSH_THRESHOLD_MILLIS)); 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)); long minReadTimeoutMillis = properties.getLong(MIN_READ_TIMEOUT_MILLIS); long maxReadTimeoutMillis = properties.getLong(MAX_READ_TIMEOUT_MILLIS); if (minReadTimeoutMillis < 0) { throw new ConfigurationException(String.format("Property '%s' must be a positive integer.", MIN_READ_TIMEOUT_MILLIS)); this.errorSleepDuration = Duration.ofMillis(properties.getLong(ERROR_SLEEP_MILLIS)); this.flushTimeout = Duration.ofMillis(properties.getLong(FLUSH_TIMEOUT_MILLIS)); this.ackTimeout = Duration.ofMillis(properties.getLong(ACK_TIMEOUT_MILLIS)); this.shutdownTimeout = Duration.ofMillis(properties.getLong(SHUTDOWN_TIMEOUT_MILLIS));
TestContainerConfig() throws ConfigurationException { super(new TypedProperties(new Properties(), "ns")); } }
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); }
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; String ipAddress = properties.get(LISTENING_IP_ADDRESS); if (ipAddress == null || ipAddress.equals(LISTENING_IP_ADDRESS.getDefaultValue())) { String publishedIPAddress = properties.get(PUBLISHED_IP_ADDRESS); if (Strings.isNullOrEmpty(publishedIPAddress)) { this.publishedIPAddress = this.listeningIPAddress; this.zkURL = properties.get(ZK_URL); 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.storageImplementation = properties.getEnum(STORAGE_IMPLEMENTATION, StorageType.class); this.readOnlySegmentStore = properties.getBoolean(READONLY_SEGMENT_STORE); this.secureZK = properties.getBoolean(SECURE_ZK); this.zkTrustStore = properties.get(ZK_TRUSTSTORE_LOCATION); this.zkTrustStorePasswordPath = properties.get(ZK_TRUST_STORE_PASSWORD_PATH); this.enableTls = properties.getBoolean(ENABLE_TLS); this.keyFile = properties.get(KEY_FILE);
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); }
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);
this.zkAddress = properties.get(ZK_ADDRESS).replace(",", ";"); 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); this.tlsTrustStore = properties.get(TLS_TRUST_STORE_PATH); this.tlsTrustStorePasswordPath = properties.get(TLS_TRUST_STORE_PASSWORD_PATH);
/** * 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); } }