Package org.apache.jackrabbit.api.management

Examples of org.apache.jackrabbit.api.management.DataStoreGarbageCollector


        RepositoryManager rm = rf.getRepositoryManager(rep);

        // need to login to start the repository
        Session session = rep.login(new SimpleCredentials("", "".toCharArray()));

        DataStoreGarbageCollector gc = rm.createDataStoreGarbageCollector();
        try {
            gc.mark();
            gc.sweep();
        } finally {
            gc.close();
        }

        session.logout();
        rm.stop();
    }
View Full Code Here


    private static final Logger LOG = LoggerFactory.getLogger(GarbageCollectorTest.class);

    public void testCloseSessionWhileRunningGc() throws Exception {
        final Session session = getHelper().getReadWriteSession();

        final DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
        final Exception[] ex = new Exception[1];
        gc.setMarkEventListener(new MarkEventListener() {
            boolean closed;

            public void beforeScanning(Node n) throws RepositoryException {
                closeTest();
            }

            private void closeTest() throws RepositoryException {
                if (closed) {
                    ex[0] = new Exception("Scanning after the session is closed");
                }
                closed = true;
                session.logout();
            }

        });
        try {
            gc.mark();
            fail("Exception 'session has been closed' expected");
        } catch (RepositoryException e) {
            LOG.debug("Expected exception caught: " + e.getMessage());
        }
        if (ex[0] != null) {
            throw ex[0];
        }
        gc.close();
    }
View Full Code Here

                    e.printStackTrace();
                }
            }
        }.start();
        assertEquals("x", sync.take());
        DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
        gc.mark();
        gc.sweep();
        sync.put("deleted");
        assertEquals("saved", sync.take());
        InputStream in = node.getProperty("slowBlob").getBinary().getStream();
        for (int pos = 1; pos < blobLength; pos++) {
            int expected = pos % 80 == 0 ? '\n' : '.';
            assertEquals(expected, in.read());
        }
        assertEquals('x', in.read());
        in.close();
        gc.close();
    }
View Full Code Here

    private static final Logger LOG = LoggerFactory.getLogger(GarbageCollectorTest.class);

    public void testCloseSessionWhileRunningGc() throws Exception {
        final Session session = getHelper().getReadWriteSession();

        final DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
        gc.setPersistenceManagerScan(false);
        final Exception[] ex = new Exception[1];
        gc.setMarkEventListener(new MarkEventListener() {
            boolean closed;

            public void beforeScanning(Node n) throws RepositoryException {
                closeTest();
            }

            private void closeTest() {
                if (closed) {
                    ex[0] = new Exception("Scanning after the session is closed");
                }
                closed = true;
                session.logout();
            }

        });
        try {
            gc.mark();
            fail("Exception 'session has been closed' expected");
        } catch (RepositoryException e) {
            LOG.debug("Expected exception caught: " + e.getMessage());
        }
        if (ex[0] != null) {
            throw ex[0];
        }
        gc.close();
    }
View Full Code Here

                    e.printStackTrace();
                }
            }
        }.start();
        assertEquals("x", sync.take());
        DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
        gc.setPersistenceManagerScan(false);
        gc.mark();
        gc.sweep();
        sync.put("deleted");
        assertEquals("saved", sync.take());
        InputStream in = node.getProperty("slowBlob").getBinary().getStream();
        for (int pos = 1; pos < blobLength; pos++) {
            int expected = pos % 80 == 0 ? '\n' : '.';
            assertEquals(expected, in.read());
        }
        assertEquals('x', in.read());
        in.close();
        gc.close();
    }
View Full Code Here

        RepositoryManager rm = rf.getRepositoryManager(rep);

        // need to login to start the repository
        Session session = rep.login();

        DataStoreGarbageCollector gc = rm.createDataStoreGarbageCollector();
        try {
            gc.mark();
            gc.sweep();
        } finally {
            gc.close();
        }

        session.logout();
        rm.stop();
    }
View Full Code Here

        Session session = root.getSession();

        final String testNodeName = "testConcurrentDelete";
        node(root, testNodeName);
        session.save();
        DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
        gc.setPersistenceManagerScan(false);
        gc.setMarkEventListener(new MarkEventListener() {
            public void beforeScanning(Node n) throws RepositoryException {
                if (n.getName().equals(testNodeName)) {
                    n.remove();
                    n.getSession().save();
                }
            }

        });
        gc.mark();
        gc.close();
    }
View Full Code Here

                session.save();
            }
        }
        session.save();
        SessionImpl si = (SessionImpl) session;
        DataStoreGarbageCollector gc = si.createDataStoreGarbageCollector();
        DataStore ds = ((GarbageCollector) gc).getDataStore();
        if (ds != null) {
            ds.clearInUse();
            boolean pmScan = gc.isPersistenceManagerScan();
            gc.setPersistenceManagerScan(allowPmScan);
            gotNullNode = false;
            gotNode = false;
            gc.setMarkEventListener(this);
            gc.mark();
            if (pmScan && allowPmScan) {
                assertTrue("PM scan without null Node", gotNullNode);
                assertFalse("PM scan, but got a real node", gotNode);
            } else {
                assertFalse("Not a PM scan - but got a null Node", gotNullNode);
                assertTrue("Not a PM scan - without a real node", gotNode);
            }
            int deleted = gc.sweep();
            LOG.debug("Deleted " + deleted);
            assertTrue("Should delete at least one item", deleted >= 0);
            gc.close();
        }
    }
View Full Code Here

        RepositoryManager rm = rf.getRepositoryManager(rep);

        // need to login to start the repository
        Session session = rep.login(new SimpleCredentials("", "".toCharArray()));

        DataStoreGarbageCollector gc = rm.createDataStoreGarbageCollector();
        try {
            gc.mark();
            gc.sweep();
        } finally {
            gc.close();
        }

        session.logout();
        rm.stop();
    }
View Full Code Here

            return;
        }
        final String testNodeName = "testConcurrentDelete";
        node(root, testNodeName);
        session.save();
        DataStoreGarbageCollector gc = ((SessionImpl) session).createDataStoreGarbageCollector();
        gc.setPersistenceManagerScan(false);
        gc.setMarkEventListener(new MarkEventListener() {
            public void beforeScanning(Node n) throws RepositoryException {
                if (n.getName().equals(testNodeName)) {
                    n.remove();
                    n.getSession().save();
                }
            }

        });
        gc.mark();
        gc.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.management.DataStoreGarbageCollector

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.