Search in sources :

Example 1 with VersionGCOptions

use of org.apache.jackrabbit.oak.plugins.document.VersionGCOptions in project jackrabbit-oak by apache.

the class RevisionsCommand method bootstrapVGC.

private VersionGarbageCollector bootstrapVGC(RevisionsOptions options, Closer closer) throws IOException {
    DocumentMK.Builder builder = createDocumentMKBuilder(options, closer);
    if (builder == null) {
        System.err.println("revisions mode only available for DocumentNodeStore");
        System.exit(1);
    }
    // create a VersionGCSupport while builder is read-write
    VersionGCSupport gcSupport = createVersionGCSupport(builder);
    // check for matching format version
    FormatVersion version = versionOf(gcSupport.getDocumentStore());
    if (!DocumentNodeStore.VERSION.equals(version)) {
        System.err.println("Incompatible versions. This oak-run is " + DocumentNodeStore.VERSION + ", while the store is " + version);
        System.exit(1);
    }
    // set it read-only before the DocumentNodeStore is created
    // this prevents the DocumentNodeStore from writing a new
    // clusterId to the clusterNodes and nodes collections
    builder.setReadOnlyMode();
    // create a version GC that operates on a read-only DocumentNodeStore
    // and a GC support with a writable DocumentStore
    VersionGarbageCollector gc = createVersionGC(builder.getNodeStore(), gcSupport);
    VersionGCOptions gcOptions = gc.getOptions();
    gcOptions = gcOptions.withDelayFactor(options.getDelay());
    if (options.runOnce()) {
        gcOptions = gcOptions.withMaxIterations(1);
    }
    if (options.getLimit() >= 0) {
        gcOptions = gcOptions.withCollectLimit(options.getLimit());
    }
    gc.setOptions(gcOptions);
    return gc;
}
Also used : DocumentNodeStoreHelper.createVersionGCSupport(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreHelper.createVersionGCSupport) VersionGCSupport(org.apache.jackrabbit.oak.plugins.document.VersionGCSupport) VersionGarbageCollector(org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector) VersionGCOptions(org.apache.jackrabbit.oak.plugins.document.VersionGCOptions) DocumentMK(org.apache.jackrabbit.oak.plugins.document.DocumentMK) FormatVersion(org.apache.jackrabbit.oak.plugins.document.FormatVersion)

Aggregations

DocumentMK (org.apache.jackrabbit.oak.plugins.document.DocumentMK)1 DocumentNodeStoreHelper.createVersionGCSupport (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreHelper.createVersionGCSupport)1 FormatVersion (org.apache.jackrabbit.oak.plugins.document.FormatVersion)1 VersionGCOptions (org.apache.jackrabbit.oak.plugins.document.VersionGCOptions)1 VersionGCSupport (org.apache.jackrabbit.oak.plugins.document.VersionGCSupport)1 VersionGarbageCollector (org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector)1