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

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


    public void close() {
    }

    @Override
    public synchronized Journal getJournal(String name) {
        Journal journal = journals.get(name);
        if (journal == null) {
            journal = new MongoJournal(
                    this, db.getCollection("journals"), concern, name);
            journals.put(name, journal);
        }
View Full Code Here


        }

        // 2. init filestore
        FileStore restore = new FileStore(source, MAX_FILE_SIZE, false);
        try {
            Journal journal = restore.getJournal("root");
            SegmentNodeState state = new SegmentNodeState(restore.getWriter()
                    .getDummySegment(), journal.getHead());
            restore(state.getChildNode("root"), store);
        } finally {
            restore.close();
        }
    }
View Full Code Here

    }

    private void doGetJournal(
            String info, HttpServletResponse response)
            throws ServletException, IOException {
        Journal journal = getSegmentStore().getJournal(info);
        if (journal == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        response.setContentType("text/plain; charset=UTF-8");
        response.getWriter().write(journal.getHead().toString());
    }
View Full Code Here

    private void doPutJournal(
            String info,
            HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        Journal journal = getSegmentStore().getJournal(info);
        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;
        }

        if (journal.setHead(journal.getHead(), head)) {
            response.setStatus(HttpServletResponse.SC_OK);
        } else {
            response.sendError(HttpServletResponse.SC_CONFLICT);
        }
    }
View Full Code Here

    public void close() {
    }

    @Override
    public synchronized Journal getJournal(String name) {
        Journal journal = journals.get(name);
        if (journal == null) {
            journal = new MongoJournal(
                    this, db.getCollection("journals"), concern, name);
            journals.put(name, journal);
        }
View Full Code Here

    }

    @Override
    public Journal getJournal(String name) {
        checkArgument("root".equals(name)); // only root supported for now
        return new Journal() {
            @Override
            public RecordId getHead() {
                return head.get();
            }
            @Override
View Full Code Here

    @Override
    public Journal getJournal(String name) {
        try {
            final URL url = new URL(base, "/j/" + name);
            return new Journal() {
                @Override
                public RecordId getHead() {
                    try {
                        InputStream stream = url.openStream();
                        try {
View Full Code Here

        checkArgument(!"root".equals(name));

        DBObject id = new BasicDBObject("_id", name);
        state = journals.findOne(id, null, primaryPreferred());
        if (state == null) {
            Journal root = store.getJournal("root");
            String head = root.getHead().toString();
            state = new BasicDBObject(of(
                    "_id",    name,
                    "parent", "root",
                    "base",   head,
                    "head",   head));
View Full Code Here

            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();
View Full Code Here

        }
    }

    @Override
    public synchronized Journal getJournal(final String name) {
        Journal journal = journals.get(name);
        if (journal == null) {
            journal = new FileJournal(this, "root");
            journals.put(name, journal);
        }
        return journal;
View Full Code Here

TOP

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

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.