Package org.apache.jackrabbit.mongomk.impl.model

Examples of org.apache.jackrabbit.mongomk.impl.model.MongoSync


            return;
        }
        DBCollection headCollection = mongoConnection.getDB().getCollection(
                COLLECTION_SYNC);
        headCollection.remove(new BasicDBObject());
        MongoSync headMongo = new MongoSync();
        headMongo.setHeadRevisionId(0L);
        headMongo.setNextRevisionId(1L);
        headCollection.insert(headMongo);
    }
View Full Code Here


        while (true) {
            LOG.debug("Waiting for commit...");

            DBCollection headCollection = ((MongoNodeStore)microKernel.getNodeStore()).getSyncCollection();
            MongoSync syncMongo = (MongoSync) headCollection.findOne();
            if (this.lastHeadRevId < syncMongo.getHeadRevisionId()) {
                DBCollection commitCollection = ((MongoNodeStore)microKernel.getNodeStore()).getCommitCollection();
                DBObject query = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).greaterThan(this.lastRevId)
                        .and(MongoCommit.KEY_REVISION_ID).lessThanEquals(syncMongo.getHeadRevisionId()).get();
                DBObject sort = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).is(1).get();
                DBCursor dbCursor = commitCollection.find(query).sort(sort);
                while (dbCursor.hasNext()) {
                    commitMongos.add((MongoCommit) dbCursor.next());
                }

                if (commitMongos.size() > 0) {
                    LOG.debug(String.format("Found %d new commits", commitMongos.size()));

                    break;
                }
                this.lastHeadRevId = syncMongo.getHeadRevisionId();
            }
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // noop
View Full Code Here

    private void initSyncCollection() {
        if (db.collectionExists(COLLECTION_SYNC)){
            return;
        }
        DBCollection headCollection = getSyncCollection();
        MongoSync headMongo = new MongoSync();
        headMongo.setHeadRevisionId(0L);
        headMongo.setNextRevisionId(1L);
        headCollection.insert(headMongo);
    }
View Full Code Here

    }

    @Override
    public Long execute() throws Exception {
        DBCollection headCollection = nodeStore.getSyncCollection();
        MongoSync syncMongo = (MongoSync)headCollection.findOne();
        long headRevisionId = syncMongo.getHeadRevisionId();

        DBCollection collection = nodeStore.getCommitCollection();
        QueryBuilder qb = QueryBuilder.start(MongoCommit.KEY_FAILED).notEquals(Boolean.TRUE)
                .and(MongoCommit.KEY_REVISION_ID).lessThanEquals(headRevisionId);
        if (branchId == null) {
View Full Code Here

        if (branchId != null) {
            return true;
        }

        long assumedHeadRevision = this.mongoSync.getHeadRevisionId();
        MongoSync mongoSync = new SaveAndSetHeadRevisionAction(nodeStore,
                assumedHeadRevision, revisionId).execute();
        if (mongoSync == null) {
            // There have been commit(s) in the meantime. If it's a conflicting
            // update, retry the whole operation and count against number of retries.
            // If not, need to retry again (in order to write commits and nodes properly)
View Full Code Here

        if (branchId != null) {
            return true;
        }

        long assumedHeadRevision = this.mongoSync.getHeadRevisionId();
        MongoSync mongoSync = new SaveAndSetHeadRevisionAction(nodeStore,
                assumedHeadRevision, revisionId).execute();
        if (mongoSync == null) {
            // There have been commit(s) in the meantime. If it's a conflicting
            // update, retry the whole operation and count against number of retries.
            // If not, need to retry again (in order to write commits and nodes properly)
View Full Code Here

        Assert.assertEquals(commit.getDiff(), result.getDiff());
    }

    public static void assertHeadRevision(long revisionId) {
        DBCollection headCollection = nodeStore.getSyncCollection();
        MongoSync result = (MongoSync) headCollection.findOne();
        Assert.assertEquals(revisionId, result.getHeadRevisionId());
    }
View Full Code Here

        Assert.assertEquals(revisionId, result.getHeadRevisionId());
    }

    public static void assertNextRevision(long revisionId) {
        DBCollection headCollection = nodeStore.getSyncCollection();
        MongoSync result = (MongoSync) headCollection.findOne();
        Assert.assertEquals(revisionId, result.getNextRevisionId());
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mongomk.impl.model.MongoSync

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.