private SegmentContainerRegistry createSegmentContainerRegistry() { SegmentContainerFactory containerFactory = getSingleton(this.containerFactory, this::createSegmentContainerFactory); return new StreamSegmentContainerRegistry(containerFactory, this.coreExecutor); }
/** * Creates or gets the instance of the SegmentContainerRegistry used throughout this ServiceBuilder. */ private SegmentContainerRegistry getSegmentContainerRegistry() { return getSingleton(this.containerRegistry, this::createSegmentContainerRegistry); }
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 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; }
@Override protected ServiceBuilder createBuilder(ServiceBuilderConfig.Builder builderConfig, int instanceId) { return ServiceBuilder.newInMemoryBuilder(builderConfig.build()) .withStorageFactory(setup -> this.storageFactory) .withDataLogFactory(setup -> this.durableDataLogFactory); }
private static ServiceBuilder newInlineExecutionInMemoryBuilder(ServiceBuilderConfig config) { return ServiceBuilder.newInMemoryBuilder(config, (size, name) -> new InlineExecutor()) .withStreamSegmentStore(setup -> new SynchronousStreamSegmentStore(new StreamSegmentService( setup.getContainerRegistry(), setup.getSegmentToContainerMapper()))); } }
@Override protected ServiceBuilder createBuilder(ServiceBuilderConfig.Builder builderConfig, int instanceId) { return super.createBuilder(builderConfig, instanceId) .withStreamSegmentStore(setup -> { StreamSegmentStore base = new StreamSegmentService(setup.getContainerRegistry(), setup.getSegmentToContainerMapper()); return new SynchronousStreamSegmentStore(base); }); } }
private void attachStorage(ServiceBuilder builder) { builder.withStorageFactory(setup -> { StorageLoader loader = new StorageLoader(); return loader.load(setup, this.serviceConfig.getStorageImplementation().toString(), setup.getStorageExecutor()); }); }
private ServiceBuilder createBuilder(int instanceId) throws Exception { val builder = createBuilder(this.configBuilder, instanceId); try { builder.initialize(); } catch (Throwable ex) { builder.close(); throw ex; } return builder; }
private ReadOnlyServiceBuilder(ServiceBuilderConfig serviceBuilderConfig, ServiceConfig serviceConfig, ExecutorBuilder executorBuilder) { super(serviceBuilderConfig, serviceConfig, executorBuilder); // We attach a LocalSegmentContainerManager, since we only have one Container Running. // Note that withContainerManager() is disabled in ReadOnlyServiceBuilder, hence we must invoke the one on // the parent class. super.withContainerManager(setup -> new LocalSegmentContainerManager(setup.getContainerRegistry(), setup.getSegmentToContainerMapper())); }
/** * Creates a new instance of TableStore using the components generated by this class. */ public TableStore createTableStoreService() { return getSingleton(this.tableStoreService, setup -> new TableService(setup.getContainerRegistry(), setup.getSegmentToContainerMapper())); }
protected ReadIndexFactory createReadIndexFactory() { CacheFactory cacheFactory = getSingleton(this.cacheFactory, this.cacheFactoryCreator); ReadIndexConfig readIndexConfig = this.serviceBuilderConfig.getConfig(ReadIndexConfig::builder); return new ContainerReadIndexFactory(readIndexConfig, cacheFactory, this.cacheManager, this.coreExecutor); }
/** * 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); }
/** * Creates a new instance of the ServiceBuilder class which is contained in memory. Any data added to this service will * be lost when the object is garbage collected or the process terminates. * * @param builderConfig The ServiceBuilderConfig to use. */ public static ServiceBuilder newInMemoryBuilder(ServiceBuilderConfig builderConfig) { return newInMemoryBuilder(builderConfig, ExecutorServiceHelpers::newScheduledThreadPool); }
/** * 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); } }
/** * Creates a new Builder for this class. * * @return The created Builder. */ public static Builder builder() { return new Builder(); }
@Override protected int getThreadPoolSize() { // We await all async operations, which means we'll be eating up a lot of threads for this test. return super.getThreadPoolSize() * 50; }
@Override public SegmentContainer createStreamSegmentContainer(int containerId) { return new TestContainer(containerId, this.startException, this.startReleaseSignal); } }
/** * Creates a new instance of StreamSegmentStore using the components generated by this class. */ public StreamSegmentStore createStreamSegmentService() { return getSingleton(this.streamSegmentService, this.streamSegmentStoreCreator); }