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

Examples of org.apache.jackrabbit.oak.plugins.segment.file.FileStore


            File directory = new File(args[0]);
            System.out.println("Compacting " + directory);
            System.out.println("    before " + Arrays.toString(directory.list()));

            System.out.println("    -> compacting");
            FileStore store = new FileStore(directory, 256, TAR_STORAGE_MEMORY_MAPPED);
            try {
                store.compact();
            } finally {
                store.close();
            }

            System.out.println("    -> cleaning up");
            store = new FileStore(directory, 256, TAR_STORAGE_MEMORY_MAPPED);
            try {
                store.cleanup();
            } finally {
                store.close();
            }

            System.out.println("    after  " + Arrays.toString(directory.list()));
        }
    }
View Full Code Here


                System.err.println("Unknown comand.");
                System.exit(1);
            }
        }
        System.out.println("Checkpoints " + path);
        FileStore store = new FileStore(new File(path), 256, TAR_STORAGE_MEMORY_MAPPED);
        try {
            if ("list".equals(op)) {
                NodeState ns = store.getHead().getChildNode("checkpoints");
                for (ChildNodeEntry cne : ns.getChildNodeEntries()) {
                    NodeState cneNs = cne.getNodeState();
                    System.out.printf("- %s created %s expires %s%n",
                            cne.getName(),
                            new Timestamp(cneNs.getLong("created")),
                            new Timestamp(cneNs.getLong("timestamp")));
                }
                System.out.println("Found "
                        + 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();
                    boolean ok = store.setHead(head,
                            (SegmentNodeState) builder.getNodeState());
                    time = System.currentTimeMillis() - time;
                    if (ok) {
                        System.err.println("Removed checkpoint " + cp + " in "
                                + time + "ms.");
                    } else {
                        System.err.println("Failed to remove checkpoint " + cp);
                    }
                } else {
                    System.err.println("Checkpoint '" + cp + "' not found.");
                    System.exit(1);
                }
            }
        } finally {
            store.close();
        }

    }
View Full Code Here

            System.exit(1);
        } else {
            // TODO: enable debug information for other node store implementations
            System.out.println("Debug " + args[0]);
            File file = new File(args[0]);
            FileStore store = new FileStore(file, 256, TAR_STORAGE_MEMORY_MAPPED);
            try {
                if (args.length == 1) {
                    debugFileStore(store);
                } else {
                    if (args[1].endsWith(".tar")) {
                        debugTarFile(store, args);
                    } else {
                        debugSegment(store, args);
                    }
                }
            } finally {
                store.close();
            }
        }
    }
View Full Code Here

                        }
                    } finally {
                        client.close();
                    }
                } else {
                    FileStore store = new FileStore(new File(dst), 256);
                    try {
                        NodeStore target = new SegmentNodeStore(store);
                        RepositoryUpgrade upgrade =
                                new RepositoryUpgrade(source, target);
                        upgrade.setCopyBinariesByReference(
                                options.has("datastore"));
                        upgrade.copy(null);
                    } finally {
                        store.close();
                    }
                }
            } finally {
                source.getRepository().shutdown();
            }
View Full Code Here

            System.err.println("usage: explore <path> [skip-size-check]");
            System.exit(1);
        }

        final String path = args[0];
        final FileStore store = new FileStore(new File(path), 256);
        final boolean skipSizeCheck = args.length == 2
                && skip.equalsIgnoreCase(args[1]);

        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
View Full Code Here

            throw new IOException("Folder " + source
                    + " is not a valid FileStore directory");
        }

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

    protected final boolean noDualStackSupport = SystemUtils.IS_OS_WINDOWS && SystemUtils.IS_JAVA_1_6;

    public void setUpServerAndClient() throws IOException {
        // server
        directoryS = createTmpTargetDir("FailoverServerTest");
        storeS = new FileStore(directoryS, 1, false);

        // client
        directoryC = createTmpTargetDir("FailoverClientTest");
        storeC = new FileStore(directoryC, 1, false);
    }
View Full Code Here

    public void setUpServerAndTwoClients() throws Exception {
        setUpServerAndClient();

        directoryC2 = createTmpTargetDir("FailoverClient2Test");
        storeC2 = new FileStore(directoryC2, 1, false);
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
        File d = createTmpTargetDir("FailoverLiveTest");
        d.delete();
        d.mkdir();
        FileStore s = new FileStore(d, 256, false);
        StandbyClient cl = new StandbyClient("127.0.0.1", 8023, s);
        try {
            cl.run();
        } finally {
            s.close();
            cl.close();
        }
    }
View Full Code Here

        boolean pauseCompaction = toBoolean(lookup(context, PAUSE_COMPACTION), true);
        boolean memoryMapping = "64".equals(mode);
        if (customBlobStore) {
            log.info("Initializing SegmentNodeStore with BlobStore [{}]", blobStore);
            store = new FileStore(blobStore, new File(directory),
                    Integer.parseInt(size), memoryMapping)
                    .setPauseCompaction(pauseCompaction);
        } else {
            store = new FileStore(new File(directory), Integer.parseInt(size),
                    memoryMapping).setPauseCompaction(pauseCompaction);
        }

        delegate = new SegmentNodeStore(store);
        observerTracker = new ObserverTracker(delegate);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.segment.file.FileStore

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.