"Adding a total of {} nodes evely spread across cluster. Loop: {}, Count: {}, Cluster nodes: {}",
new Object[] { loop * count * clusters, loop, count, clusters });
// creating instances
for (int i = 1; i <= clusters; i++) {
DocumentMK mk = new DocumentMK.Builder()
.memoryCacheSize(CACHE_SIZE)
.setMongoDB(createConnection().getDB())
.setClusterId(i).open();
mks.add(mk);
}
Map<String, Exception> exceptions = Collections.synchronizedMap(
new HashMap<String, Exception>());
// initialising repositories and creating workers
for (int i = 0; i < mks.size(); i++) {
DocumentMK mk = mks.get(i);
Repository repo = new Jcr(mk.getNodeStore()).createRepository();
Session session = repo.login(ADMIN);
ensureIndex(session);
session.logout();
repos.add(repo);
workers.add(new Thread(new Worker(repo, exceptions), "Worker-" + (i + 1)));
}
// we know we have at least repos[0]
Repository repo = repos.get(0);
Session session = repo.login(ADMIN);
ensureIndex(session);
// initialising the repository sequentially to avoid any possible
// concurrency errors during inserts
for (Thread w : workers) {
String nodeName = getNodeName(w);
createNodes(session, nodeName, loop, count, exceptions);
}
// extra save for being sure.
session.save();
if (exceptions.isEmpty()) {
// ensuring the cluster is aligned before triggering in order to avoid any
// PathNotFoundException
for (DocumentMK mk : mks) {
mk.getNodeStore().runBackgroundOperations();
}
for (Thread t : workers) {
t.start();
}
for (Thread t : workers) {