Examples of SegmentNodeState


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

        }

        // 2. init filestore
        FileStore backup = new FileStore(destination, MAX_FILE_SIZE, false);
        try {
            SegmentNodeState state = backup.getHead();
            NodeState before = null;
            String beforeCheckpoint = state.getString("checkpoint");
            if (beforeCheckpoint == null) {
                // 3.1 no stored checkpoint, so do the initial full backup
                before = EMPTY_NODE;
            } else {
                // 3.2 try to retrieve the previously backed up checkpoint
                before = store.retrieve(beforeCheckpoint);
                if (before == null) {
                    // the previous checkpoint is no longer available,
                    // so use the backed up state as the basis of the
                    // incremental backup diff
                    before = state.getChildNode("root");
                }
            }

            Compactor compactor = new Compactor(backup.getTracker().getWriter());
            SegmentNodeState after = compactor.compact(before, current);

            // 4. commit the backup
            SegmentNodeBuilder builder = state.builder();
            builder.setProperty("checkpoint", checkpoint);
            builder.setChildNode("root", after);
View Full Code Here

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

                            }
                            String path = "/";
                            if (matcher.group(3) != null) {
                                path = matcher.group(3);
                            }
                            NodeState node = new SegmentNodeState(id);
                            System.out.println("/ -> " + node);
                            for (String name : PathUtils.elements(path)) {
                                node = node.getChildNode(name);
                                System.out.println(" " + name  + " -> " + node);
                            }
                        }
                    }
                }
View Full Code Here

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

                        + ns.getChildNodeCount(Integer.MAX_VALUE)
                        + " checkpoints");
            }
            if ("rm-all".equals(op)) {
                long time = System.currentTimeMillis();
                SegmentNodeState head = store.getHead();
                NodeBuilder builder = head.builder();

                NodeBuilder cps = builder.getChildNode("checkpoints");
                long cnt = cps.getChildNodeCount(Integer.MAX_VALUE);
                builder.setChildNode("checkpoints");
                boolean ok = store.setHead(head,
                        (SegmentNodeState) builder.getNodeState());
                time = System.currentTimeMillis() - time;
                if (ok) {
                    System.out.println("Removed " + cnt + " checkpoints in "
                            + time + "ms.");
                } else {
                    System.err.println("Failed to remove all checkpoints.");
                }
            }
            if ("rm-unreferenced".equals(op)) {
                long time = System.currentTimeMillis();
                SegmentNodeState head = store.getHead();

                String ref = null;
                PropertyState refPS = head.getChildNode("root")
                        .getChildNode(":async").getProperty("async");
                if (refPS != null) {
                    ref = refPS.getValue(Type.STRING);
                }
                if (ref != null) {
                    System.out
                            .println("Referenced checkpoint from /:async@async is "
                                    + ref);
                }

                NodeBuilder builder = head.builder();
                NodeBuilder cps = builder.getChildNode("checkpoints");
                long cnt = 0;
                for (String c : cps.getChildNodeNames()) {
                    if (c.equals(ref)) {
                        continue;
                    }
                    cps.getChildNode(c).remove();
                    cnt++;
                }

                boolean ok = cnt == 0 || store.setHead(head,
                        (SegmentNodeState) builder.getNodeState());
                time = System.currentTimeMillis() - time;
                if (ok) {
                    System.out.println("Removed " + cnt + " checkpoints in "
                            + time + "ms.");
                } else {
                    System.err.println("Failed to remove unreferenced checkpoints.");
                }
            }
            if ("rm".equals(op)) {
                if (args.length != 3) {
                    System.err.println("Missing checkpoint id");
                    System.exit(1);
                }
                long time = System.currentTimeMillis();
                String cp = args[2];
                SegmentNodeState head = store.getHead();
                NodeBuilder builder = head.builder();

                NodeBuilder cpn = builder.getChildNode("checkpoints")
                        .getChildNode(cp);
                if (cpn.exists()) {
                    cpn.remove();
View Full Code Here

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

                if (matcher.group(6) != null) {
                    path = matcher.group(6);
                }

                if (id2 == null) {
                    NodeState node = new SegmentNodeState(id1);
                    System.out.println("/ (" + id1 + ") -> " + node);
                    for (String name : PathUtils.elements(path)) {
                        node = node.getChildNode(name);
                        RecordId nid = null;
                        if (node instanceof SegmentNodeState) {
                            nid = ((SegmentNodeState) node).getRecordId();
                        }
                        System.out.println("  " + name + " (" + nid + ") -> "
                                + node);
                    }
                } else {
                    NodeState node1 = new SegmentNodeState(id1);
                    NodeState node2 = new SegmentNodeState(id2);
                    for (String name : PathUtils.elements(path)) {
                        node1 = node1.getChildNode(name);
                        node2 = node2.getChildNode(name);
                    }
                    System.out.println(JsopBuilder.prettyPrint(JsopDiff
                            .diffToJsop(node1, node2)));
                }
            }
View Full Code Here

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

    public void testRestartAndGC(boolean memoryMapping) throws IOException {
        FileStore store = new FileStore(directory, 1, memoryMapping);
        store.close();

        store = new FileStore(directory, 1, memoryMapping);
        SegmentNodeState base = store.getHead();
        SegmentNodeBuilder builder = base.builder();
        byte[] data = new byte[10 * 1024 * 1024];
        new Random().nextBytes(data);
        Blob blob = builder.createBlob(new ByteArrayInputStream(data));
        builder.setProperty("foo", blob);
        store.setHead(base, builder.getNodeState());
View Full Code Here

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

        int largeBinarySize = 10 * 1024 * 1024;

        FileStore store = new FileStore(directory, 1, false);
        SegmentWriter writer = store.getTracker().getWriter();

        SegmentNodeState base = store.getHead();
        SegmentNodeBuilder builder = base.builder();
        byte[] data = new byte[largeBinarySize];
        new Random().nextBytes(data);
        SegmentBlob blob = writer.writeStream(new ByteArrayInputStream(data));
        builder.setProperty("foo", blob);
        builder.getNodeState(); // write the blob reference to the segment
        builder.setProperty("foo", "bar");
        SegmentNodeState head = builder.getNodeState();
        assertTrue(store.setHead(base, head));
        assertEquals("bar", store.getHead().getString("foo"));
        store.close();

        // First simulate the case where during compaction a reference to the
        // older segments is added to a segment that the compactor is writing
        store = new FileStore(directory, 1, false);
        head = store.getHead();
        assertTrue(store.size() > largeBinarySize);
        Compactor compactor = new Compactor(writer);
        SegmentNodeState compacted =
                compactor.compact(EmptyNodeState.EMPTY_NODE, head);
        builder = head.builder();
        builder.setChildNode("old", head); // reference to pre-compacted state
        builder.getNodeState();
        assertTrue(store.setHead(head, compacted));
View Full Code Here

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

    @Test
    public void testRecovery() throws IOException {
        FileStore store = new FileStore(directory, 1, false);
        store.flush(); // first 1kB

        SegmentNodeState base = store.getHead();
        SegmentNodeBuilder builder = base.builder();
        builder.setProperty("step", "a");
        store.setHead(base, builder.getNodeState());
        store.flush(); // second 1kB

        base = store.getHead();
        builder = base.builder();
        builder.setProperty("step", "b");
        store.setHead(base, builder.getNodeState());
        store.close(); // third 1kB

        store = new FileStore(directory, 1, false);
View Full Code Here

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

            sb.append(newline);

            NamePathModel model = (NamePathModel) node.getUserObject();
            NodeState state = model.getState();
            if (state instanceof SegmentNodeState) {
                SegmentNodeState sns = (SegmentNodeState) state;
                sb.append("Record ");
                sb.append(sns.getRecordId().toString());
                sb.append(newline);
            }
            log.setText(sb.toString());
        }
    }
View Full Code Here

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

        NodeState state = model.getState();
        String tarFile = "";

        if (state instanceof SegmentNodeState) {
            SegmentNodeState s = (SegmentNodeState) state;
            RecordId recordId = s.getRecordId();
            sb.append("Record " + recordId);
            tarFile = getFile(recordId);
            if (tarFile.length() > 0) {
                sb.append(" in " + tarFile);
            }
View Full Code Here

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

        String path = "/";
        if (tokens.length == 3) {
            path = tokens[2];
        }

        NodeState node1 = new SegmentNodeState(id1);
        NodeState node2 = new SegmentNodeState(id2);
        for (String name : PathUtils.elements(path)) {
            node1 = node1.getChildNode(name);
            node2 = node2.getChildNode(name);
        }

        sb.append("SegmentNodeState diff ");
        sb.append(id1);
        sb.append(" vs ");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.