AnsweredAssumed Answered

Contentstore caching, number of open files problem

Question asked by sebgymn on Jan 31, 2012
Latest reply on Feb 13, 2012 by sebgymn
Hello, this is my first post in this forum.

I have a relatively large alfresco repository of 300 gb and I want to export some of the files within it to local filesystem. I have written a code using jcr api, like this:

   private void recursiveExport (Node root, String exportDir) throws RepositoryException, IOException {
      if(root==null) {
      String currentDir = String.format("%s%s%s", exportDir, File.separator, root.getName().substring(root.getName().lastIndexOf(":")+1));
         new File(currentDir).mkdirs();
         for(NodeIterator iterator = root.getNodes(); iterator.hasNext(); ){
            Node child = iterator.nextNode();
            recursiveExport(child, currentDir+File.separator);
            child = null;
         FileOutputStream fos = new FileOutputStream(currentDir);
         Property prop = root.getProperty("cm:content");
         IOUtils.copy(prop.getStream(), fos);

         prop = null;
         root = null;
         fos = null;
      }"%s exported.", currentDir));

I call this method with the root folder that I want to export. The code runs smoothly, however my problem is the number of open files while using this. Somehow alfresco does not close the file handles, leading to excess resource usage, as it can be checked with this command:
ls -1 /proc/`pidof java`/fd | wc -l 
The number of open files grows to high numbers (80000 in half an hour, my ulimit -n is 819200). I want this to exactly work like I have written the above code, opening the file, exporting it, and closing the streams, simple. I have checked which files are open, and they are *.bin files inside contentstore, so I suspect there is some configuration issues about it.

Can anybody lead me out of this situation? Thanks in advance