Search in sources :

Example 1 with SegmentPublisherWrapper

use of org.infinispan.persistence.support.SegmentPublisherWrapper in project infinispan by infinispan.

the class SFSToSIFSStore method start.

@Override
public CompletionStage<Void> start(InitializationContext ctx) {
    SFSToSIFSConfiguration sfsToSIFSConfiguration = ctx.getConfiguration();
    CompletionStage<NonBlockingStore<K, V>> targetStage = createAndStartSoftIndexFileStore(ctx, sfsToSIFSConfiguration);
    // If config has purge don't even bother with migration
    if (sfsToSIFSConfiguration.purgeOnStartup()) {
        return targetStage.thenAccept(sifsStore -> targetStore = sifsStore);
    }
    CompletionStage<NonBlockingStore<K, V>> nonSegmentedSFSStage = createAndStartSingleFileStore(ctx, sfsToSIFSConfiguration.dataLocation(), false);
    CompletionStage<NonBlockingStore<K, V>> segmentedSFSStage = createAndStartSingleFileStore(ctx, sfsToSIFSConfiguration.dataLocation(), true);
    Function<NonBlockingStore<K, V>, CompletionStage<Void>> composed = sourceStore -> targetStage.thenCompose(targetStore -> {
        this.targetStore = targetStore;
        int segmentCount = ctx.getCache().getCacheConfiguration().clustering().hash().numSegments();
        IntSet allSegments = IntSets.immutableRangeSet(segmentCount);
        Flowable<GroupedFlowable<Integer, MarshallableEntry<K, V>>> groupedFlowable = Flowable.fromPublisher(sourceStore.publishEntries(allSegments, null, true)).groupBy(ctx.getKeyPartitioner()::getSegment);
        return targetStore.batch(segmentCount, Flowable.empty(), groupedFlowable.map(SegmentPublisherWrapper::wrap)).thenCompose(ignore -> sourceStore.destroy());
    });
    return CompletionStages.allOf(nonSegmentedSFSStage.thenCompose(composed), segmentedSFSStage.thenCompose(composed));
}
Also used : IntSets(org.infinispan.commons.util.IntSets) Flowable(io.reactivex.rxjava3.core.Flowable) AbstractStoreConfiguration(org.infinispan.configuration.cache.AbstractStoreConfiguration) NonBlockingStore(org.infinispan.persistence.spi.NonBlockingStore) CompletionStages(org.infinispan.util.concurrent.CompletionStages) DelegatingInitializationContext(org.infinispan.persistence.support.DelegatingInitializationContext) Function(java.util.function.Function) IntSet(org.infinispan.commons.util.IntSet) PersistenceUtil(org.infinispan.persistence.internal.PersistenceUtil) AttributeSet(org.infinispan.commons.configuration.attributes.AttributeSet) StoreConfiguration(org.infinispan.configuration.cache.StoreConfiguration) CompletionStage(java.util.concurrent.CompletionStage) GroupedFlowable(io.reactivex.rxjava3.flowables.GroupedFlowable) SoftIndexFileStoreConfiguration(org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfiguration) InitializationContext(org.infinispan.persistence.spi.InitializationContext) DelegatingNonBlockingStore(org.infinispan.persistence.support.DelegatingNonBlockingStore) MarshallableEntry(org.infinispan.persistence.spi.MarshallableEntry) ConfiguredBy(org.infinispan.commons.configuration.ConfiguredBy) SegmentPublisherWrapper(org.infinispan.persistence.support.SegmentPublisherWrapper) SingleFileStoreConfiguration(org.infinispan.configuration.cache.SingleFileStoreConfiguration) AsyncStoreConfiguration(org.infinispan.configuration.cache.AsyncStoreConfiguration) NonBlockingStore(org.infinispan.persistence.spi.NonBlockingStore) DelegatingNonBlockingStore(org.infinispan.persistence.support.DelegatingNonBlockingStore) IntSet(org.infinispan.commons.util.IntSet) SegmentPublisherWrapper(org.infinispan.persistence.support.SegmentPublisherWrapper) CompletionStage(java.util.concurrent.CompletionStage) GroupedFlowable(io.reactivex.rxjava3.flowables.GroupedFlowable)

Aggregations

Flowable (io.reactivex.rxjava3.core.Flowable)1 GroupedFlowable (io.reactivex.rxjava3.flowables.GroupedFlowable)1 CompletionStage (java.util.concurrent.CompletionStage)1 Function (java.util.function.Function)1 ConfiguredBy (org.infinispan.commons.configuration.ConfiguredBy)1 AttributeSet (org.infinispan.commons.configuration.attributes.AttributeSet)1 IntSet (org.infinispan.commons.util.IntSet)1 IntSets (org.infinispan.commons.util.IntSets)1 AbstractStoreConfiguration (org.infinispan.configuration.cache.AbstractStoreConfiguration)1 AsyncStoreConfiguration (org.infinispan.configuration.cache.AsyncStoreConfiguration)1 SingleFileStoreConfiguration (org.infinispan.configuration.cache.SingleFileStoreConfiguration)1 StoreConfiguration (org.infinispan.configuration.cache.StoreConfiguration)1 PersistenceUtil (org.infinispan.persistence.internal.PersistenceUtil)1 SoftIndexFileStoreConfiguration (org.infinispan.persistence.sifs.configuration.SoftIndexFileStoreConfiguration)1 InitializationContext (org.infinispan.persistence.spi.InitializationContext)1 MarshallableEntry (org.infinispan.persistence.spi.MarshallableEntry)1 NonBlockingStore (org.infinispan.persistence.spi.NonBlockingStore)1 DelegatingInitializationContext (org.infinispan.persistence.support.DelegatingInitializationContext)1 DelegatingNonBlockingStore (org.infinispan.persistence.support.DelegatingNonBlockingStore)1 SegmentPublisherWrapper (org.infinispan.persistence.support.SegmentPublisherWrapper)1