Search in sources :

Example 1 with StorageExtraConfig

use of io.pravega.segmentstore.storage.noop.StorageExtraConfig in project pravega by pravega.

the class StorageLoader method load.

public StorageFactory load(ConfigSetup setup, String storageImplementation, StorageLayoutType storageLayoutType, ScheduledExecutorService executor) {
    ServiceLoader<StorageFactoryCreator> loader = ServiceLoader.load(StorageFactoryCreator.class);
    StorageExtraConfig noOpConfig = setup.getConfig(StorageExtraConfig::builder);
    for (StorageFactoryCreator factoryCreator : loader) {
        val factories = factoryCreator.getStorageFactories();
        for (val factoryInfo : factories) {
            log.info("Loading {}, trying {}", storageImplementation, factoryInfo);
            if (factoryInfo.getName().equals(storageImplementation) && factoryInfo.getStorageLayoutType() == storageLayoutType) {
                StorageFactory factory = factoryCreator.createFactory(factoryInfo, setup, executor);
                if (!noOpConfig.isStorageNoOpMode()) {
                    return factory;
                } else {
                    // The specified storage implementation is in No-Op mode.
                    log.warn("{} IS IN NO-OP MODE: DATA LOSS WILL HAPPEN! MAKE SURE IT IS BY FULL INTENTION FOR TESTING PURPOSE!", storageImplementation);
                    return new NoOpStorageFactory(noOpConfig, executor, factory, null);
                }
            }
        }
    }
    return null;
}
Also used : lombok.val(lombok.val) StorageFactory(io.pravega.segmentstore.storage.StorageFactory) NoOpStorageFactory(io.pravega.segmentstore.storage.noop.NoOpStorageFactory) NoOpStorageFactory(io.pravega.segmentstore.storage.noop.NoOpStorageFactory) StorageFactoryCreator(io.pravega.segmentstore.storage.StorageFactoryCreator) StorageExtraConfig(io.pravega.segmentstore.storage.noop.StorageExtraConfig)

Aggregations

StorageFactory (io.pravega.segmentstore.storage.StorageFactory)1 StorageFactoryCreator (io.pravega.segmentstore.storage.StorageFactoryCreator)1 NoOpStorageFactory (io.pravega.segmentstore.storage.noop.NoOpStorageFactory)1 StorageExtraConfig (io.pravega.segmentstore.storage.noop.StorageExtraConfig)1 lombok.val (lombok.val)1