Search in sources :

Example 1 with InMemoryStorageFactory

use of io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory in project pravega by pravega.

the class DebugRecoveryProcessor method create.

/**
 * Creates a new instance of the DebugRecoveryProcessor class with the given arguments.
 *
 * @param containerId     The Id of the Container to recover.
 * @param durableDataLog  A DurableDataLog to recover from.
 * @param config          A ContainerConfig to use during recovery.
 * @param readIndexConfig A ReadIndexConfig to use during recovery.
 * @param executor        An Executor to use for background tasks.
 * @param callbacks       Callbacks to invoke during recovery.
 * @return A new instance of the DebugRecoveryProcessor.
 */
public static DebugRecoveryProcessor create(int containerId, DurableDataLog durableDataLog, ContainerConfig config, ReadIndexConfig readIndexConfig, ScheduledExecutorService executor, OperationCallbacks callbacks) {
    Preconditions.checkNotNull(durableDataLog, "durableDataLog");
    Preconditions.checkNotNull(config, "config");
    Preconditions.checkNotNull(readIndexConfig, "readIndexConfig");
    Preconditions.checkNotNull(executor, "executor");
    Preconditions.checkNotNull(callbacks, callbacks);
    StreamSegmentContainerMetadata metadata = new StreamSegmentContainerMetadata(containerId, config.getMaxActiveSegmentCount());
    ContainerReadIndexFactory rf = new ContainerReadIndexFactory(readIndexConfig, new NoOpCacheFactory(), executor);
    Storage s = new InMemoryStorageFactory(executor).createStorageAdapter();
    return new DebugRecoveryProcessor(metadata, durableDataLog, rf, s, callbacks);
}
Also used : Storage(io.pravega.segmentstore.storage.Storage) ContainerReadIndexFactory(io.pravega.segmentstore.server.reading.ContainerReadIndexFactory) InMemoryStorageFactory(io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory) StreamSegmentContainerMetadata(io.pravega.segmentstore.server.containers.StreamSegmentContainerMetadata)

Example 2 with InMemoryStorageFactory

use of io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory in project pravega by pravega.

the class ServiceBuilder method newInMemoryBuilder.

/**
 * 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.
 * @param executorBuilder A Function that, given a thread count and a pool name, creates a ScheduledExecutorService
 *                        with the given number of threads that have the given name as prefix.
 */
@VisibleForTesting
public static ServiceBuilder newInMemoryBuilder(ServiceBuilderConfig builderConfig, ExecutorBuilder executorBuilder) {
    ServiceConfig serviceConfig = builderConfig.getConfig(ServiceConfig::builder);
    ServiceBuilder builder;
    if (serviceConfig.isReadOnlySegmentStore()) {
        // Only components required for ReadOnly SegmentStore.
        builder = new ReadOnlyServiceBuilder(builderConfig, serviceConfig, executorBuilder);
    } else {
        // Components that are required for general SegmentStore.
        builder = new ServiceBuilder(builderConfig, serviceConfig, executorBuilder).withCacheFactory(setup -> new InMemoryCacheFactory());
    }
    // Components that are required for all types of SegmentStore.
    return builder.withDataLogFactory(setup -> new InMemoryDurableDataLogFactory(setup.getCoreExecutor())).withContainerManager(setup -> new LocalSegmentContainerManager(setup.getContainerRegistry(), setup.getSegmentToContainerMapper())).withStorageFactory(setup -> new InMemoryStorageFactory(setup.getStorageExecutor())).withStreamSegmentStore(setup -> new StreamSegmentService(setup.getContainerRegistry(), setup.getSegmentToContainerMapper()));
}
Also used : ReadOnlySegmentContainerFactory(io.pravega.segmentstore.server.containers.ReadOnlySegmentContainerFactory) Getter(lombok.Getter) WriterConfig(io.pravega.segmentstore.server.writer.WriterConfig) StorageFactory(io.pravega.segmentstore.storage.StorageFactory) StreamSegmentContainerFactory(io.pravega.segmentstore.server.containers.StreamSegmentContainerFactory) StorageWriterFactory(io.pravega.segmentstore.server.writer.StorageWriterFactory) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ReadIndexFactory(io.pravega.segmentstore.server.ReadIndexFactory) AccessLevel(lombok.AccessLevel) InMemoryStorageFactory(io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory) ContainerConfig(io.pravega.segmentstore.server.containers.ContainerConfig) ReadIndexConfig(io.pravega.segmentstore.server.reading.ReadIndexConfig) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) DurableDataLogException(io.pravega.segmentstore.storage.DurableDataLogException) LocalSegmentContainerManager(io.pravega.segmentstore.server.mocks.LocalSegmentContainerManager) ContainerReadIndexFactory(io.pravega.segmentstore.server.reading.ContainerReadIndexFactory) InMemoryDurableDataLogFactory(io.pravega.segmentstore.storage.mocks.InMemoryDurableDataLogFactory) StreamSegmentStore(io.pravega.segmentstore.contracts.StreamSegmentStore) CacheFactory(io.pravega.segmentstore.storage.CacheFactory) WriterFactory(io.pravega.segmentstore.server.WriterFactory) DurableLogFactory(io.pravega.segmentstore.server.logs.DurableLogFactory) DurableLogConfig(io.pravega.segmentstore.server.logs.DurableLogConfig) SegmentStoreMetrics(io.pravega.segmentstore.server.SegmentStoreMetrics) ConfigBuilder(io.pravega.common.util.ConfigBuilder) Slf4j(lombok.extern.slf4j.Slf4j) SegmentContainerManager(io.pravega.segmentstore.server.SegmentContainerManager) SegmentContainerFactory(io.pravega.segmentstore.server.SegmentContainerFactory) InMemoryCacheFactory(io.pravega.segmentstore.storage.mocks.InMemoryCacheFactory) SegmentContainerRegistry(io.pravega.segmentstore.server.SegmentContainerRegistry) SegmentToContainerMapper(io.pravega.shared.segment.SegmentToContainerMapper) OperationLogFactory(io.pravega.segmentstore.server.OperationLogFactory) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ExecutorServiceHelpers(io.pravega.common.concurrent.ExecutorServiceHelpers) DurableDataLogFactory(io.pravega.segmentstore.storage.DurableDataLogFactory) InMemoryCacheFactory(io.pravega.segmentstore.storage.mocks.InMemoryCacheFactory) InMemoryStorageFactory(io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory) LocalSegmentContainerManager(io.pravega.segmentstore.server.mocks.LocalSegmentContainerManager) InMemoryDurableDataLogFactory(io.pravega.segmentstore.storage.mocks.InMemoryDurableDataLogFactory) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with InMemoryStorageFactory

use of io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory in project pravega by pravega.

the class StreamSegmentServiceTests method setUp.

@Before
public void setUp() {
    this.storageFactory = new InMemoryStorageFactory(executorService());
    this.durableDataLogFactory = new PermanentDurableDataLogFactory(executorService());
}
Also used : InMemoryStorageFactory(io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory) Before(org.junit.Before)

Aggregations

InMemoryStorageFactory (io.pravega.segmentstore.storage.mocks.InMemoryStorageFactory)3 ContainerReadIndexFactory (io.pravega.segmentstore.server.reading.ContainerReadIndexFactory)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 ExecutorServiceHelpers (io.pravega.common.concurrent.ExecutorServiceHelpers)1 ConfigBuilder (io.pravega.common.util.ConfigBuilder)1 StreamSegmentStore (io.pravega.segmentstore.contracts.StreamSegmentStore)1 OperationLogFactory (io.pravega.segmentstore.server.OperationLogFactory)1 ReadIndexFactory (io.pravega.segmentstore.server.ReadIndexFactory)1 SegmentContainerFactory (io.pravega.segmentstore.server.SegmentContainerFactory)1 SegmentContainerManager (io.pravega.segmentstore.server.SegmentContainerManager)1 SegmentContainerRegistry (io.pravega.segmentstore.server.SegmentContainerRegistry)1 SegmentStoreMetrics (io.pravega.segmentstore.server.SegmentStoreMetrics)1 WriterFactory (io.pravega.segmentstore.server.WriterFactory)1 ContainerConfig (io.pravega.segmentstore.server.containers.ContainerConfig)1 ReadOnlySegmentContainerFactory (io.pravega.segmentstore.server.containers.ReadOnlySegmentContainerFactory)1 StreamSegmentContainerFactory (io.pravega.segmentstore.server.containers.StreamSegmentContainerFactory)1 StreamSegmentContainerMetadata (io.pravega.segmentstore.server.containers.StreamSegmentContainerMetadata)1 DurableLogConfig (io.pravega.segmentstore.server.logs.DurableLogConfig)1 DurableLogFactory (io.pravega.segmentstore.server.logs.DurableLogFactory)1