Search in sources :

Example 46 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class FileStoreBackupTest method testBackup.

@Test
public void testBackup() throws Exception {
    FileStore source = newFileStore(src);
    SegmentNodeStore store = SegmentNodeStoreBuilders.builder(source).build();
    FileStoreBackup fsb = new FileStoreBackupImpl();
    try {
        init(store);
        source.flush();
        fsb.backup(source.getReader(), source.getRevisions(), destination);
        compare(source, destination);
        addTestContent(store);
        source.flush();
        fsb.backup(source.getReader(), source.getRevisions(), destination);
        compare(source, destination);
        source.compactFull();
        fsb.cleanup(source);
        fsb.backup(source.getReader(), source.getRevisions(), destination);
        compare(source, destination);
    } finally {
        source.close();
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) FileStoreBackupImpl(org.apache.jackrabbit.oak.backup.impl.FileStoreBackupImpl) Test(org.junit.Test)

Example 47 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class BlobIdRecordTest method longReferencesShouldHaveBlobIdType.

@Test
public void longReferencesShouldHaveBlobIdType() throws Exception {
    try (FileStore ss = newFileStore(new LongIdMappingBlobStore())) {
        SegmentWriter sw = defaultSegmentWriterBuilder("test").build(ss);
        byte[] content = new byte[Segment.MEDIUM_LIMIT + 1];
        SegmentBlob sb = new SegmentBlob(ss.getBlobStore(), sw.writeBlob(new ArrayBasedBlob(content)));
        assertRecordTypeEquals(sb, RecordType.BLOB_ID);
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) ArrayBasedBlob(org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob) Test(org.junit.Test)

Example 48 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class SegmentTarFixture method getOak.

@Override
public Oak getOak(int clusterId) throws Exception {
    FileStoreBuilder fileStoreBuilder = fileStoreBuilder(parentPath).withMaxFileSize(maxFileSize).withSegmentCacheSize(segmentCacheSize).withMemoryMapping(memoryMapping);
    if (azureConnectionString != null) {
        CloudStorageAccount cloud = CloudStorageAccount.parse(azureConnectionString);
        CloudBlobContainer container = cloud.createCloudBlobClient().getContainerReference(azureContainerName);
        container.createIfNotExists();
        CloudBlobDirectory directory = container.getDirectoryReference(azureRootPath);
        fileStoreBuilder.withCustomPersistence(new AzurePersistence(directory));
    }
    if (useBlobStore) {
        FileDataStore fds = new FileDataStore();
        fds.setMinRecordLength(4092);
        fds.init(parentPath.getAbsolutePath());
        BlobStore blobStore = new DataStoreBlobStore(fds);
        fileStoreBuilder.withBlobStore(blobStore);
    }
    FileStore fs = fileStoreBuilder.build();
    return newOak(SegmentNodeStoreBuilders.builder(fs).build());
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) AzurePersistence(org.apache.jackrabbit.oak.segment.azure.AzurePersistence) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) CloudBlobDirectory(com.microsoft.azure.storage.blob.CloudBlobDirectory) CloudBlobContainer(com.microsoft.azure.storage.blob.CloudBlobContainer) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore) BlobStore(org.apache.jackrabbit.oak.spi.blob.BlobStore) DataStoreBlobStore(org.apache.jackrabbit.oak.plugins.blob.datastore.DataStoreBlobStore)

Example 49 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class RepeatedRepositorySidegradeTest method upgradeRepository.

@Before
public synchronized void upgradeRepository() throws Exception {
    if (!upgradeComplete) {
        final File sourceDir = new File(getTestDirectory(), "jackrabbit2");
        sourceDir.mkdirs();
        FileStore fileStore = fileStoreBuilder(sourceDir).build();
        SegmentNodeStore segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        RepositoryImpl repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        Session session = repository.login(CREDENTIALS);
        try {
            createSourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        final NodeStore target = getTargetNodeStore();
        doUpgradeRepository(sourceDir, target, false);
        fileStore = fileStoreBuilder(sourceDir).build();
        segmentNodeStore = SegmentNodeStoreBuilders.builder(fileStore).build();
        repository = (RepositoryImpl) new Jcr(new Oak(segmentNodeStore)).createRepository();
        session = repository.login(CREDENTIALS);
        try {
            modifySourceContent(session);
        } finally {
            session.save();
            session.logout();
            repository.shutdown();
            fileStore.close();
        }
        doUpgradeRepository(sourceDir, target, true);
        upgradeComplete = true;
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) RepositoryImpl(org.apache.jackrabbit.oak.jcr.repository.RepositoryImpl) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Oak(org.apache.jackrabbit.oak.Oak) SegmentNodeStore(org.apache.jackrabbit.oak.segment.SegmentNodeStore) File(java.io.File) Session(javax.jcr.Session) Before(org.junit.Before)

Example 50 with FileStore

use of org.apache.jackrabbit.oak.segment.file.FileStore in project jackrabbit-oak by apache.

the class Compact method compact.

private void compact() throws IOException, InvalidFileStoreVersionException {
    try (FileStore store = newFileStore()) {
        store.compact();
    }
    System.out.println("    -> cleaning up");
    try (FileStore store = newFileStore()) {
        store.cleanup();
        File journal = new File(path, "journal.log");
        String head;
        try (JournalReader journalReader = new JournalReader(journal)) {
            head = journalReader.next().getRevision() + " root " + System.currentTimeMillis() + "\n";
        }
        try (RandomAccessFile journalFile = new RandomAccessFile(journal, "rw")) {
            System.out.println("    -> writing new " + journal.getName() + ": " + head);
            journalFile.setLength(0);
            journalFile.writeBytes(head);
            journalFile.getChannel().force(false);
        }
    }
}
Also used : FileStore(org.apache.jackrabbit.oak.segment.file.FileStore) RandomAccessFile(java.io.RandomAccessFile) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) JournalReader(org.apache.jackrabbit.oak.segment.file.JournalReader)

Aggregations

FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)106 Test (org.junit.Test)70 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)41 File (java.io.File)25 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)25 StandbyClientSync (org.apache.jackrabbit.oak.segment.standby.client.StandbyClientSync)18 StandbyServerSync (org.apache.jackrabbit.oak.segment.standby.server.StandbyServerSync)18 IOException (java.io.IOException)17 SegmentNodeStore (org.apache.jackrabbit.oak.segment.SegmentNodeStore)15 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)13 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)13 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)12 TemporaryFileStore (org.apache.jackrabbit.oak.segment.test.TemporaryFileStore)11 Blob (org.apache.jackrabbit.oak.api.Blob)10 DefaultStatisticsProvider (org.apache.jackrabbit.oak.stats.DefaultStatisticsProvider)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)9 Before (org.junit.Before)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)8 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)7