Search in sources :

Example 1 with InMemoryStateStore

use of io.pravega.segmentstore.server.containers.InMemoryStateStore in project pravega by pravega.

the class OperationLogTestBase method createStreamSegmentsWithOperations.

/**
 * Creates a number of StreamSegments in the given Metadata and OperationLog.
 */
HashSet<Long> createStreamSegmentsWithOperations(int streamSegmentCount, ContainerMetadata containerMetadata, OperationLog durableLog, Storage storage) {
    StreamSegmentMapper mapper = new StreamSegmentMapper(containerMetadata, durableLog, new InMemoryStateStore(), NO_OP_METADATA_CLEANUP, storage, ForkJoinPool.commonPool());
    HashSet<Long> result = new HashSet<>();
    for (int i = 0; i < streamSegmentCount; i++) {
        String name = getStreamSegmentName(i);
        long streamSegmentId = mapper.createNewStreamSegment(name, null, Duration.ZERO).thenCompose(v -> mapper.getOrAssignStreamSegmentId(name, Duration.ZERO)).join();
        result.add(streamSegmentId);
    }
    return result;
}
Also used : Storage(io.pravega.segmentstore.storage.Storage) AssertExtensions(io.pravega.test.common.AssertExtensions) StreamSegmentMapper(io.pravega.segmentstore.server.containers.StreamSegmentMapper) ProbeOperation(io.pravega.segmentstore.server.logs.operations.ProbeOperation) RequiredArgsConstructor(lombok.RequiredArgsConstructor) ContainerMetadata(io.pravega.segmentstore.server.ContainerMetadata) TimeoutException(java.util.concurrent.TimeoutException) Cleanup(lombok.Cleanup) UpdateableSegmentMetadata(io.pravega.segmentstore.server.UpdateableSegmentMetadata) SequencedItemList(io.pravega.common.util.SequencedItemList) AttributeUpdate(io.pravega.segmentstore.contracts.AttributeUpdate) ByteArrayInputStream(java.io.ByteArrayInputStream) ReadResultEntryContents(io.pravega.segmentstore.contracts.ReadResultEntryContents) Duration(java.time.Duration) Map(java.util.Map) Operation(io.pravega.segmentstore.server.logs.operations.Operation) CancellationException(java.util.concurrent.CancellationException) Collection(java.util.Collection) UUID(java.util.UUID) StreamSegmentNameUtils(io.pravega.shared.segment.StreamSegmentNameUtils) List(java.util.List) ThreadPooledTestSuite(io.pravega.test.common.ThreadPooledTestSuite) Futures(io.pravega.common.concurrent.Futures) ReadResult(io.pravega.segmentstore.contracts.ReadResult) ObjectClosedException(io.pravega.common.ObjectClosedException) IllegalContainerStateException(io.pravega.segmentstore.server.IllegalContainerStateException) Exceptions(io.pravega.common.Exceptions) InMemoryStateStore(io.pravega.segmentstore.server.containers.InMemoryStateStore) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) UpdateableContainerMetadata(io.pravega.segmentstore.server.UpdateableContainerMetadata) SegmentMetadata(io.pravega.segmentstore.server.SegmentMetadata) DurableDataLogException(io.pravega.segmentstore.storage.DurableDataLogException) SequenceInputStream(java.io.SequenceInputStream) IntentionalException(io.pravega.test.common.IntentionalException) lombok.val(lombok.val) MetadataCheckpointOperation(io.pravega.segmentstore.server.logs.operations.MetadataCheckpointOperation) OperationLog(io.pravega.segmentstore.server.OperationLog) IOException(java.io.IOException) AtomicLong(java.util.concurrent.atomic.AtomicLong) AbstractMap(java.util.AbstractMap) StreamSegmentAppendOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentAppendOperation) ForkJoinPool(java.util.concurrent.ForkJoinPool) AttributeUpdateType(io.pravega.segmentstore.contracts.AttributeUpdateType) ReadIndex(io.pravega.segmentstore.server.ReadIndex) DataCorruptionException(io.pravega.segmentstore.server.DataCorruptionException) Assert(org.junit.Assert) MergeTransactionOperation(io.pravega.segmentstore.server.logs.operations.MergeTransactionOperation) Collections(java.util.Collections) StreamSegmentSealOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentSealOperation) InputStream(java.io.InputStream) InMemoryStateStore(io.pravega.segmentstore.server.containers.InMemoryStateStore) AtomicLong(java.util.concurrent.atomic.AtomicLong) StreamSegmentMapper(io.pravega.segmentstore.server.containers.StreamSegmentMapper) HashSet(java.util.HashSet)

Example 2 with InMemoryStateStore

use of io.pravega.segmentstore.server.containers.InMemoryStateStore in project pravega by pravega.

the class OperationLogTestBase method createTransactionsWithOperations.

/**
 * Creates a number of Transaction Segments in the given Metadata and OperationLog.
 */
AbstractMap<Long, Long> createTransactionsWithOperations(HashSet<Long> streamSegmentIds, int transactionsPerStreamSegment, ContainerMetadata containerMetadata, OperationLog durableLog, Storage storage) {
    HashMap<Long, Long> result = new HashMap<>();
    StreamSegmentMapper mapper = new StreamSegmentMapper(containerMetadata, durableLog, new InMemoryStateStore(), NO_OP_METADATA_CLEANUP, storage, ForkJoinPool.commonPool());
    for (long streamSegmentId : streamSegmentIds) {
        String streamSegmentName = containerMetadata.getStreamSegmentMetadata(streamSegmentId).getName();
        for (int i = 0; i < transactionsPerStreamSegment; i++) {
            long transactionId = mapper.createNewTransactionStreamSegment(streamSegmentName, UUID.randomUUID(), null, Duration.ZERO).thenCompose(v -> mapper.getOrAssignStreamSegmentId(v, Duration.ZERO)).join();
            result.put(transactionId, streamSegmentId);
        }
    }
    return result;
}
Also used : Storage(io.pravega.segmentstore.storage.Storage) AssertExtensions(io.pravega.test.common.AssertExtensions) StreamSegmentMapper(io.pravega.segmentstore.server.containers.StreamSegmentMapper) ProbeOperation(io.pravega.segmentstore.server.logs.operations.ProbeOperation) RequiredArgsConstructor(lombok.RequiredArgsConstructor) ContainerMetadata(io.pravega.segmentstore.server.ContainerMetadata) TimeoutException(java.util.concurrent.TimeoutException) Cleanup(lombok.Cleanup) UpdateableSegmentMetadata(io.pravega.segmentstore.server.UpdateableSegmentMetadata) SequencedItemList(io.pravega.common.util.SequencedItemList) AttributeUpdate(io.pravega.segmentstore.contracts.AttributeUpdate) ByteArrayInputStream(java.io.ByteArrayInputStream) ReadResultEntryContents(io.pravega.segmentstore.contracts.ReadResultEntryContents) Duration(java.time.Duration) Map(java.util.Map) Operation(io.pravega.segmentstore.server.logs.operations.Operation) CancellationException(java.util.concurrent.CancellationException) Collection(java.util.Collection) UUID(java.util.UUID) StreamSegmentNameUtils(io.pravega.shared.segment.StreamSegmentNameUtils) List(java.util.List) ThreadPooledTestSuite(io.pravega.test.common.ThreadPooledTestSuite) Futures(io.pravega.common.concurrent.Futures) ReadResult(io.pravega.segmentstore.contracts.ReadResult) ObjectClosedException(io.pravega.common.ObjectClosedException) IllegalContainerStateException(io.pravega.segmentstore.server.IllegalContainerStateException) Exceptions(io.pravega.common.Exceptions) InMemoryStateStore(io.pravega.segmentstore.server.containers.InMemoryStateStore) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) UpdateableContainerMetadata(io.pravega.segmentstore.server.UpdateableContainerMetadata) SegmentMetadata(io.pravega.segmentstore.server.SegmentMetadata) DurableDataLogException(io.pravega.segmentstore.storage.DurableDataLogException) SequenceInputStream(java.io.SequenceInputStream) IntentionalException(io.pravega.test.common.IntentionalException) lombok.val(lombok.val) MetadataCheckpointOperation(io.pravega.segmentstore.server.logs.operations.MetadataCheckpointOperation) OperationLog(io.pravega.segmentstore.server.OperationLog) IOException(java.io.IOException) AtomicLong(java.util.concurrent.atomic.AtomicLong) AbstractMap(java.util.AbstractMap) StreamSegmentAppendOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentAppendOperation) ForkJoinPool(java.util.concurrent.ForkJoinPool) AttributeUpdateType(io.pravega.segmentstore.contracts.AttributeUpdateType) ReadIndex(io.pravega.segmentstore.server.ReadIndex) DataCorruptionException(io.pravega.segmentstore.server.DataCorruptionException) Assert(org.junit.Assert) MergeTransactionOperation(io.pravega.segmentstore.server.logs.operations.MergeTransactionOperation) Collections(java.util.Collections) StreamSegmentSealOperation(io.pravega.segmentstore.server.logs.operations.StreamSegmentSealOperation) InputStream(java.io.InputStream) InMemoryStateStore(io.pravega.segmentstore.server.containers.InMemoryStateStore) HashMap(java.util.HashMap) AtomicLong(java.util.concurrent.atomic.AtomicLong) StreamSegmentMapper(io.pravega.segmentstore.server.containers.StreamSegmentMapper)

Aggregations

Iterators (com.google.common.collect.Iterators)2 Exceptions (io.pravega.common.Exceptions)2 ObjectClosedException (io.pravega.common.ObjectClosedException)2 Futures (io.pravega.common.concurrent.Futures)2 SequencedItemList (io.pravega.common.util.SequencedItemList)2 AttributeUpdate (io.pravega.segmentstore.contracts.AttributeUpdate)2 AttributeUpdateType (io.pravega.segmentstore.contracts.AttributeUpdateType)2 ReadResult (io.pravega.segmentstore.contracts.ReadResult)2 ReadResultEntryContents (io.pravega.segmentstore.contracts.ReadResultEntryContents)2 ContainerMetadata (io.pravega.segmentstore.server.ContainerMetadata)2 DataCorruptionException (io.pravega.segmentstore.server.DataCorruptionException)2 IllegalContainerStateException (io.pravega.segmentstore.server.IllegalContainerStateException)2 OperationLog (io.pravega.segmentstore.server.OperationLog)2 ReadIndex (io.pravega.segmentstore.server.ReadIndex)2 SegmentMetadata (io.pravega.segmentstore.server.SegmentMetadata)2 UpdateableContainerMetadata (io.pravega.segmentstore.server.UpdateableContainerMetadata)2 UpdateableSegmentMetadata (io.pravega.segmentstore.server.UpdateableSegmentMetadata)2 InMemoryStateStore (io.pravega.segmentstore.server.containers.InMemoryStateStore)2 StreamSegmentMapper (io.pravega.segmentstore.server.containers.StreamSegmentMapper)2 MergeTransactionOperation (io.pravega.segmentstore.server.logs.operations.MergeTransactionOperation)2