use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.
the class NodeStoreFixtureProvider method configureDocumentMk.
private static NodeStore configureDocumentMk(Options options, BlobStore blobStore, StatisticsProvider statisticsProvider, Closer closer, Whiteboard wb, boolean readOnly) throws UnknownHostException {
DocumentMK.Builder builder = new DocumentMK.Builder();
if (blobStore != null) {
builder.setBlobStore(blobStore);
}
DocumentNodeStoreOptions docStoreOpts = options.getOptionBean(DocumentNodeStoreOptions.class);
builder.setClusterId(docStoreOpts.getClusterId());
builder.setStatisticsProvider(statisticsProvider);
if (readOnly) {
builder.setReadOnlyMode();
}
int cacheSize = docStoreOpts.getCacheSize();
if (cacheSize != 0) {
builder.memoryCacheSize(cacheSize * MB);
}
if (docStoreOpts.disableBranchesSpec()) {
builder.disableBranches();
}
CommonOptions commonOpts = options.getOptionBean(CommonOptions.class);
if (docStoreOpts.isCacheDistributionDefined()) {
builder.memoryCacheDistribution(docStoreOpts.getNodeCachePercentage(), docStoreOpts.getPrevDocCachePercentage(), docStoreOpts.getChildrenCachePercentage(), docStoreOpts.getDiffCachePercentage());
}
if (commonOpts.isMongo()) {
MongoClientURI uri = new MongoClientURI(commonOpts.getStoreArg());
if (uri.getDatabase() == null) {
System.err.println("Database missing in MongoDB URI: " + uri.getURI());
System.exit(1);
}
MongoConnection mongo = new MongoConnection(uri.getURI());
wb.register(MongoConnection.class, mongo, Collections.emptyMap());
closer.register(mongo::close);
builder.setMongoDB(mongo.getDB());
} else if (commonOpts.isRDB()) {
RDBStoreOptions rdbOpts = options.getOptionBean(RDBStoreOptions.class);
DataSource ds = RDBDataSourceFactory.forJdbcUrl(commonOpts.getStoreArg(), rdbOpts.getUser(), rdbOpts.getPassword());
wb.register(DataSource.class, ds, Collections.emptyMap());
builder.setRDBConnection(ds);
}
return builder.getNodeStore();
}
use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.
the class RevisionsCommandTest method reset.
@Test
public void reset() throws Exception {
ns.getVersionGarbageCollector().gc(1, TimeUnit.HOURS);
Document doc = ns.getDocumentStore().find(Collection.SETTINGS, "versionGC");
assertNotNull(doc);
ns.dispose();
String output = captureSystemOut(new RevisionsCmd("reset"));
assertTrue(output.contains("resetting recommendations and statistics"));
MongoConnection c = connectionFactory.getConnection();
ns = builderProvider.newBuilder().setMongoDB(c.getDB()).getNodeStore();
doc = ns.getDocumentStore().find(Collection.SETTINGS, "versionGC");
assertNull(doc);
}
use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.
the class UnlockUpgradeCommandTest method resetFormatVersion.
private void resetFormatVersion(FormatVersion v) {
MongoConnection c = connectionFactory.getConnection();
DocumentStore s = new MongoDocumentStore(c.getDB(), new DocumentMK.Builder());
s.remove(Collection.SETTINGS, "version");
assertTrue(v.writeTo(s));
s.dispose();
}
use of org.apache.jackrabbit.oak.plugins.document.util.MongoConnection in project jackrabbit-oak by apache.
the class UnlockUpgradeCommandTest 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 DocumentMongoFixture method getDb.
protected DB getDb(String suffix) throws UnknownHostException {
String dbName = new MongoClientURI(uri).getDatabase();
MongoConnection connection = new MongoConnection(uri);
return connection.getDB(dbName + "-" + suffix);
}
Aggregations