Hi, The code looks good to me. Maybe you are using versioning, so the old binaries are still referenced?
Regards, Thomas On 27/08/14 09:43, "Vikram Vaswani" <vikram.vasw...@loudcloudsystems.com> wrote: >Hi all > > >I have a Jackrabbit 2.8.0 setup and am using MySQL as the backend for the >data store, versioning etc. Our repository is quite active with 100+ >documents being added daily. When a new document is added, I can see that >a new record is also added to the datastore table in MySQL > > >I am trying to find a way to have Jackrabbit automatically delete unused >(relating to deleted content) records from the datastore table. I have >read about Jackrabbit's garbage collection and I created a servlet to try >and use this. > > >Despite my best efforts however, when I run the servlet code there is no >removal of records from the datastore table, even though I know for a >fact that there are a high number of records referencing >previously-deleted docs. > > >My servlet code is below, runs on Tomcat, please could you help me >identify what I might be doing wrong? > > >@WebServlet("/GCServlet") >public class GCServlet extends HttpServlet { > > private static org.apache.log4j.Logger logger = >org.apache.log4j.Logger.getLogger(GCServlet.class); > private static final long serialVersionUID = 1L; > private List<RepositoryManager> repositoryManagers; > /** > * @see HttpServlet#HttpServlet() > */ > public GCServlet() { > super(); > // TODO Auto-generated constructor stub > } > > /** > * Runs the garbage collector for the given RepositoryManagers. If >multiple > * repositories use the same data store, give all RepositoryManagers >in the > * parameter list. > * > * @param rms > * @throws RepositoryException > */ > @SuppressWarnings(value="DM_GC") > private int runDataStoreGarbageCollector(OutputStream out) > throws RepositoryException { > int result = 0; > JackrabbitRepositoryFactory rf = new RepositoryFactoryImpl(); > Properties prop = new Properties(); > ServletContext servletContext = getServletContext(); > String path = servletContext.getRealPath("."); > System.out.println("Real Path =>"+path); > prop.setProperty("org.apache.jackrabbit.repository.home", >"/opt/jackrabbit"); > prop.setProperty("org.apache.jackrabbit.repository.conf", >"/opt/jackrabbit/repository.xml"); > JackrabbitRepository rep = (JackrabbitRepository) >rf.getRepository(prop); > // need to login to start the repository > Session session = rep.login(new SimpleCredentials("admin", >"admin".toCharArray())); > RepositoryManager rm = rf.getRepositoryManager(rep); > DataStoreGarbageCollector gc = >rm.createDataStoreGarbageCollector(); > try { > gc.mark(); > gc.sweep(); > > } finally { > gc.close(); > } > > session.logout(); > rm.stop(); > return result; > } > > /** > * @see HttpServlet#doGet(HttpServletRequest request, >HttpServletResponse response) > */ > protected void doGet(HttpServletRequest request, HttpServletResponse >response) throws ServletException, IOException { > String gcEnabled = request.getParameter("gcExecute"); > System.out.println("gcEnabled=="+gcEnabled+" length = >"+gcEnabled.length()); > response.setContentType("text/html"); > OutputStream outputStream = response.getOutputStream(); > outputStream.write("<html><body>Starting Garbage Collection ><p/>".getBytes()); > if (gcEnabled.equals("1")) { > try { > int result = runDataStoreGarbageCollector(outputStream); > outputStream.write(result); > > } catch (RepositoryException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > logger.error(e); > }finally { > outputStream.close(); > } > } > outputStream.write("</body></html>".getBytes()); > outputStream.flush(); > } > > >I have also attached the relevant section of the Tomcat log file. > > >Vikram > > > >________________________________ >This email may contain proprietary, privileged and confidential >information and is sent for the intended recipient(s) only. If, by an >addressing or transmission error, this mail has been misdirected to you, >you are requested to notify us immediately by return email message and >delete this email and its attachments. You are also hereby notified that >any use, any form of reproduction, dissemination, copying, disclosure, >modification, distribution and/or publication of this email message, >contents or its attachment(s) other than by its intended recipient(s) is >strictly prohibited. Any opinions expressed in this email are those of >the individual and may not necessarily represent those of LoudCloud >Systems. Before opening attachment(s), please scan for viruses. It is >further notified that email transmission cannot be guaranteed to be >secure or error-free as information could be intercepted, corrupted, >lost, destroyed, arrive late or incomplete, or may contain viruses. The >sender therefore does not accept liability for any error or omission in >the contents of this message, which arise as a result of email >transmission. LoudCloud Systems Inc. and its subsidiaries do not accept >liability for damage caused by this email or any attachments and may >monitor email traffic. >________________________________