use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.
the class RevisionsCommandTest method sweep.
@Test
public void sweep() throws Exception {
int clusterId = ns.getClusterId();
String output = captureSystemErr(new Sweep(clusterId));
assertThat(output, containsString("cannot sweep revisions for active clusterId"));
output = captureSystemErr(new Sweep(0));
assertThat(output, containsString("clusterId option is required"));
output = captureSystemErr(new Sweep(99));
assertThat(output, containsString("store does not have changes with clusterId"));
ns.dispose();
output = captureSystemOut(new Sweep(clusterId));
assertThat(output, containsString("Revision sweep not needed for clusterId"));
// remove the sweep revision to force a sweep run
MongoConnection c = connectionFactory.getConnection();
DocumentMK.Builder builder = builderProvider.newBuilder().setMongoDB(c.getDB());
DocumentStore store = builder.getDocumentStore();
UpdateOp op = new UpdateOp(getIdFromPath("/"), false);
op.removeMapEntry("_sweepRev", new Revision(0, 0, clusterId));
assertNotNull(store.findAndUpdate(Collection.NODES, op));
output = captureSystemOut(new Sweep(clusterId));
assertThat(output, containsString("Updated sweep revision to"));
}
use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.
the class RevisionsCommandTest method createDocumentNodeStore.
private DocumentNodeStore createDocumentNodeStore() {
MongoConnection c = connectionFactory.getConnection();
MongoUtils.dropCollections(c.getDB().getName());
return builderProvider.newBuilder().setMongoDB(c.getDB()).getNodeStore();
}
use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.
the class Utils method createDocumentMKBuilder.
@CheckForNull
static DocumentMK.Builder createDocumentMKBuilder(NodeStoreOptions options, Closer closer) throws IOException {
String src = options.getStoreArg();
if (src == null || src.length() == 0) {
options.printHelpOn(System.err);
System.exit(1);
}
DocumentMK.Builder builder = new DocumentMK.Builder();
if (src.startsWith(MongoURI.MONGODB_PREFIX)) {
MongoClientURI uri = new MongoClientURI(src);
if (uri.getDatabase() == null) {
System.err.println("Database missing in MongoDB URI: " + uri.getURI());
System.exit(1);
}
MongoConnection mongo = new MongoConnection(uri.getURI());
closer.register(asCloseable(mongo));
builder.setMongoDB(mongo.getDB());
} else if (src.startsWith("jdbc")) {
DataSource ds = RDBDataSourceFactory.forJdbcUrl(src, options.getRDBJDBCUser(), options.getRDBJDBCPassword());
builder.setRDBConnection(ds);
} else {
return null;
}
builder.setLeaseCheck(false).setClusterId(options.getClusterId());
if (options.disableBranchesSpec()) {
builder.disableBranches();
}
int cacheSize = options.getCacheSize();
if (cacheSize != 0) {
builder.memoryCacheSize(cacheSize * MB);
}
return builder;
}
Aggregations