/** * Gets the Configuration with specified constructor from the ServiceBuilder's config. * * @param builderConstructor A Supplier that creates a ConfigBuilder for the desired configuration type. * @param <T> The type of the Configuration to instantiate. */ @Override public <T> T getConfig(Supplier<? extends ConfigBuilder<T>> builderConstructor) { return this.builder.serviceBuilderConfig.getConfig(builderConstructor); }
TestingServer zkTestServer = new TestingServerStarter().start(); ServiceBuilder serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig()); serviceBuilder.initialize(); StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
/** * 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. } }
@Override public void execute() { Preconditions.checkArgument(getCommandArgs().getArgs().size() == 0, "Not expecting any arguments."); getCommandArgs().getState().getConfigBuilder().build().forEach((name, value) -> output("\t%s=%s", name, value)); }
/** * Creates a new instance of the ServiceBuilderConfig class with the information contained in this builder. * * @return The newly created ServiceBuilderConfig. */ public ServiceBuilderConfig build() { return new ServiceBuilderConfig(this.properties); } }
public static void main(String[] args) { try { ServiceBuilderConfig config = ServiceBuilderConfig .builder() .include(System.getProperty(SingleNodeConfig.PROPERTY_FILE, "./config/standalone-config.properties")) .include(System.getProperties()) .build(); SingleNodeConfig conf = config.getConfig(SingleNodeConfig::builder);
/** * 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); }
public ServiceStarter(ServiceBuilderConfig config) { this.builderConfig = config; this.serviceConfig = this.builderConfig.getConfig(ServiceConfig::builder); this.serviceBuilder = createServiceBuilder(); }
@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(); }
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 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(); }
public static void main(String[] args) throws Exception { @Cleanup ServiceBuilder serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig()); serviceBuilder.initialize(); StreamSegmentStore store = serviceBuilder.createStreamSegmentService(); TableStore tableStore = serviceBuilder.createTableStoreService(); @Cleanup PravegaConnectionListener server = new PravegaConnectionListener(false, StartLocalService.SERVICE_PORT, store, tableStore); server.startListening(); @Cleanup MockStreamManager streamManager = new MockStreamManager(SCOPE, "localhost", StartLocalService.SERVICE_PORT); streamManager.createScope(SCOPE); streamManager.createStream(SCOPE, STREAM_NAME, null); Thread.sleep(60000); System.exit(0); } }
protected WriterFactory createWriterFactory() { WriterConfig writerConfig = this.serviceBuilderConfig.getConfig(WriterConfig::builder); return new StorageWriterFactory(writerConfig, this.coreExecutor); }
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; }
.builder() .include(System.getProperties()) .include(authProps)
ServiceBuilder serviceBuilder = ServiceBuilder.newInMemoryBuilder(ServiceBuilderConfig.getDefaultConfig()); serviceBuilder.initialize(); StreamSegmentStore store = serviceBuilder.createStreamSegmentService();
protected OperationLogFactory createOperationLogFactory() { DurableDataLogFactory dataLogFactory = getSingleton(this.dataLogFactory, this.dataLogFactoryCreator); DurableLogConfig durableLogConfig = this.serviceBuilderConfig.getConfig(DurableLogConfig::builder); return new DurableLogFactory(durableLogConfig, dataLogFactory, this.coreExecutor); }
/** * 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)); }