use of io.pravega.segmentstore.server.containers.StreamSegmentMapper 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;
}
use of io.pravega.segmentstore.server.containers.StreamSegmentMapper 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;
}
Aggregations