Package org.apache.jackrabbit.mk.model

Examples of org.apache.jackrabbit.mk.model.Id


    public void writeHead(Id id) {
       
    }

    public void readNode(StoredNode node) throws NotFoundException, Exception {
        Id id = node.getId();
        byte[] bytes = objects.get(id);
        if (bytes != null) {
            node.deserialize(new BinaryBinding(new ByteArrayInputStream(bytes)));
            return;
        }
        throw new NotFoundException(id.toString());
    }
View Full Code Here


    public Id writeNode(Node node) throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        node.serialize(new BinaryBinding(out));
        byte[] bytes = out.toByteArray();
        Id id = new Id(idFactory.createContentId(bytes));

        if (!objects.containsKey(id)) {
            objects.put(id, bytes);
        }
        if (gcStart != 0) {
View Full Code Here

    public Id writeCNEMap(ChildNodeEntries map) throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        map.serialize(new BinaryBinding(out));
        byte[] bytes = out.toByteArray();
        Id id = new Id(idFactory.createContentId(bytes));

        if (!objects.containsKey(id)) {
            objects.put(id, bytes);
        }
        if (gcStart != 0) {
View Full Code Here

        head = ids[0];
        if (head == null || head.getBytes().length == 0) {
            // assume virgin repository
            byte[] rawHead = Id.fromLong(commitCounter.incrementAndGet())
                    .getBytes();
            head = new Id(rawHead);

            Id rootNodeId = pm.writeNode(new MutableNode(this));
            MutableCommit initialCommit = new MutableCommit();
            initialCommit.setCommitTS(System.currentTimeMillis());
            initialCommit.setRootNodeId(rootNodeId);
            pm.writeCommit(head, initialCommit);
            pm.writeHead(head);
        } else {
            Id lastCommitId = head;
            if (ids[1] != null && ids[1].compareTo(lastCommitId) > 0) {
                lastCommitId = ids[1];
            }
            commitCounter.set(Long.parseLong(lastCommitId.toString(), 16));
        }

        if (gcpm != null) {
            gcExecutor = Executors.newScheduledThreadPool(1,
                    new ThreadFactory() {
View Full Code Here

         * before we have updated our token
         */
        tokensLock.writeLock().lock();

        try {
            Id id = pm.writeNode(node);

            if (callback != null) {
                callback.postPersist(this, token);
            }

View Full Code Here

        if (map instanceof PersistHook) {
            callback = (PersistHook) map;
            callback.prePersist(this, token);
        }

        Id id = pm.writeCNEMap(map);

        if (callback != null) {
            callback.postPersist(this, token);
        }
View Full Code Here

        if (commit.getBranchRootId() != null) {
            // OAK-267
            throw new IllegalStateException("private branch commit [" + commit + "] cannot become HEAD");
        }

        Id id = writeCommit(token, commit);
        setHeadCommitId(id);

        tokensLock.writeLock().lock();

        try {
View Full Code Here

    }

    public Id putCommit(PutToken token, MutableCommit commit) throws Exception {
        verifyInitialized();

        Id commitId = writeCommit(token, commit);

        tokensLock.writeLock().lock();

        try {
            putTokens.remove(token);
        } finally {
            tokensLock.writeLock().unlock();
        }

        Id branchRootId = commit.getBranchRootId();
        if (branchRootId != null) {
            synchronized (branches) {
                Id parentId = commit.getParentId();
                if (!parentId.equals(branchRootId)) {
                    /* not the first branch commit, replace its head */
                    branches.remove(parentId);
                }
                branches.put(commitId, branchRootId);
            }
View Full Code Here

        if (commit instanceof PersistHook) {
            callback = (PersistHook) commit;
            callback.prePersist(this, token);
        }

        Id id = commit.getId();
        if (id == null) {
            id = Id.fromLong(commitCounter.incrementAndGet());
        }
        pm.writeCommit(id, commit);
View Full Code Here

        LOG.debug("GC started.");
        markedCommits = markedNodes = 0;

        try {
            markUncommittedNodes();
            Id firstBranchRootId = markBranches();
            if (firstBranchRootId != null) {
                LOG.debug("First branch root to be preserved: {}", firstBranchRootId);
            }
            Id firstCommitId = markCommits();
            LOG.debug("First commit to be preserved: {}", firstCommitId);

            LOG.debug("Marked {} commits, {} nodes.", markedCommits, markedNodes);

            if (firstBranchRootId != null && firstBranchRootId.compareTo(firstCommitId) < 0) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.mk.model.Id

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.