Search in sources :

Example 1 with SegmentArchiveManager

use of org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveManager 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)

Aggregations

Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 UUID (java.util.UUID)1 FileStoreMonitorAdapter (org.apache.jackrabbit.oak.segment.spi.monitor.FileStoreMonitorAdapter)1 IOMonitorAdapter (org.apache.jackrabbit.oak.segment.spi.monitor.IOMonitorAdapter)1 SegmentArchiveManager (org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveManager)1 SegmentArchiveWriter (org.apache.jackrabbit.oak.segment.spi.persistence.SegmentArchiveWriter)1 Test (org.junit.Test)1