use of org.apache.jackrabbit.oak.plugins.document.VersionGCSupport 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;
}
Aggregations