public ArrayList<MicroKernel> init(Configuration conf, int mksNumber)
throws Exception {
ArrayList<MicroKernel> mks = new ArrayList<MicroKernel>();
MongoConnection mongoConnection;
mongoConnection = new MongoConnection(conf.getHost(),
conf.getMongoPort(), conf.getMongoDatabase());
Thread.sleep(1000);
MongoClearCollections.clearAllCollections(mongoConnection);
mongoConnection.close();
mongoConnection = new MongoConnection(conf.getHost(),
conf.getMongoPort(), "admin");
// set the shard key
mongoConnection.getDB()
.command(
BasicDBObjectBuilder
.start("shardCollection", "test.nodes")
.push("key").add("path", 1).add("revId", 1)
.pop().get());
for (int i = 0; i < mksNumber; i++) {
mongoConnection = new MongoConnection(conf.getHost(),
conf.getMongoPort(), conf.getMongoDatabase());
MongoNodeStore nodeStore = new MongoNodeStore(
mongoConnection.getDB());
// MongoAssert.setNodeStore(nodeStore);
BlobStore blobStore = new MongoGridFSBlobStore(
mongoConnection.getDB());
mks.add(new MongoMicroKernel(mongoConnection, nodeStore, blobStore));
}
return mks;
}