/** * Creates a new instance of the AdminCommandState class. * * @throws IOException If unable to read specified config properties file (assuming it exists). */ public AdminCommandState() throws IOException { this.configBuilder = ServiceBuilderConfig.builder(); try { this.configBuilder.include(System.getProperty(ServiceBuilderConfig.CONFIG_FILE_PROPERTY_NAME, "config.properties")); } catch (FileNotFoundException ex) { // Nothing to do here. } }
.builder() .include(System.getProperty(ServiceBuilderConfig.CONFIG_FILE_PROPERTY_NAME, "config.properties")) .include(System.getProperties())
val b = ServiceBuilderConfig.builder(); for (Map.Entry<Class<?>, Supplier<ConfigBuilder<?>>> e : testClasses.entrySet()) { Class<?> c = e.getKey();
/** * Tests the Builder for ServiceBuilderConfig. */ @Test public void testBuilder() throws Exception { final int propertyCount = 20; // Create three raw Properties. val p1 = buildProperties(0, propertyCount / 2, 0); val p2 = buildProperties(propertyCount / 4, propertyCount / 2, 100); val p3 = buildProperties(propertyCount / 2, propertyCount / 2, 1000); // Save #1 to a temp file. @Cleanup("delete") File tmpFile = File.createTempFile("pravega-", "-servicebuildertest"); try (val writer = new FileWriter(tmpFile)) { p1.store(writer, ""); } // Create a builder and load up #1 from file val b = ServiceBuilderConfig.builder().include(tmpFile.getPath()); val expected = new Properties(); expected.putAll(p1); verifyContents("Unexpected contents after: file. ", expected, b); // Include #2. b.include(p2); expected.putAll(p2); verifyContents("Unexpected contents after: file + Properties.", expected, b); // Include a test config builder with #3. b.include(new ConfigBuilderSupplier<>(p3, s -> s)); expected.putAll(p3); verifyContents("Unexpected contents after: file + Properties + ConfigBuilder.", expected, b); }
private static ServiceBuilderConfig getReadOnlyBuilderConfig() { val baseConfig = getBuilderConfig(); val props = new Properties(); baseConfig.forEach(props::put); return ServiceBuilderConfig.builder() .include(props) .include(ServiceConfig.builder() .with(ServiceConfig.READONLY_SEGMENT_STORE, true)) .build(); }
private ServiceBuilder createReadOnlyBuilder(int instanceId) throws Exception { // Copy base config properties to a new object. val props = new Properties(); this.configBuilder.build().forEach(props::put); // Create a new config (so we don't alter the base one) and set the ReadOnlySegmentStore to true). val configBuilder = ServiceBuilderConfig.builder() .include(props) .include(ServiceConfig.builder() .with(ServiceConfig.READONLY_SEGMENT_STORE, true)); val builder = createBuilder(configBuilder, instanceId); builder.initialize(); return builder; }
public static void main(String[] args) { try { ServiceBuilderConfig config = ServiceBuilderConfig .builder() .include(System.getProperty(SingleNodeConfig.PROPERTY_FILE, "./config/standalone-config.properties")) .include(System.getProperties())
private static ServiceBuilderConfig getBuilderConfig() { return ServiceBuilderConfig .builder() .include(ServiceConfig.builder() .with(ServiceConfig.CONTAINER_COUNT, 1) .with(ServiceConfig.THREAD_POOL_SIZE, 3) .with(ServiceConfig.LISTENING_PORT, TestUtils.getAvailableListenPort())) .build(); }
.builder() .include(System.getProperties()) .include(authProps)
/** * Generates a new ServiceBuilderConfig.Builder with hardcoded defaults, in case these are not supplied via other means, * such as a config file or System Properties. */ private static ServiceBuilderConfig.Builder getDefaultServiceBuilderConfig() { return ServiceBuilderConfig .builder() .include(ServiceConfig.builder() .with(ServiceConfig.THREAD_POOL_SIZE, 80) .with(ServiceConfig.CACHE_POLICY_MAX_TIME, 600) .with(ServiceConfig.CACHE_POLICY_MAX_SIZE, 4 * 1024 * 1024 * 1024L) .with(ServiceConfig.CERT_FILE, "../config/cert.pem") .with(ServiceConfig.KEY_FILE, "../config/key.pem")) .include(DurableLogConfig.builder() .with(DurableLogConfig.CHECKPOINT_COMMIT_COUNT, 100) .with(DurableLogConfig.CHECKPOINT_MIN_COMMIT_COUNT, 100) .with(DurableLogConfig.CHECKPOINT_TOTAL_COMMIT_LENGTH, 100 * 1024 * 1024L)) .include(ReadIndexConfig.builder() .with(ReadIndexConfig.MEMORY_READ_MIN_LENGTH, 128 * 1024)) .include(ContainerConfig.builder() .with(ContainerConfig.SEGMENT_METADATA_EXPIRATION_SECONDS, ContainerConfig.MINIMUM_SEGMENT_METADATA_EXPIRATION_SECONDS) .with(ContainerConfig.MAX_ACTIVE_SEGMENT_COUNT, 500)) // This is for those tests that use BookKeeper for Tier1. .include(BookKeeperConfig.builder() .with(BookKeeperConfig.BK_LEDGER_MAX_SIZE, Integer.MAX_VALUE) .with(BookKeeperConfig.ZK_METADATA_PATH, "/pravega/selftest/segmentstore/containers") .with(BookKeeperConfig.BK_LEDGER_PATH, TestConfig.BK_LEDGER_PATH)); }
.builder() .include(ServiceConfig .builder()
@Before public void setUp() throws Exception { ServiceBuilderConfig config = ServiceBuilderConfig .builder() .include(System.getProperties()) .build(); SingleNodeConfig conf = config.getConfig(SingleNodeConfig::builder); localPravega = LocalPravegaEmulator.builder() .controllerPort(TestUtils.getAvailableListenPort()) .segmentStorePort(TestUtils.getAvailableListenPort()) .zkPort(TestUtils.getAvailableListenPort()) .restServerPort(TestUtils.getAvailableListenPort()) .enableRestServer(restEnabled) .enableAuth(authEnabled) .enableTls(tlsEnabled) .certFile("../config/cert.pem") .keyFile("../config/key.pem") .jksKeyFile("../config/bookie.keystore.jks") .jksTrustFile("../config/bookie.truststore.jks") .keyPasswordFile("../config/bookie.keystore.jks.passwd") .passwdFile("../config/passwd") .userName("admin") .passwd("1111_aaaa") .build(); localPravega.start(); }