.include(System.getProperty(ServiceBuilderConfig.CONFIG_FILE_PROPERTY_NAME, "config.properties")) .include(System.getProperties()) .build();
private void verifyContents(String message, Properties expected, ServiceBuilderConfig.Builder builder) { AtomicReference<Properties> rawProperties = new AtomicReference<>(); builder.build().getConfig(() -> new TestConfigBuilder<>(s -> s, rawProperties::set)); AssertExtensions.assertContainsSameElements( message, expected.entrySet(), rawProperties.get().entrySet(), (e1, e2) -> { int keyCompare = ((String) e1.getKey()).compareTo((String) e2.getKey()); int valueCompare = ((String) e1.getValue()).compareTo((String) e2.getValue()); return keyCompare * valueCompare + keyCompare + valueCompare; }); }
@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)); }
val builderConfig = b.build(); for (Map.Entry<Class<?>, Supplier<ConfigBuilder<?>>> e : testClasses.entrySet()) { Class<?> c = e.getKey();
.include(System.getProperty(SingleNodeConfig.PROPERTY_FILE, "./config/standalone-config.properties")) .include(System.getProperties()) .build(); SingleNodeConfig conf = config.getConfig(SingleNodeConfig::builder);
.with(MetricsConfig.ENABLE_STATISTICS, enableMetrics)); nodeServiceStarter[segmentStoreId] = new ServiceStarter(configBuilder.build()); nodeServiceStarter[segmentStoreId].start();
@Cleanup val context = createContext(); val readIndexConfig = getCommandArgs().getState().getConfigBuilder().build().getConfig(ReadIndexConfig::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(); }
/** * Creates a new Context to be used by the BookKeeper command. * * @return A new Context. * @throws DurableDataLogException If the BookKeeperLogFactory could not be initialized. */ @Override protected Context createContext() throws DurableDataLogException { val serviceConfig = getServiceConfig(); val containerConfig = getCommandArgs().getState().getConfigBuilder().build().getConfig(ContainerConfig::builder); val bkConfig = getCommandArgs().getState().getConfigBuilder() .include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, serviceConfig.getZkURL())) .build().getConfig(BookKeeperConfig::builder); val zkClient = createZKClient(); val factory = new BookKeeperLogFactory(bkConfig, zkClient, getCommandArgs().getState().getExecutor()); try { factory.initialize(); } catch (DurableDataLogException ex) { zkClient.close(); throw ex; } val bkAdmin = new BookKeeperAdmin(factory.getBookKeeperClient()); return new Context(serviceConfig, containerConfig, bkConfig, zkClient, factory, bkAdmin); }
/** * Creates a new Context to be used by the BookKeeper command. * * @return A new Context. * @throws DurableDataLogException If the BookKeeperLogFactory could not be initialized. */ protected Context createContext() throws DurableDataLogException { val serviceConfig = getServiceConfig(); val bkConfig = getCommandArgs().getState().getConfigBuilder() .include(BookKeeperConfig.builder().with(BookKeeperConfig.ZK_ADDRESS, serviceConfig.getZkURL())) .build().getConfig(BookKeeperConfig::builder); val zkClient = createZKClient(); val factory = new BookKeeperLogFactory(bkConfig, zkClient, getCommandArgs().getState().getExecutor()); try { factory.initialize(); } catch (DurableDataLogException ex) { zkClient.close(); throw ex; } val bkAdmin = new BookKeeperAdmin(factory.getBookKeeperClient()); return new Context(serviceConfig, bkConfig, zkClient, factory, bkAdmin); }
/** * Creates a ServiceBuilderConfig based on the given builder, by attaching the correct RocksDB file path based on the instance. * * @param configBuilder The ServiceBuilderConfig.Builder to base from (this builder will not be touched). * @param instanceId The instance id of the Service to build (for least interference, different instances should have * different Ids so that shared resources (i.e., RocksDB) can be setup appropriately). * @return A ServiceBuilderConfig instance. */ protected ServiceBuilderConfig getBuilderConfig(ServiceBuilderConfig.Builder configBuilder, int instanceId) { String id = Integer.toString(instanceId); return configBuilder .makeCopy() .include(ServiceConfig.builder().with(ServiceConfig.INSTANCE_ID, id)) .include(RocksDBConfig.builder().with(RocksDBConfig.DATABASE_DIR, Paths.get(getRocksDBDir().toString(), id).toString())) .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; }
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(); }
@Override protected ServiceBuilder createBuilder(ServiceBuilderConfig.Builder builderConfig, int instanceId) { return ServiceBuilder.newInMemoryBuilder(builderConfig.build()) .withStorageFactory(setup -> this.storageFactory) .withDataLogFactory(setup -> this.durableDataLogFactory); }
private ServiceBuilder createBuilder() throws Exception { val builder = ServiceBuilder.newInMemoryBuilder(this.configBuilder.build()) .withStorageFactory(setup -> this.storageFactory) .withDataLogFactory(setup -> this.durableDataLogFactory); try { builder.initialize(); } catch (Throwable ex) { builder.close(); throw ex; } return builder; }
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(); }
/** * Gets a default set of configuration values, in absence of any real configuration. * These configuration values are the default ones from all component configurations, except that it will * create only one container to host segments. */ public static ServiceBuilderConfig getDefaultConfig() { // All component configs should have defaults built-in, so no need to override them here. return new Builder() .include(ServiceConfig.builder().with(ServiceConfig.CONTAINER_COUNT, 1)) .build(); }
/** * Creates a new instance of the ServiceConfig class from the shared AdminCommandState passed in via the Constructor. */ protected ServiceConfig getServiceConfig() { return getCommandArgs().getState().getConfigBuilder().build().getConfig(ServiceConfig::builder); }