1

In our test server we want to delete nodes. We use below code

        Repository repository = .... ;
        Session session = null;
        session = repository.login(new SimpleCredentials(getApplicationName(), getPassword().toCharArray()));

        JcrTools jcrTools = new JcrTools();

        if (!session.nodeExists(fileInfo.getRealPath())) {
            return;
        }
        Node node = session.getNode(fileInfo.getRealPath());
        //delete children nodes if exists  
        jcrTools.removeAllChildren(node);
        //delete all properties include mixins  
        PropertyIterator pIt = node.getProperties();
        while (pIt.hasNext()) {
            javax.jcr.Property property = pIt.nextProperty();
            property.remove();
        }
        node.remove();
        session.save();
        session.logout();

The method works, we see that the files are deleted from modeshape-explorer web application. But we also see that binary files are in the binaries folder of the repository, so the nodes are not removed physically, the disk usage does not alter. What may be the problem?

mcvkr
  • 3,209
  • 6
  • 38
  • 63

1 Answers1

3

Unused binary values will eventually be removed in a background thread, which by defaults executes once per day.

You can easily configure this via the repository's JSON configuration. For example:

{
  ...
  "garbageCollection" : {
    "threadPool" : "modeshape-gc-pool",
    "initialTime" : "00:00",
    "intervalInHours" : 24,
  }
  ...
}

The values shown above are the defaults, but obviously you can change them and include only those non-default fields that make sense.

Randall Hauch
  • 7,069
  • 31
  • 28
  • Thanks Randall. Well, is there a way to call the related thread more frequently? – mcvkr Aug 22 '14 at 13:43
  • 1
    Since I use modeshape as a Jboss subsystem, I made the configuration with the `/subsystem=modeshape/repository=sample:write-attribute(name=garbage-collection-interval,value="1")` command on Jboss command line interface (CLI). Similarly, adding the line `` to the standalone.xml for modeshape subsystem does the same job. But I still see the deleted file binaries on my disk. – mcvkr Aug 25 '14 at 11:04
  • 1
    It's fine to set the interval, but did you set the time at which the next jobs are run? We use a scheduled executor for this, so it's quite likely that the job does not run until the prescribed time. Also, make sure that your BINARY values are not used anymore anywhere in the content (including version history). Try upgrading to the latest releases (if you're not on it already). Finally, if you think there's a problem, please file a bug report and provide a simple test case that demonstrates the problem. – Randall Hauch Aug 25 '14 at 14:16
  • How can I set the time for the scheduler and confirm that ? I understand that it is something different than `garbage-collection-initial-time` . – mcvkr Sep 19 '14 at 14:09