Search in sources :

Example 1 with IOMonitorAdapter

use of org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter in project jackrabbit-oak by apache.

the class AzureTarFilesTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    container = azurite.getContainer("oak-test");
    tarFiles = TarFiles.builder().withDirectory(folder.newFolder()).withTarRecovery((id, data, recovery) -> {
    // Intentionally left blank
    }).withIOMonitor(new IOMonitorAdapter()).withFileStoreMonitor(new FileStoreMonitorAdapter()).withMaxFileSize(MAX_FILE_SIZE).withPersistence(new AzurePersistence(container.getDirectoryReference("oak"))).build();
}
Also used : FileStoreMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitorAdapter) IOMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter) Before(org.junit.Before)

Example 2 with IOMonitorAdapter

use of org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter in project jackrabbit-oak by apache.

the class AzureTarFileTest method setUp.

@Before
@Override
public void setUp() throws IOException {
    try {
        container = azurite.getContainer("oak-test");
        archiveManager = new AzurePersistence(container.getDirectoryReference("oak")).createArchiveManager(true, new IOMonitorAdapter(), new FileStoreMonitorAdapter());
    } catch (StorageException | InvalidKeyException | URISyntaxException e) {
        throw new IOException(e);
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) FileStoreMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitorAdapter) InvalidKeyException(java.security.InvalidKeyException) StorageException(com.microsoft.azure.storage.StorageException) IOMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter) Before(org.junit.Before)

Example 3 with IOMonitorAdapter

use of org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter in project jackrabbit-oak by apache.

the class AzureTarWriterTest method setUp.

@Before
@Override
public void setUp() throws IOException {
    try {
        monitor = new TestFileStoreMonitor();
        container = azurite.getContainer("oak-test");
        archiveManager = new AzurePersistence(container.getDirectoryReference("oak")).createArchiveManager(true, new IOMonitorAdapter(), monitor);
    } catch (StorageException | InvalidKeyException | URISyntaxException e) {
        throw new IOException(e);
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) InvalidKeyException(java.security.InvalidKeyException) StorageException(com.microsoft.azure.storage.StorageException) IOMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter) Before(org.junit.Before)

Example 4 with IOMonitorAdapter

use of org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter in project jackrabbit-oak by apache.

the class AzureArchiveManagerTest method testRecovery.

@Test
public void testRecovery() throws StorageException, URISyntaxException, IOException {
    SegmentArchiveManager manager = new AzurePersistence(container.getDirectoryReference("oak")).createArchiveManager(false, new IOMonitorAdapter(), new FileStoreMonitorAdapter());
    SegmentArchiveWriter writer = manager.create("data00000a.tar");
    List<UUID> uuids = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        UUID u = UUID.randomUUID();
        writer.writeSegment(u.getMostSignificantBits(), u.getLeastSignificantBits(), new byte[10], 0, 10, 0, 0, false);
        uuids.add(u);
    }
    writer.flush();
    writer.close();
    container.getBlockBlobReference("oak/data00000a.tar/0005." + uuids.get(5).toString()).delete();
    LinkedHashMap<UUID, byte[]> recovered = new LinkedHashMap<>();
    manager.recoverEntries("data00000a.tar", recovered);
    assertEquals(uuids.subList(0, 5), newArrayList(recovered.keySet()));
}
Also used : SegmentArchiveWriter(org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveWriter) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) FileStoreMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitorAdapter) UUID(java.util.UUID) SegmentArchiveManager(org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveManager) IOMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 5 with IOMonitorAdapter

use of org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter in project jackrabbit-oak by apache.

the class UpgradeIT method checkSegmentVersion.

private void checkSegmentVersion(@Nonnull SegmentVersion version) throws IOException {
    try (TarFiles tarFiles = TarFiles.builder().withDirectory(fileStoreHome.getRoot()).withTarRecovery((_1, _2, _3) -> fail("Unexpected recovery")).withIOMonitor(new IOMonitorAdapter()).withReadOnly().build()) {
        for (SegmentData segmentData : getSegments(tarFiles)) {
            SegmentVersion actualVersion = SegmentVersion.fromByte(segmentData.getVersion());
            assertEquals(format("Segment version mismatch. Expected %s, found %s", version, actualVersion), version, actualVersion);
        }
    }
}
Also used : IOMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter) Iterables.transform(com.google.common.collect.Iterables.transform) SegmentVersion(org.apache.jackrabbit.oak.segment.SegmentVersion) OS_NAME(com.google.common.base.StandardSystemProperty.OS_NAME) MINUTES(java.util.concurrent.TimeUnit.MINUTES) FileStoreBuilder.fileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder) TarFiles(org.apache.jackrabbit.oak.segment.file.tar.TarFiles) SegmentData(org.apache.jackrabbit.oak.segment.data.SegmentData) Compact(org.apache.jackrabbit.oak.segment.tool.Compact) Assert.fail(org.junit.Assert.fail) Nonnull(javax.annotation.Nonnull) Before(org.junit.Before) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) String.format(java.lang.String.format) File(java.io.File) Rule(org.junit.Rule) LocalManifestFile(org.apache.jackrabbit.oak.segment.file.LocalManifestFile) ManifestChecker.newManifestChecker(org.apache.jackrabbit.oak.segment.file.ManifestChecker.newManifestChecker) V_12(org.apache.jackrabbit.oak.segment.SegmentVersion.V_12) V_13(org.apache.jackrabbit.oak.segment.SegmentVersion.V_13) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) SegmentData.newSegmentData(org.apache.jackrabbit.oak.segment.data.SegmentData.newSegmentData) TarFiles(org.apache.jackrabbit.oak.segment.file.tar.TarFiles) SegmentData(org.apache.jackrabbit.oak.segment.data.SegmentData) SegmentData.newSegmentData(org.apache.jackrabbit.oak.segment.data.SegmentData.newSegmentData) IOMonitorAdapter(org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter) SegmentVersion(org.apache.jackrabbit.oak.segment.SegmentVersion)

Aggregations

IOMonitorAdapter (org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter)5 Before (org.junit.Before)4 IOException (java.io.IOException)3 FileStoreMonitorAdapter (org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitorAdapter)3 StorageException (com.microsoft.azure.storage.StorageException)2 URISyntaxException (java.net.URISyntaxException)2 InvalidKeyException (java.security.InvalidKeyException)2 Test (org.junit.Test)2 OS_NAME (com.google.common.base.StandardSystemProperty.OS_NAME)1 Iterables.transform (com.google.common.collect.Iterables.transform)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 File (java.io.File)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 UUID (java.util.UUID)1 MINUTES (java.util.concurrent.TimeUnit.MINUTES)1 Nonnull (javax.annotation.Nonnull)1 SegmentVersion (org.apache.jackrabbit.oak.segment.SegmentVersion)1 V_12 (org.apache.jackrabbit.oak.segment.SegmentVersion.V_12)1