use of com.mongodb.DBAddress in project sling by apache.
the class MongoDBResourceProviderFactory method activate.
@Activate
protected void activate(final Map<String, Object> props) throws Exception {
final String[] roots = PropertiesUtil.toStringArray(props.get(ResourceProvider.ROOTS));
if (roots == null || roots.length == 0) {
throw new Exception("Roots configuration is missing.");
}
if (roots.length > 1) {
throw new Exception("Only a single root should be configured.");
}
if (roots[0] == null || roots[0].trim().length() == 0) {
throw new Exception("Roots configuration is missing.");
}
final String host = PropertiesUtil.toString(props.get(PROP_HOST), DEFAULT_HOST);
final int port = PropertiesUtil.toInteger(props.get(PROP_PORT), DEFAULT_PORT);
final String db = PropertiesUtil.toString(props.get(PROP_DB), DEFAULT_DB);
logger.info("Starting MongoDB resource provider with host={}, port={}, db={}", new Object[] { host, port, db });
final DBAddress address = new DBAddress(host, port, db);
final MongoOptions options = new MongoOptions();
options.connectionsPerHost = PropertiesUtil.toInteger(props.get(PROP_NUM_CONNECTIONS), DEFAULT_NUMCONNECTIONS);
options.threadsAllowedToBlockForConnectionMultiplier = PropertiesUtil.toInteger(props.get(PROP_THREAD_MULTIPLIER), DEFAULT_THREAD_MULTIPLIER);
final Mongo m = new Mongo(address, options);
final DB database = m.getDB(db);
logger.info("Connected to database {}", database);
this.context = new MongoDBContext(database, roots[0], PropertiesUtil.toStringArray(props.get(PROP_FILTER_COLLECTIONS)), this.eventAdmin);
}
use of com.mongodb.DBAddress in project jackrabbit-oak by apache.
the class BlobThroughPutTest method performBenchMark_WriteConcern.
@Ignore
@Test
public void performBenchMark_WriteConcern() throws UnknownHostException, InterruptedException {
Mongo mongo = new Mongo(new DBAddress(remoteServer));
final DB db = mongo.getDB(TEST_DB1);
final DBCollection nodes = db.getCollection("nodes");
final DBCollection blobs = db.getCollection("blobs");
int readers = 0;
int writers = 2;
for (WriteConcern wc : namedConcerns.keySet()) {
prepareDB(nodes, blobs);
final Benchmark b = new Benchmark(nodes, blobs);
Result r = b.run(readers, writers, true, wc);
results.add(r);
}
prepareDB(nodes, blobs);
dumpResult();
}
use of com.mongodb.DBAddress in project jackrabbit-oak by apache.
the class BlobThroughPutTest method performBenchMark.
@Ignore
@Test
public void performBenchMark() throws UnknownHostException, InterruptedException {
MongoClient local = new MongoClient(new DBAddress(localServer));
MongoClient remote = new MongoClient(new DBAddress(remoteServer));
run(local, false, false);
run(local, true, false);
run(remote, false, true);
run(remote, true, true);
dumpResult();
}
Aggregations