Package org.apache.jackrabbit.oak.plugins.segment

Examples of org.apache.jackrabbit.oak.plugins.segment.RecordId


        DBObject id = new BasicDBObject("_id", name);
        DBObject state = journals.findOne(id, null, primaryPreferred());
        checkState(state != null);

        if (state.containsField("parent")) {
            RecordId base = RecordId.fromString(state.get("base").toString());
            RecordId head = RecordId.fromString(state.get("head").toString());

            SegmentWriter writer = store.getWriter();
            Segment segment = writer.getDummySegment();

            NodeState before = new SegmentNodeState(segment, base);
            NodeState after = new SegmentNodeState(segment, head);

            Journal parent = store.getJournal(state.get("parent").toString());
            while (!parent.setHead(base, head)) {
                RecordId newBase = parent.getHead();
                NodeBuilder builder =
                        new SegmentNodeState(segment, newBase).builder();
                after.compareAgainstBaseState(before, new MergeDiff(builder));
                RecordId newHead =
                        writer.writeNode(builder.getNodeState()).getRecordId();

                base = newBase;
                head = newHead;
            }
View Full Code Here


        if (journal == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        RecordId head = getRecordId(request.getReader());
        if (head == null) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }
View Full Code Here

        }

        journalFile = new RandomAccessFile(
                new File(directory, JOURNAL_FILE_NAME), "rw");

        RecordId id = null;
        String line = journalFile.readLine();
        while (line != null) {
            int space = line.indexOf(' ');
            if (space != -1) {
                id = RecordId.fromString(line.substring(0, space));
View Full Code Here

        flushThread.start();
    }

    public void flush() throws IOException {
        synchronized (persistedHead) {
            RecordId before = persistedHead.get();
            RecordId after = head.get();
            if (!after.equals(before)) {
                // needs to happen outside the synchronization block below to
                // avoid a deadlock with another thread flushing the writer
                getWriter().flush();

                synchronized (this) {
View Full Code Here

            public RecordId getHead() {
                return head.get();
            }
            @Override
            public boolean setHead(RecordId before, RecordId after) {
                RecordId id = head.get();
                return id.equals(before) && head.compareAndSet(id, after);
            }
            @Override
            public void merge() {
                throw new UnsupportedOperationException();
            }
View Full Code Here

        DBObject id = new BasicDBObject("_id", "root");
        state = journals.findOne(id, null, primaryPreferred());
        if (state == null) {
            SegmentWriter writer = new SegmentWriter(store);
            RecordId head = writer.writeNode(root).getRecordId();
            writer.flush();
            state = new BasicDBObject(of(
                    "_id""root",
                    "head", head.toString()));
            try {
                journals.insert(state, concern);
            } catch (MongoException.DuplicateKey e) {
                // Someone else managed to concurrently create the journal,
                // so let's just re-read it from the database
View Full Code Here

        DBObject id = new BasicDBObject("_id", name);
        DBObject state = journals.findOne(id, null, primaryPreferred());
        checkState(state != null);

        if (state.containsField("parent")) {
            RecordId base = RecordId.fromString(state.get("base").toString());
            RecordId head = RecordId.fromString(state.get("head").toString());

            NodeState before = new SegmentNodeState(store, base);
            NodeState after = new SegmentNodeState(store, head);

            Journal parent = store.getJournal(state.get("parent").toString());
            SegmentWriter writer = new SegmentWriter(store);
            while (!parent.setHead(base, head)) {
                RecordId newBase = parent.getHead();
                NodeBuilder builder =
                        new SegmentNodeState(store, newBase).builder();
                after.compareAgainstBaseState(before, new MergeDiff(builder));
                RecordId newHead =
                        writer.writeNode(builder.getNodeState()).getRecordId();
                writer.flush();

                base = newBase;
                head = newHead;
View Full Code Here

                    int count = ro.getInt();
                    for (int i = 0; i < count; i++) {
                        byte[] n = new byte[ro.getInt()];
                        ro.get(n);
                        SegmentNodeState h = new SegmentNodeState(this, new RecordId(
                                new UUID(ro.getLong(), ro.getLong()),
                                ro.getInt()));
                        journals.put(
                                new String(n, UTF_8),
                                new FileJournal(this, h));
View Full Code Here

        rw.putInt(journals.size());
        for (Map.Entry<String, Journal> entry : journals.entrySet()) {
            byte[] name = entry.getKey().getBytes(UTF_8);
            rw.putInt(name.length);
            rw.put(name);
            RecordId head = entry.getValue().getHead();
            rw.putLong(head.getSegmentId().getMostSignificantBits());
            rw.putLong(head.getSegmentId().getLeastSignificantBits());
            rw.putInt(head.getOffset());
        }
        rw.position((rw.position() + 0x1ff) & ~0x1ff);
    }
View Full Code Here

    public MemoryJournal(SegmentStore store, NodeState root) {
        this.store = checkNotNull(store);
        this.parent = null;

        SegmentWriter writer = new SegmentWriter(store);
        RecordId id = writer.writeNode(root).getRecordId();
        writer.flush();

        this.base = id;
        this.head = id;
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.segment.RecordId

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.