Package org.apache.jackrabbit.core.persistence.bundle

Examples of org.apache.jackrabbit.core.persistence.bundle.ConsistencyCheckerImpl$OrphanedNode


        bundle2.addChildNodeEntry(nameFactory.create("", "test"), bundle3.getId());
        // node3 has node2 as parent
        bundle3.setParentId(bundle2.getId());

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(bundle1, bundle2, bundle3));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null);

        // run checker with fix = true
        checker.check(null, false, true, null);

        bundle1 = pm.loadBundle(bundle1.getId());
        bundle2 = pm.loadBundle(bundle2.getId());
        bundle3 = pm.loadBundle(bundle3.getId());
View Full Code Here


        bundle3.addChildNodeEntry(nameFactory.create("", "test"), bundle5.getId());
        bundle4.addChildNodeEntry(nameFactory.create("", "test"), bundle5.getId());
        bundle5.setParentId(bundle4.getId());

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(bundle1, bundle2, bundle3, bundle4, bundle5, lostAndFound, orphaned));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null);

        // run checker with fix = false
        checker.check(null, false, false, null);

        bundle1 = pm.loadBundle(bundle1.getId());
        lostAndFound = pm.loadBundle(lostAndFound.getId());
        bundle3 = pm.loadBundle(bundle3.getId());
View Full Code Here

        // node2 has a reference to node 1 as its parent, but node 1 doesn't have
        // a corresponding child node entry
        bundle2.setParentId(bundle1.getId());

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(bundle1, bundle2));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null);

        // run checker with fix = true
        checker.check(null, false, true, null);

        // node1 should now have a child node entry for node2
        bundle1 = pm.loadBundle(bundle1.getId());
        assertEquals(1, bundle1.getChildNodeEntries().size());
        assertEquals(bundle2.getId(), bundle1.getChildNodeEntries().get(0).getId());
View Full Code Here

        // corresponding child node entries
        bundle2.setParentId(bundle1.getId());
        bundle3.setParentId(bundle1.getId());

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(bundle1, bundle2, bundle3));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null);

        // run checker with fix = true
        checker.check(null, false, true, null);

        // node1 should now have child node entries for node2 and node3
        bundle1 = pm.loadBundle(bundle1.getId());
        assertEquals(2, bundle1.getChildNodeEntries().size());
        assertEquals(bundle2.getId(), bundle1.getChildNodeEntries().get(0).getId());
View Full Code Here

        NodePropBundle orphaned = new NodePropBundle(new NodeId(0, 1));
        // set non-existent parent node id
        orphaned.setParentId(new NodeId(1, 0));

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(lostAndFound, orphaned));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null);

        // run checker with fix = true
        checker.check(null, false, true, lostAndFound.getId().toString());

        // orphan should have been added to lost+found
        lostAndFound = pm.loadBundle(lostAndFound.getId());
        assertEquals(1, lostAndFound.getChildNodeEntries().size());
        assertEquals(orphaned.getId(), lostAndFound.getChildNodeEntries().get(0).getId());
View Full Code Here

        NodePropBundle orphaned = new NodePropBundle(orphanedId);
        // set non-existent parent node id
        orphaned.setParentId(new NodeId(1, 0));

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(lostAndFound, orphaned));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null, lostAndFoundId.toString(),
                master.createUpdateChannel("default"));

        // set up cluster event update listener
        final TestUpdateEventListener listener = new TestUpdateEventListener();
        final UpdateEventChannel slaveEventChannel = slave.createUpdateChannel("default");
        slaveEventChannel.setListener(listener);

        checker.check(null, false);

        Set<ReportItem> reportItems = checker.getReport().getItems();
        assertEquals(1, reportItems.size());
        ReportItem reportItem = reportItems.iterator().next();
        assertEquals(ReportItem.Type.ORPHANED, reportItem.getType());
        assertEquals(orphanedId.toString(), reportItem.getNodeId());

        checker.repair();

        // orphan should have been added to lost+found
        lostAndFound = pm.loadBundle(lostAndFoundId);
        assertEquals(1, lostAndFound.getChildNodeEntries().size());
        assertEquals(orphanedId, lostAndFound.getChildNodeEntries().get(0).getId());
View Full Code Here

    public void testDoubleCheckOrphanedNode() throws RepositoryException {
        NodePropBundle orphaned = new NodePropBundle(new NodeId(0, 1));
        orphaned.setParentId(new NodeId(1, 0));

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(orphaned));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null, null, null);

        checker.check(null, false);

        Set<ReportItem> reportItems = checker.getReport().getItems();
        assertEquals(1, reportItems.size());
        ReportItem reportItem = reportItems.iterator().next();
        assertEquals(ReportItem.Type.ORPHANED, reportItem.getType());
        assertEquals(orphaned.getId().toString(), reportItem.getNodeId());

        checker.doubleCheckErrors();

        assertFalse("Double check removed valid error", checker.getReport().getItems().isEmpty());

        // fix the error
        NodePropBundle parent = new NodePropBundle(orphaned.getParentId());
        pm.bundles.put(parent.getId(), parent);

        checker.doubleCheckErrors();

        assertTrue("Double check didn't remove invalid error", checker.getReport().getItems().isEmpty());
    }
View Full Code Here

        bundle2.addChildNodeEntry(nameFactory.create("", "test"), bundle3.getId());
        // node3 has node2 as parent
        bundle3.setParentId(bundle2.getId());

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(bundle1, bundle2, bundle3));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null, null, master.createUpdateChannel("default"));

        // set up cluster event update listener
        final TestUpdateEventListener listener = new TestUpdateEventListener();
        final UpdateEventChannel slaveEventChannel = slave.createUpdateChannel("default");
        slaveEventChannel.setListener(listener);

        checker.check(null, false);

        Set<ReportItem> reportItems = checker.getReport().getItems();
        assertEquals(1, reportItems.size());
        ReportItem reportItem = reportItems.iterator().next();
        assertEquals(ReportItem.Type.DISCONNECTED, reportItem.getType());
        assertEquals(bundle1.getId().toString(), reportItem.getNodeId());

        checker.repair();

        bundle1 = pm.loadBundle(bundle1.getId());
        bundle2 = pm.loadBundle(bundle2.getId());
        bundle3 = pm.loadBundle(bundle3.getId());
View Full Code Here

        bundle2.addChildNodeEntry(nameFactory.create("", "test"), bundle3.getId());
        // node3 has node2 as parent
        bundle3.setParentId(bundle2.getId());

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(bundle1, bundle2, bundle3));
        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null, null, null);

        checker.check(null, false);

        Set<ReportItem> reportItems = checker.getReport().getItems();
        assertEquals(1, reportItems.size());
        ReportItem reportItem = reportItems.iterator().next();
        assertEquals(ReportItem.Type.DISCONNECTED, reportItem.getType());
        assertEquals(bundle1.getId().toString(), reportItem.getNodeId());

        checker.doubleCheckErrors();

        assertFalse("Double check removed valid error", checker.getReport().getItems().isEmpty());

        // fix the error
        bundle1.getChildNodeEntries().remove(0);

        checker.doubleCheckErrors();

        assertTrue("Double check didn't remove invalid error", checker.getReport().getItems().isEmpty());
    }
View Full Code Here

        NodePropBundle bundle = new NodePropBundle(new NodeId(0, 0));
        bundle.addChildNodeEntry(nameFactory.create("", "test"), new NodeId(0, 1));

        MockPersistenceManager pm = new MockPersistenceManager(Arrays.asList(bundle));

        ConsistencyCheckerImpl checker = new ConsistencyCheckerImpl(pm, null, null, master.createUpdateChannel("default"));

        // set up cluster event update listener
        final TestUpdateEventListener listener = new TestUpdateEventListener();
        final UpdateEventChannel slaveEventChannel = slave.createUpdateChannel("default");
        slaveEventChannel.setListener(listener);

        checker.check(null, false);

        Set<ReportItem> reportItems = checker.getReport().getItems();
        assertEquals(1, reportItems.size());
        ReportItem reportItem = reportItems.iterator().next();
        assertEquals(ReportItem.Type.MISSING, reportItem.getType());
        assertEquals(bundle.getId().toString(), reportItem.getNodeId());

        checker.repair();

        // node should have no child no entries
        assertTrue(bundle.getChildNodeEntries().isEmpty());

        slave.sync();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.persistence.bundle.ConsistencyCheckerImpl$OrphanedNode

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.