use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore in project jackrabbit-oak by apache.
the class DocumentNodeStoreHelper method getDocuments.
private static Iterable<NodeDocument> getDocuments(DocumentStore store) {
if (store instanceof MongoDocumentStore) {
// optimized implementation for MongoDocumentStore
final MongoDocumentStore mds = (MongoDocumentStore) store;
DBCollection dbCol = MongoDocumentStoreHelper.getDBCollection(mds, Collection.NODES);
DBObject query = QueryBuilder.start(NodeDocument.HAS_BINARY_FLAG).is(NodeDocument.HAS_BINARY_VAL).get();
DBCursor cursor = dbCol.find(query);
return Iterables.transform(cursor, new Function<DBObject, NodeDocument>() {
@Nullable
@Override
public NodeDocument apply(DBObject input) {
return MongoDocumentStoreHelper.convertFromDBObject(mds, Collection.NODES, input);
}
});
} else {
return Utils.getSelectedDocuments(store, NodeDocument.HAS_BINARY_FLAG, NodeDocument.HAS_BINARY_VAL);
}
}
use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore in project jackrabbit-oak by apache.
the class RepairCommand method execute.
@Override
public void execute(String... args) throws Exception {
Closer closer = Closer.create();
String h = "repair mongodb://host:port/database path";
try {
NodeStore store = Utils.bootstrapNodeStore(args, closer, h);
if (!(store instanceof DocumentNodeStore)) {
System.err.println("Repair only available for DocumentNodeStore");
System.exit(1);
}
DocumentNodeStore dns = (DocumentNodeStore) store;
if (!(dns.getDocumentStore() instanceof MongoDocumentStore)) {
System.err.println("Repair only available for MongoDocumentStore");
System.exit(1);
}
MongoDocumentStore docStore = (MongoDocumentStore) dns.getDocumentStore();
String path = args[args.length - 1];
MongoDocumentStoreHelper.repair(docStore, path);
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
use of org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore 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();
}
}
Aggregations