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

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


        source.close();
    }

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

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

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

        addTestContent(store);

        FileStoreRestore.restore(destination, store);

        compare(store, destination);

        source.close();
    }
View Full Code Here

        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

                .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

    }

    private static void backup(String[] args) throws IOException {
        if (args.length == 2) {
            // TODO: enable backup for other node store implementations
            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);
        }
    }
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, false);
            try {
                if (args.length == 1) {
                    Map<SegmentId, List<SegmentId>> idmap = Maps.newHashMap();

                    int dataCount = 0;
                    long dataSize = 0;
                    int bulkCount = 0;
                    long bulkSize = 0;
                    for (SegmentId id : store.getSegmentIds()) {
                        if (id.isDataSegmentId()) {
                            Segment segment = id.getSegment();
                            dataCount++;
                            dataSize += segment.size();
                            idmap.put(id, segment.getReferencedIds());
                        } else if (id.isBulkSegmentId()) {
                            bulkCount++;
                            bulkSize += id.getSegment().size();
                            idmap.put(id, Collections.<SegmentId>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<SegmentId> garbage = newHashSet(idmap.keySet());
                    Queue<SegmentId> queue = Queues.newArrayDeque();
                    queue.add(store.getHead().getRecordId().getSegmentId());
                    while (!queue.isEmpty()) {
                        SegmentId id = queue.remove();
                        if (garbage.remove(id)) {
                            queue.addAll(idmap.get(id));
                        }
                    }
                    dataCount = 0;
                    dataSize = 0;
                    bulkCount = 0;
                    bulkSize = 0;
                    for (SegmentId id : garbage) {
                        if (id.isDataSegmentId()) {
                            dataCount++;
                            dataSize += id.getSegment().size();
                        } else if (id.isBulkSegmentId()) {
                            bulkCount++;
                            bulkSize += id.getSegment().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]);
                        SegmentId id = store.getTracker().getSegmentId(
                                uuid.getMostSignificantBits(),
                                uuid.getLeastSignificantBits());
                        System.out.println(id.getSegment());
                    }
                }
            } 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();
                    } finally {
                        store.close();
                    }
                }
            } finally {
                source.getRepository().shutdown();
            }
View Full Code Here

        FileUtils.cleanDirectory(getWorkDir());
    }

    protected SegmentNodeStore getNodeStore(BlobStore blobStore) throws IOException {
        if (nodeStore == null) {
            store = new FileStore(blobStore, getWorkDir(), 256, false);
            nodeStore = new SegmentNodeStore(store);
        }
        return nodeStore;
    }
View Full Code Here

        return new OakFixture(OAK_TAR) {
            private SegmentStore[] stores;

            @Override
            public Oak getOak(int clusterId) throws Exception {
                FileStore fs = new FileStore(base, maxFileSizeMB, cacheSizeMB, memoryMapping);
                return new Oak(new SegmentNodeStore(fs));
            }

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

        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

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.