0 Replies Latest reply on Oct 24, 2017 3:31 PM by Rakesh K

    Modeshape delete node and recover space on File system

    Rakesh K Newbie

      I'm using Modeshape 5.4.0 with File system persistence. I'm storing all the subsequent files/resources in this particular node (/uploads) which is of type "nt:folder". I deleted all the nodes in the /uploads node by using the below code.

       

       public void deleteNode(String path) {
          try {
              JcrTools jcrTools = new JcrTools(false);
              jcrTools.printSubgraph(session.getNode(path));
              NodeIterator iter = session.getNode(path).getNodes();
              while (iter.hasNext()) {
                  Node child = iter.nextNode();
                    if(!child.getName().contains("jcr:system")) { 
                        jcrTools.removeAllChildren(child);
                        child.remove();
                        session.save();
                    }
              }
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
      

       

       

      But when I see my persistence folder size it's still the same and never reduces even when I delete huge files (~1-2 GB). Later I read somewhere that Modeshape has a garbage collector which runs periodically. How do I trigger this GC manually? Am I deleting the nodes in the right manner? Please help.

      My config JSON is as follows

      {
      "name": "TestRepository",
      "node-types": ["custom-props.cnd"],
      "jndiName": "jcr/TestRepo",
      "monitoring": {
         "enabled": true
      },
      "workspaces": {
         "default": "defaultWorkspace",
         "predefined": ["otherWorkspace"],
         "allowCreation": true
      },
      "storage": {
      
         "persistence": {
         "type": "file",
         "path": "D:\\repository"
         },
         "binaryStorage": {
         "type": "file",
         "directory": "D:\\repository\\binaries",
         "trash": "D:\\repository\\binaries\\trash"
         }
      
      },
      "garbageCollection": {
         "initialTime": "11:46",
         "intervalInHours": 1
      }
      }

       

       

      Even after specifying initial time and interval, my GC never runs.