Search in sources :

Example 1 with InMemoryMetadataStore

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

the class StorageFactoryTests method testS3StorageFactoryCreator.

private void testS3StorageFactoryCreator(S3StorageConfig config) {
    StorageFactoryCreator factoryCreator = new S3StorageFactoryCreator();
    val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("S3").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build() };
    val factoryInfoList = factoryCreator.getStorageFactories();
    Assert.assertEquals(1, factoryInfoList.length);
    Assert.assertArrayEquals(expected, factoryInfoList);
    // Simple Storage
    ConfigSetup configSetup1 = mock(ConfigSetup.class);
    when(configSetup1.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, config);
    val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executorService());
    Assert.assertTrue(factory1 instanceof S3SimpleStorageFactory);
    @Cleanup Storage storage1 = ((S3SimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService()));
    Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
    Assert.assertTrue(((ChunkedSegmentStorage) storage1).getChunkStorage() instanceof S3ChunkStorage);
    AssertExtensions.assertThrows("createStorageAdapter should throw UnsupportedOperationException.", () -> factory1.createStorageAdapter(), ex -> ex instanceof UnsupportedOperationException);
}
Also used : lombok.val(lombok.val) Storage(io.pravega.segmentstore.storage.Storage) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) ExtendedS3ChunkStorage(io.pravega.storage.extendeds3.ExtendedS3ChunkStorage) HDFSChunkStorage(io.pravega.storage.hdfs.HDFSChunkStorage) S3ChunkStorage(io.pravega.storage.s3.S3ChunkStorage) SyncStorage(io.pravega.segmentstore.storage.SyncStorage) FileSystemChunkStorage(io.pravega.storage.filesystem.FileSystemChunkStorage) ExtendedS3SimpleStorageFactory(io.pravega.storage.extendeds3.ExtendedS3SimpleStorageFactory) S3SimpleStorageFactory(io.pravega.storage.s3.S3SimpleStorageFactory) ExtendedS3ChunkStorage(io.pravega.storage.extendeds3.ExtendedS3ChunkStorage) S3ChunkStorage(io.pravega.storage.s3.S3ChunkStorage) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) StorageFactoryInfo(io.pravega.segmentstore.storage.StorageFactoryInfo) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) S3StorageFactoryCreator(io.pravega.storage.s3.S3StorageFactoryCreator) HDFSStorageFactoryCreator(io.pravega.storage.hdfs.HDFSStorageFactoryCreator) StorageFactoryCreator(io.pravega.segmentstore.storage.StorageFactoryCreator) ExtendedS3StorageFactoryCreator(io.pravega.storage.extendeds3.ExtendedS3StorageFactoryCreator) FileSystemStorageFactoryCreator(io.pravega.storage.filesystem.FileSystemStorageFactoryCreator) S3StorageFactoryCreator(io.pravega.storage.s3.S3StorageFactoryCreator) ExtendedS3StorageFactoryCreator(io.pravega.storage.extendeds3.ExtendedS3StorageFactoryCreator) Cleanup(lombok.Cleanup) ConfigSetup(io.pravega.segmentstore.storage.ConfigSetup)

Example 2 with InMemoryMetadataStore

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

the class StorageFactoryTests method testHDFSStorageFactoryCreator.

@Test
public void testHDFSStorageFactoryCreator() {
    StorageFactoryCreator factoryCreator = new HDFSStorageFactoryCreator();
    val expected = new StorageFactoryInfo[] { StorageFactoryInfo.builder().name("HDFS").storageLayoutType(StorageLayoutType.CHUNKED_STORAGE).build(), StorageFactoryInfo.builder().name("HDFS").storageLayoutType(StorageLayoutType.ROLLING_STORAGE).build() };
    val factoryInfoList = factoryCreator.getStorageFactories();
    Assert.assertEquals(2, factoryInfoList.length);
    Assert.assertArrayEquals(expected, factoryInfoList);
    // Simple Storage
    ConfigSetup configSetup1 = mock(ConfigSetup.class);
    when(configSetup1.getConfig(any())).thenReturn(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, HDFSStorageConfig.builder().build());
    val factory1 = factoryCreator.createFactory(expected[0], configSetup1, executorService());
    Assert.assertTrue(factory1 instanceof HDFSSimpleStorageFactory);
    @Cleanup Storage storage1 = ((HDFSSimpleStorageFactory) factory1).createStorageAdapter(42, new InMemoryMetadataStore(ChunkedSegmentStorageConfig.DEFAULT_CONFIG, executorService()));
    Assert.assertTrue(storage1 instanceof ChunkedSegmentStorage);
    Assert.assertTrue(((ChunkedSegmentStorage) storage1).getChunkStorage() instanceof HDFSChunkStorage);
    // Legacy Storage
    ConfigSetup configSetup2 = mock(ConfigSetup.class);
    when(configSetup2.getConfig(any())).thenReturn(HDFSStorageConfig.builder().build());
    val factory2 = factoryCreator.createFactory(expected[1], configSetup2, executorService());
    Assert.assertTrue(factory2 instanceof HDFSStorageFactory);
    @Cleanup Storage storage2 = factory2.createStorageAdapter();
    Assert.assertTrue(storage2 instanceof AsyncStorageWrapper);
    SyncStorage syncStorage = factory2.createSyncStorage();
    Assert.assertNotNull(syncStorage);
    AssertExtensions.assertThrows("createStorageAdapter should throw UnsupportedOperationException.", () -> factory1.createStorageAdapter(), ex -> ex instanceof UnsupportedOperationException);
}
Also used : lombok.val(lombok.val) SyncStorage(io.pravega.segmentstore.storage.SyncStorage) HDFSChunkStorage(io.pravega.storage.hdfs.HDFSChunkStorage) HDFSStorageFactoryCreator(io.pravega.storage.hdfs.HDFSStorageFactoryCreator) StorageFactoryInfo(io.pravega.segmentstore.storage.StorageFactoryInfo) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) Cleanup(lombok.Cleanup) HDFSSimpleStorageFactory(io.pravega.storage.hdfs.HDFSSimpleStorageFactory) HDFSStorageFactory(io.pravega.storage.hdfs.HDFSStorageFactory) Storage(io.pravega.segmentstore.storage.Storage) ChunkedSegmentStorage(io.pravega.segmentstore.storage.chunklayer.ChunkedSegmentStorage) ExtendedS3ChunkStorage(io.pravega.storage.extendeds3.ExtendedS3ChunkStorage) HDFSChunkStorage(io.pravega.storage.hdfs.HDFSChunkStorage) S3ChunkStorage(io.pravega.storage.s3.S3ChunkStorage) SyncStorage(io.pravega.segmentstore.storage.SyncStorage) FileSystemChunkStorage(io.pravega.storage.filesystem.FileSystemChunkStorage) AsyncStorageWrapper(io.pravega.segmentstore.storage.AsyncStorageWrapper) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) S3StorageFactoryCreator(io.pravega.storage.s3.S3StorageFactoryCreator) HDFSStorageFactoryCreator(io.pravega.storage.hdfs.HDFSStorageFactoryCreator) StorageFactoryCreator(io.pravega.segmentstore.storage.StorageFactoryCreator) ExtendedS3StorageFactoryCreator(io.pravega.storage.extendeds3.ExtendedS3StorageFactoryCreator) FileSystemStorageFactoryCreator(io.pravega.storage.filesystem.FileSystemStorageFactoryCreator) ConfigSetup(io.pravega.segmentstore.storage.ConfigSetup) Test(org.junit.Test)

Example 3 with InMemoryMetadataStore

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

the class ChunkedSegmentStorageTests method testParallelReadRequestsOnSingleSegmentWithReentry.

private void testParallelReadRequestsOnSingleSegmentWithReentry(int numberOfRequests, int threadPoolSize, boolean shouldBlock) throws Exception {
    String testSegmentName = "testSegment";
    // Force rollover after every 2 byte.
    SegmentRollingPolicy policy = new SegmentRollingPolicy(2);
    @Cleanup TestContext testContext = getTestContext(ChunkedSegmentStorageConfig.DEFAULT_CONFIG.toBuilder().indexBlockSize(3).build());
    if (!(testContext.metadataStore instanceof InMemoryMetadataStore)) {
        return;
    }
    CompletableFuture<Void> futureToWaitOn = shouldBlock ? new CompletableFuture<Void>() : CompletableFuture.completedFuture(null);
    // Step 1: Populate dummy system segment segment.
    // Write some data to system segment so that we can read it back in call back.
    val systemSegment = "SystemSegment";
    val hSystem = testContext.chunkedSegmentStorage.create(systemSegment, policy, null).get();
    testContext.chunkedSegmentStorage.write(hSystem, 0, new ByteArrayInputStream(new byte[1]), 1, null).join();
    // Step 2: Create test segment.
    val h = testContext.chunkedSegmentStorage.create(testSegmentName, policy, null).get();
    Assert.assertEquals(h.getSegmentName(), testSegmentName);
    Assert.assertFalse(h.isReadOnly());
    // Step 3: Write some data to test segment.
    long writeAt = 0;
    for (int i = 1; i < 5; i++) {
        testContext.chunkedSegmentStorage.write(h, writeAt, new ByteArrayInputStream(new byte[i]), i, null).join();
        writeAt += i;
    }
    TestUtils.checkSegmentLayout(testContext.metadataStore, testSegmentName, 2, 5);
    TestUtils.checkSegmentBounds(testContext.metadataStore, testSegmentName, 0, 10);
    TestUtils.checkReadIndexEntries(testContext.chunkedSegmentStorage, testContext.metadataStore, testSegmentName, 0, 10, true);
    TestUtils.checkChunksExistInStorage(testContext.chunkStorage, testContext.metadataStore, testSegmentName);
    // Step 4: Setup call backs that read system segment on each read.
    // Set up a call back which will be invoked during get call.
    ((InMemoryMetadataStore) testContext.metadataStore).setReadCallback(transactionData -> {
        // Make sure we don't invoke read for system segment itself.
        if (!transactionData.getKey().equals(systemSegment)) {
            return futureToWaitOn.thenComposeAsync(v -> checkDataReadAsync(systemSegment, testContext, 0, 1, executorService()), executorService()).thenApplyAsync(v -> null, executorService());
        }
        return CompletableFuture.completedFuture(null);
    });
    // Step 5: Read back data concurrently.
    @Cleanup("shutdownNow") ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
    CompletableFuture[] futures = new CompletableFuture[numberOfRequests];
    for (int i = 0; i < numberOfRequests; i++) {
        CompletableFuture<Void> f = testContext.chunkedSegmentStorage.getStreamSegmentInfo(testSegmentName, null).thenComposeAsync(info -> {
            Assert.assertFalse(info.isSealed());
            Assert.assertFalse(info.isDeleted());
            Assert.assertEquals(info.getName(), testSegmentName);
            Assert.assertEquals(info.getLength(), 10);
            Assert.assertEquals(info.getStartOffset(), 0);
            return checkDataReadAsync(testSegmentName, testContext, 0, 10, executor);
        }, executor);
        futures[i] = f;
    }
    if (shouldBlock) {
        futureToWaitOn.complete(null);
    }
    CompletableFuture.allOf(futures).join();
}
Also used : lombok.val(lombok.val) Arrays(java.util.Arrays) Getter(lombok.Getter) StreamSegmentNotExistsException(io.pravega.segmentstore.contracts.StreamSegmentNotExistsException) SegmentRollingPolicy(io.pravega.segmentstore.storage.SegmentRollingPolicy) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) AssertExtensions(io.pravega.test.common.AssertExtensions) Exceptions(io.pravega.common.Exceptions) StorageNotPrimaryException(io.pravega.segmentstore.storage.StorageNotPrimaryException) Cleanup(lombok.Cleanup) Random(java.util.Random) CompletableFuture(java.util.concurrent.CompletableFuture) StorageFullException(io.pravega.segmentstore.storage.StorageFullException) InMemoryTaskQueueManager(io.pravega.segmentstore.storage.mocks.InMemoryTaskQueueManager) ArrayList(java.util.ArrayList) SegmentProperties(io.pravega.segmentstore.contracts.SegmentProperties) HashSet(java.util.HashSet) SegmentMetadata(io.pravega.segmentstore.storage.metadata.SegmentMetadata) StreamSegmentSealedException(io.pravega.segmentstore.contracts.StreamSegmentSealedException) AbstractInMemoryChunkStorage(io.pravega.segmentstore.storage.mocks.AbstractInMemoryChunkStorage) SegmentHandle(io.pravega.segmentstore.storage.SegmentHandle) ByteArrayInputStream(java.io.ByteArrayInputStream) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Timeout(org.junit.rules.Timeout) NoOpChunkStorage(io.pravega.segmentstore.storage.noop.NoOpChunkStorage) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) ChunkMetadata(io.pravega.segmentstore.storage.metadata.ChunkMetadata) StreamSegmentTruncatedException(io.pravega.segmentstore.contracts.StreamSegmentTruncatedException) Longs(com.google.common.primitives.Longs) Executor(java.util.concurrent.Executor) IntentionalException(io.pravega.test.common.IntentionalException) lombok.val(lombok.val) Test(org.junit.Test) UUID(java.util.UUID) Executors(java.util.concurrent.Executors) Slf4j(lombok.extern.slf4j.Slf4j) Rule(org.junit.Rule) StreamSegmentExistsException(io.pravega.segmentstore.contracts.StreamSegmentExistsException) ChunkMetadataStore(io.pravega.segmentstore.storage.metadata.ChunkMetadataStore) ThreadPooledTestSuite(io.pravega.test.common.ThreadPooledTestSuite) BadOffsetException(io.pravega.segmentstore.contracts.BadOffsetException) Preconditions(com.google.common.base.Preconditions) Assert(org.junit.Assert) Futures(io.pravega.common.concurrent.Futures) SegmentRollingPolicy(io.pravega.segmentstore.storage.SegmentRollingPolicy) Cleanup(lombok.Cleanup) CompletableFuture(java.util.concurrent.CompletableFuture) ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService)

Example 4 with InMemoryMetadataStore

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

the class ChunkedSegmentStorageTests method testParallelSegmentOperationsWithReentry.

private void testParallelSegmentOperationsWithReentry(int numberOfRequests, int threadPoolSize, boolean shouldBlock) throws Exception {
    // Force rollover after every 2 byte.
    SegmentRollingPolicy policy = new SegmentRollingPolicy(2);
    @Cleanup TestContext testContext = getTestContext();
    if (!(testContext.metadataStore instanceof InMemoryMetadataStore)) {
        return;
    }
    CompletableFuture<Void> futureToWaitOn = shouldBlock ? new CompletableFuture<Void>() : CompletableFuture.completedFuture(null);
    // Step 1: Populate system segment.
    // Write some data to system segment so that we can read it back in call back.
    val systemSegment = "SystemSegment";
    val h = testContext.chunkedSegmentStorage.create(systemSegment, policy, null).get();
    testContext.chunkedSegmentStorage.write(h, 0, new ByteArrayInputStream(new byte[1]), 1, null).join();
    // Step 2: Setup call backs.
    // Set up a call back which will be invoked during get call.
    ((InMemoryMetadataStore) testContext.metadataStore).setReadCallback(transactionData -> {
        // Make sure we don't invoke read for system segment itself.
        if (!transactionData.getKey().equals(systemSegment)) {
            return futureToWaitOn.thenComposeAsync(v -> checkDataReadAsync(systemSegment, testContext, 0, 1, executorService()), executorService()).thenApplyAsync(v -> null, executorService());
        }
        return CompletableFuture.completedFuture(null);
    });
    // Set up a call back which will be invoked during writeAll call.
    ((InMemoryMetadataStore) testContext.metadataStore).setWriteCallback(transactionDataList -> {
        // Make sure we don't invoke read for system segment itself.
        if (transactionDataList.stream().filter(t -> !t.getKey().equals(systemSegment)).findAny().isPresent()) {
            return futureToWaitOn.thenComposeAsync(v -> checkDataReadAsync(systemSegment, testContext, 0, 1, executorService()), executorService()).thenApplyAsync(v -> null, executorService());
        }
        return CompletableFuture.completedFuture(null);
    });
    // Step 3: Perform operations on multiple segments.
    @Cleanup("shutdownNow") ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
    CompletableFuture[] futures = new CompletableFuture[numberOfRequests];
    for (int i = 0; i < numberOfRequests; i++) {
        String testSegmentName = "test" + i;
        val f = testSimpleScenarioAsync(testSegmentName, policy, testContext, executor);
        futures[i] = f;
    }
    if (shouldBlock) {
        futureToWaitOn.complete(null);
    }
    CompletableFuture.allOf(futures).join();
}
Also used : lombok.val(lombok.val) Arrays(java.util.Arrays) Getter(lombok.Getter) StreamSegmentNotExistsException(io.pravega.segmentstore.contracts.StreamSegmentNotExistsException) SegmentRollingPolicy(io.pravega.segmentstore.storage.SegmentRollingPolicy) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) AssertExtensions(io.pravega.test.common.AssertExtensions) Exceptions(io.pravega.common.Exceptions) StorageNotPrimaryException(io.pravega.segmentstore.storage.StorageNotPrimaryException) Cleanup(lombok.Cleanup) Random(java.util.Random) CompletableFuture(java.util.concurrent.CompletableFuture) StorageFullException(io.pravega.segmentstore.storage.StorageFullException) InMemoryTaskQueueManager(io.pravega.segmentstore.storage.mocks.InMemoryTaskQueueManager) ArrayList(java.util.ArrayList) SegmentProperties(io.pravega.segmentstore.contracts.SegmentProperties) HashSet(java.util.HashSet) SegmentMetadata(io.pravega.segmentstore.storage.metadata.SegmentMetadata) StreamSegmentSealedException(io.pravega.segmentstore.contracts.StreamSegmentSealedException) AbstractInMemoryChunkStorage(io.pravega.segmentstore.storage.mocks.AbstractInMemoryChunkStorage) SegmentHandle(io.pravega.segmentstore.storage.SegmentHandle) ByteArrayInputStream(java.io.ByteArrayInputStream) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Timeout(org.junit.rules.Timeout) NoOpChunkStorage(io.pravega.segmentstore.storage.noop.NoOpChunkStorage) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) ChunkMetadata(io.pravega.segmentstore.storage.metadata.ChunkMetadata) StreamSegmentTruncatedException(io.pravega.segmentstore.contracts.StreamSegmentTruncatedException) Longs(com.google.common.primitives.Longs) Executor(java.util.concurrent.Executor) IntentionalException(io.pravega.test.common.IntentionalException) lombok.val(lombok.val) Test(org.junit.Test) UUID(java.util.UUID) Executors(java.util.concurrent.Executors) Slf4j(lombok.extern.slf4j.Slf4j) Rule(org.junit.Rule) StreamSegmentExistsException(io.pravega.segmentstore.contracts.StreamSegmentExistsException) ChunkMetadataStore(io.pravega.segmentstore.storage.metadata.ChunkMetadataStore) ThreadPooledTestSuite(io.pravega.test.common.ThreadPooledTestSuite) BadOffsetException(io.pravega.segmentstore.contracts.BadOffsetException) Preconditions(com.google.common.base.Preconditions) Assert(org.junit.Assert) Futures(io.pravega.common.concurrent.Futures) SegmentRollingPolicy(io.pravega.segmentstore.storage.SegmentRollingPolicy) Cleanup(lombok.Cleanup) CompletableFuture(java.util.concurrent.CompletableFuture) ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService)

Example 5 with InMemoryMetadataStore

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

the class ChunkedSegmentStorageTests method testWritesWithFlakyMetadataStore.

public void testWritesWithFlakyMetadataStore(int failFrequency, int length) throws Exception {
    String testSegmentName = "foo";
    @Cleanup TestContext testContext = getTestContext(ChunkedSegmentStorageConfig.DEFAULT_CONFIG.toBuilder().lazyCommitEnabled(false).build());
    val invocationCount = new AtomicInteger(0);
    val testMetadataStore = (InMemoryMetadataStore) testContext.metadataStore;
    testMetadataStore.setMaxEntriesInTxnBuffer(1);
    testMetadataStore.setWriteCallback(dummy -> {
        if (invocationCount.incrementAndGet() % failFrequency == 0) {
            return CompletableFuture.failedFuture(new IntentionalException("Intentional"));
        }
        return CompletableFuture.completedFuture(null);
    });
    val h = testContext.chunkedSegmentStorage.create(testSegmentName, null).get();
    byte[] data = populate(100);
    int currentOffset = 0;
    SegmentMetadata expectedSegmentMetadata = TestUtils.getSegmentMetadata(testContext.metadataStore, testSegmentName);
    ChunkMetadata expectedChunkMetadata = TestUtils.getChunkMetadata(testContext.metadataStore, expectedSegmentMetadata.getLastChunk());
    testMetadataStore.evictAllEligibleEntriesFromBuffer();
    testMetadataStore.evictFromCache();
    while (currentOffset < data.length) {
        try {
            int toWrite = Math.min(length, data.length - currentOffset);
            expectedSegmentMetadata = TestUtils.getSegmentMetadata(testContext.metadataStore, testSegmentName);
            expectedChunkMetadata = TestUtils.getChunkMetadata(testContext.metadataStore, expectedSegmentMetadata.getLastChunk());
            testContext.chunkedSegmentStorage.write(h, currentOffset, new ByteArrayInputStream(data, currentOffset, toWrite), toWrite, null).get();
            currentOffset += toWrite;
        } catch (Exception e) {
            if (!(Exceptions.unwrap(e) instanceof IntentionalException)) {
                throw e;
            }
            val actual = TestUtils.getSegmentMetadata(testContext.metadataStore, testSegmentName);
            val actualChunkMetadata = TestUtils.getChunkMetadata(testContext.metadataStore, expectedSegmentMetadata.getLastChunk());
            Assert.assertEquals(expectedSegmentMetadata, actual);
            Assert.assertEquals(expectedChunkMetadata, actualChunkMetadata);
        } finally {
            val info = testContext.chunkedSegmentStorage.getStreamSegmentInfo(testSegmentName, null).get();
            Assert.assertEquals(info.getLength(), currentOffset);
        }
    }
    testMetadataStore.setWriteCallback(null);
    checkDataRead(testSegmentName, testContext, 0, data.length, data);
}
Also used : lombok.val(lombok.val) Cleanup(lombok.Cleanup) IntentionalException(io.pravega.test.common.IntentionalException) StreamSegmentNotExistsException(io.pravega.segmentstore.contracts.StreamSegmentNotExistsException) StorageNotPrimaryException(io.pravega.segmentstore.storage.StorageNotPrimaryException) StorageFullException(io.pravega.segmentstore.storage.StorageFullException) StreamSegmentSealedException(io.pravega.segmentstore.contracts.StreamSegmentSealedException) StreamSegmentTruncatedException(io.pravega.segmentstore.contracts.StreamSegmentTruncatedException) IntentionalException(io.pravega.test.common.IntentionalException) StreamSegmentExistsException(io.pravega.segmentstore.contracts.StreamSegmentExistsException) BadOffsetException(io.pravega.segmentstore.contracts.BadOffsetException) SegmentMetadata(io.pravega.segmentstore.storage.metadata.SegmentMetadata) ChunkMetadata(io.pravega.segmentstore.storage.metadata.ChunkMetadata) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ByteArrayInputStream(java.io.ByteArrayInputStream) InMemoryMetadataStore(io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore)

Aggregations

InMemoryMetadataStore (io.pravega.segmentstore.storage.mocks.InMemoryMetadataStore)33 lombok.val (lombok.val)30 Test (org.junit.Test)25 Cleanup (lombok.Cleanup)20 BaseMetadataStore (io.pravega.segmentstore.storage.metadata.BaseMetadataStore)11 NoOpChunkStorage (io.pravega.segmentstore.storage.noop.NoOpChunkStorage)11 IntentionalException (io.pravega.test.common.IntentionalException)11 ByteArrayInputStream (java.io.ByteArrayInputStream)11 InMemoryTaskQueueManager (io.pravega.segmentstore.storage.mocks.InMemoryTaskQueueManager)10 StorageFullException (io.pravega.segmentstore.storage.StorageFullException)9 StorageNotPrimaryException (io.pravega.segmentstore.storage.StorageNotPrimaryException)9 MockStorageMetadata (io.pravega.segmentstore.storage.mocks.MockStorageMetadata)9 CompletableFuture (java.util.concurrent.CompletableFuture)8 CompletionException (java.util.concurrent.CompletionException)8 SegmentRollingPolicy (io.pravega.segmentstore.storage.SegmentRollingPolicy)6 StorageMetadataException (io.pravega.segmentstore.storage.metadata.StorageMetadataException)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 StorageMetadataVersionMismatchException (io.pravega.segmentstore.storage.metadata.StorageMetadataVersionMismatchException)5 StorageMetadataWritesFencedOutException (io.pravega.segmentstore.storage.metadata.StorageMetadataWritesFencedOutException)5 IOException (java.io.IOException)5