}
}
@Override
public MicroKernel getMicroKernel() throws UnknownHostException {
MongoConnection mongo = new MongoConnection(uri);
DocumentMK.Builder mkBuilder = new DocumentMK.Builder().
setMongoDB(mongo.getDB()).
memoryCacheSize(cacheSize).
setLogging(false);
setupBlobStore(mkBuilder);
return mkBuilder.open();
}
@Override
public Oak getOak(int clusterId) throws Exception {
MongoConnection mongo = new MongoConnection(uri);
DocumentMK.Builder mkBuilder = new DocumentMK.Builder().
setMongoDB(mongo.getDB()).
memoryCacheSize(cacheSize).
setClusterId(clusterId).setLogging(false);
setupBlobStore(mkBuilder);
DocumentMK dmk = mkBuilder.open();
Oak oak;
if (useMk) {
oak = new Oak(new KernelNodeStore(dmk, cacheSize));
} else {
oak = new Oak(dmk.getNodeStore());
}
return oak;
}
@Override
public Oak[] setUpCluster(int n) throws Exception {
Oak[] cluster = new Oak[n];
kernels = new DocumentMK[cluster.length];
for (int i = 0; i < cluster.length; i++) {
MongoConnection mongo = new MongoConnection(uri);
DocumentMK.Builder mkBuilder = new DocumentMK.Builder().
setMongoDB(mongo.getDB()).
memoryCacheSize(cacheSize).
setClusterId(i).setLogging(false);
setupBlobStore(mkBuilder);
kernels[i] = mkBuilder.open();
Oak oak;
if (useMk) {
oak = new Oak(new KernelNodeStore(kernels[i], cacheSize));
} else {
oak = new Oak(kernels[i].getNodeStore());
}
cluster[i] = oak;
}
return cluster;
}
@Override
public void tearDownCluster() {
for (DocumentMK kernel : kernels) {
kernel.dispose();
}
if (dropDBAfterTest) {
try {
MongoConnection mongo =
new MongoConnection(uri);
mongo.getDB().dropDatabase();
mongo.close();
if(blobStoreFixture != null){
blobStoreFixture.tearDown();
}
} catch (Exception e) {
throw new RuntimeException(e);