while (true) {
LOG.debug("Waiting for commit...");
DBCollection headCollection = this.mongoConnection.getHeadCollection();
HeadMongo headMongo = (HeadMongo) headCollection.findOne();
if (this.lastHeadRevId < headMongo.getHeadRevisionId()) {
DBCollection commitCollection = this.mongoConnection.getCommitCollection();
DBObject query = QueryBuilder.start(CommitMongo.KEY_REVISION_ID).greaterThan(this.lastRevId)
.and(CommitMongo.KEY_REVISION_ID).lessThanEquals(headMongo.getHeadRevisionId()).get();
DBObject sort = QueryBuilder.start(CommitMongo.KEY_REVISION_ID).is(1).get();
DBCursor dbCursor = commitCollection.find(query).sort(sort);
while (dbCursor.hasNext()) {
commitMongos.add((CommitMongo) dbCursor.next());
}
if (commitMongos.size() > 0) {
LOG.debug(String.format("Found %d new commits", commitMongos.size()));
break;
}
this.lastHeadRevId = headMongo.getHeadRevisionId();
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// noop