Search in sources :

Example 1 with MapDBMapFactory

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

the class RecoveryCommand method execute.

@Override
public void execute(String... args) throws Exception {
    MapFactory.setInstance(new MapDBMapFactory());
    Closer closer = Closer.create();
    String h = "recovery mongodb://host:port/database { dryRun }";
    try {
        NodeStore store = Utils.bootstrapNodeStore(args, closer, h);
        if (!(store instanceof DocumentNodeStore)) {
            System.err.println("Recovery only available for DocumentNodeStore");
            System.exit(1);
        }
        DocumentNodeStore dns = (DocumentNodeStore) store;
        if (!(dns.getDocumentStore() instanceof MongoDocumentStore)) {
            System.err.println("Recovery only available for MongoDocumentStore");
            System.exit(1);
        }
        MongoDocumentStore docStore = (MongoDocumentStore) dns.getDocumentStore();
        LastRevRecoveryAgent agent = new LastRevRecoveryAgent(dns);
        MongoMissingLastRevSeeker seeker = new MongoMissingLastRevSeeker(docStore, dns.getClock());
        CloseableIterable<NodeDocument> docs = seeker.getCandidates(0);
        closer.register(docs);
        boolean dryRun = Arrays.asList(args).contains("dryRun");
        agent.recover(docs, dns.getClusterId(), dryRun);
    } catch (Throwable e) {
        throw closer.rethrow(e);
    } finally {
        closer.close();
    }
}
Also used : Closer(com.google.common.io.Closer) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) NodeStore(org.apache.jackrabbit.oak.spi.state.NodeStore) MapDBMapFactory(org.apache.jackrabbit.oak.plugins.document.util.MapDBMapFactory) DocumentNodeStore(org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore) LastRevRecoveryAgent(org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent) NodeDocument(org.apache.jackrabbit.oak.plugins.document.NodeDocument) MongoDocumentStore(org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore) MongoMissingLastRevSeeker(org.apache.jackrabbit.oak.plugins.document.mongo.MongoMissingLastRevSeeker)

Aggregations

Closer (com.google.common.io.Closer)1 DocumentNodeStore (org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore)1 LastRevRecoveryAgent (org.apache.jackrabbit.oak.plugins.document.LastRevRecoveryAgent)1 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)1 MongoDocumentStore (org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore)1 MongoMissingLastRevSeeker (org.apache.jackrabbit.oak.plugins.document.mongo.MongoMissingLastRevSeeker)1 MapDBMapFactory (org.apache.jackrabbit.oak.plugins.document.util.MapDBMapFactory)1 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)1