Examples of FileStore


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

            if (size == null) {
                size = System.getProperty(SIZE, "268435456"); // 256MB
            }

            mongo = null;
            store = new FileStore(
                    new File(directory),
                    Integer.parseInt(size), "64".equals(mode));
        } else {
            int port = Integer.parseInt(String.valueOf(properties.get(PORT)));
            String db = String.valueOf(properties.get(DB));
View Full Code Here

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

        Session session = null;
        try {
            File directory =
                    new File("target", "tarmk-" + System.currentTimeMillis());
            this.store = new FileStore(directory, 1024 * 1024, false);
            Jcr jcr = new Jcr(new Oak(new SegmentNodeStore(store)));
            this.repository = jcr.createRepository();

            session = getRepository().login(superuser);
            TestContentLoader loader = new TestContentLoader();
View Full Code Here

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

            @Override
            public Repository[] setUpCluster(int n) throws Exception {
                Repository[] cluster = new Repository[n];
                stores = new FileStore[cluster.length];
                for (int i = 0; i < cluster.length; i++) {
                    stores[i] = new FileStore(
                            new File(base, unique), maxFileSize, memoryMapping);
                    Oak oak = new Oak(new SegmentNodeStore(stores[i]));
                    cluster[i] = new Jcr(oak).createRepository();
                }
                return cluster;
View Full Code Here

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

                System.err.println("usage: upgrade <olddir> <newdir>");
                System.exit(1);
            }
        } else if ("backup".equals(command)) {
            if (args.length == 2) {
                FileStore store = new FileStore(new File(args[0]), 256, false);
                FileStoreBackup.backup(
                        new SegmentNodeStore(store), new File(args[1]));
                store.close();
            } else {
                System.err.println("usage: backup <repository> <backup>");
                System.exit(1);
            }
        } else if ("tarmk".equals(command)) {
            if (args.length == 0) {
                System.err.println("usage: tarmk <path> [id...]");
                System.exit(1);
            } else {
                System.out.println("TarMK " + args[0]);
                File file = new File(args[0]);
                FileStore store = new FileStore(file, 256, false);
                try {
                    if (args.length == 1) {
                        Map<UUID, List<UUID>> idmap = Maps.newHashMap();

                        int dataCount = 0;
                        long dataSize = 0;
                        int bulkCount = 0;
                        long bulkSize = 0;
                        for (UUID uuid : store.getSegmentIds()) {
                            if (SegmentIdFactory.isDataSegmentId(uuid)) {
                                Segment segment = store.readSegment(uuid);
                                dataCount++;
                                dataSize += segment.size();
                                idmap.put(uuid, segment.getReferencedIds());
                            } else if (SegmentIdFactory.isBulkSegmentId(uuid)) {
                                bulkCount++;
                                bulkSize += store.readSegment(uuid).size();
                                idmap.put(uuid, Collections.<UUID>emptyList());
                            }
                        }
                        System.out.println("Total size:");
                        System.out.format(
                                "%6dMB in %6d data segments%n",
                                dataSize / (1024 * 1024), dataCount);
                        System.out.format(
                                "%6dMB in %6d bulk segments%n",
                                bulkSize / (1024 * 1024), bulkCount);

                        Set<UUID> garbage = newHashSet(idmap.keySet());
                        Queue<UUID> queue = Queues.newArrayDeque();
                        queue.add(store.getJournal("root").getHead().getSegmentId());
                        while (!queue.isEmpty()) {
                            UUID id = queue.remove();
                            if (garbage.remove(id)) {
                                queue.addAll(idmap.get(id));
                            }
                        }
                        dataCount = 0;
                        dataSize = 0;
                        bulkCount = 0;
                        bulkSize = 0;
                        for (UUID uuid : garbage) {
                            if (SegmentIdFactory.isDataSegmentId(uuid)) {
                                dataCount++;
                                dataSize += store.readSegment(uuid).size();
                            } else if (SegmentIdFactory.isBulkSegmentId(uuid)) {
                                bulkCount++;
                                bulkSize += store.readSegment(uuid).size();
                            }
                        }
                        System.out.println("Available for garbage collection:");
                        System.out.format(
                                "%6dMB in %6d data segments%n",
                                dataSize / (1024 * 1024), dataCount);
                        System.out.format(
                                "%6dMB in %6d bulk segments%n",
                                bulkSize / (1024 * 1024), bulkCount);
                    } else {
                        for (int i = 1; i < args.length; i++) {
                            UUID uuid = UUID.fromString(args[i]);
                            System.out.println(store.readSegment(uuid));
                        }
                    }
                } finally {
                    store.close();
                }
            }
        } else {
            System.err.println("Unknown command: " + command);
            System.exit(1);
View Full Code Here

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

    private static void upgrade(String olddir, String newdir) throws Exception {
        RepositoryContext source = RepositoryContext.create(
                RepositoryConfig.create(new File(olddir)));
        try {
            FileStore store = new FileStore(new File(newdir), 256, true);
            try {
                NodeStore target = new SegmentNodeStore(store);
                new RepositoryUpgrade(source, target).copy();
            } finally {
                store.close();
            }
        } finally {
            source.getRepository().shutdown();
        }
    }
View Full Code Here

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

        deleteQuietly(destination);
    }

    @Test
    public void testBackup() throws Exception {
        FileStore source = new FileStore(src, 256, false);

        NodeStore store = new SegmentNodeStore(source);
        init(store);

        // initial content
        FileStoreBackup.backup(store, destination);

        compare(store, destination);

        addTestContent(store);
        FileStoreBackup.backup(store, destination);
        compare(store, destination);

        source.close();
    }
View Full Code Here

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

        store.merge(builder, EmptyHook.INSTANCE, null);
    }

    private static void compare(NodeStore store, File destination)
            throws IOException {
        FileStore backup = new FileStore(destination, 256, false);
        assertEquals(store.getRoot(), new SegmentNodeStore(backup).getRoot());
        backup.close();
    }
View Full Code Here

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

                .with(new InitialContent()).createContentRepository();
    }

    @Test @Ignore("OAK-1159 duplicate content")
    public void testSharedContent() throws Exception {
        FileStore source = new FileStore(src, 256, false);

        NodeStore store = new SegmentNodeStore(source);

        // ~100k
        Blob blob = store.createBlob(new ByteArrayInputStream(new byte[100000]));

        NodeBuilder builder = store.getRoot().builder();
        NodeBuilder c1 = builder.child("test-backup");
        c1.setProperty("blob", blob);
        NodeBuilder c2 = builder.child("test-backup2");
        c2.setProperty("blob", blob);
        store.merge(builder, EmptyHook.INSTANCE, null);

        FileStoreBackup.backup(store, destination);
        compare(store, destination);
        source.close();

        Map<String, Long> expected = new HashMap<String, Long>();
        for (File f : src.listFiles()) {
            if (f.getName().endsWith(".tar")) {
                expected.put(f.getName(), f.length());
View Full Code Here

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

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

        // 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

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

    }

    @Parameterized.Parameters
    public static Collection<Object[]> fixtures() throws IOException {
        File file = new File(new File("target"), "tar." + System.nanoTime());
        SegmentStore segmentStore = new FileStore(file, 266, true);

        List<Object[]> fixtures = Lists.newArrayList();
        SegmentFixture segmentFixture = new SegmentFixture(segmentStore);
        if (segmentFixture.isAvailable()) {
            fixtures.add(new Object[] {segmentFixture, SEGMENT_SCALES});
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.