test_class.declarator: temporaryFolder = new TemporaryFolder(new File("target"))
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public TemporaryFolder temporaryFolder = new TemporaryFolder(new File("target"));
test_class.type: TemporaryFolder
test_class.var_name: temporaryFolder
test_class.declarator: dir
test_class.modifier: private
test_class.original_string: private IndexRootDirectory dir;
test_class.type: IndexRootDirectory
test_class.var_name: dir
test_class.declarator: root = INITIAL_CONTENT
test_class.modifier: private
test_class.original_string: private NodeState root = INITIAL_CONTENT;
test_class.type: NodeState
test_class.var_name: root
test_class.declarator: builder = EMPTY_NODE.builder()
test_class.modifier: private
test_class.original_string: private NodeBuilder builder = EMPTY_NODE.builder();
test_class.type: NodeBuilder
test_class.var_name: builder
test_class.file: oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectoryTest.java
test_class.identifier: IndexRootDirectoryTest
test_case.body: @Test
      public void gcIndexDirs() throws Exception{
          //Create an old format directory
          File fa0 = dir.getIndexDir(getDefn(), "/a", "default");
  
          configureUniqueId();
          File fa1 = dir.getIndexDir(getDefn(), "/a", "default");
          configureUniqueId();
          File fa2 = dir.getIndexDir(getDefn(), "/a", "default");
  
          List<LocalIndexDir> dirs = dir.getLocalIndexes("/a");
          assertEquals(2, dirs.size());
  
          dir.gcEmptyDirs(fa2);
          //No index dir should be removed. Even empty ones
          assertEquals(2, dirs.size());
  
          configureUniqueId();
          File fa3 = dir.getIndexDir(getDefn(), "/a", "default");
  
          assertEquals(3, dir.getLocalIndexes("/a").size());
  
          //Dir size should still be 3 as non empty dir cannot be be collected
          dir.gcEmptyDirs(fa3);
          assertEquals(3, dir.getLocalIndexes("/a").size());
  
          //Now get rid of 'default' for the first localDir dir i.e. fa1
          FileUtils.deleteQuietly(fa1);
          dir.gcEmptyDirs(fa1);
  
          assertEquals(2, dir.getLocalIndexes("/a").size());
          assertFalse(fa0.exists());
  
          FileUtils.deleteDirectory(fa2);
          FileUtils.deleteDirectory(fa3);
  
          //Note that we deleted both fa2 and fa3 but GC was done based on fa2 (fa2 < fa3)
          //So only dirs which are of same time or older than fa2 would be removed. So in this
          //case fa3 would be left
          dir.gcEmptyDirs(fa2);
          assertEquals(1, dir.getLocalIndexes("/a").size());
      }
test_case.class_method_signature: IndexRootDirectoryTest.gcIndexDirs()
test_case.full_signature: @Test public void gcIndexDirs()
test_case.identifier: gcIndexDirs
test_case.invocations: getIndexDir getDefn configureUniqueId getIndexDir getDefn configureUniqueId getIndexDir getDefn getLocalIndexes assertEquals size gcEmptyDirs assertEquals size configureUniqueId getIndexDir getDefn assertEquals size getLocalIndexes gcEmptyDirs assertEquals size getLocalIndexes deleteQuietly gcEmptyDirs assertEquals size getLocalIndexes assertFalse exists deleteDirectory deleteDirectory gcEmptyDirs assertEquals size getLocalIndexes
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void gcIndexDirs()
focal_class.declarator: MAX_NAME_LENGTH = 127
focal_class.modifier: static final
focal_class.original_string: static final int MAX_NAME_LENGTH = 127;
focal_class.type: int
focal_class.var_name: MAX_NAME_LENGTH
focal_class.declarator: INDEX_METADATA_FILE_NAME = "index-details.txt"
focal_class.modifier: public static final
focal_class.original_string: public static final String INDEX_METADATA_FILE_NAME = "index-details.txt";
focal_class.type: String
focal_class.var_name: INDEX_METADATA_FILE_NAME
focal_class.declarator: LOCAL_DIR_FILTER = new FileFilter() {
          @Override
          public boolean accept(File file) {
              if (!file.isDirectory()) {
                  return false;
              }
              File metaFile = new File(file, INDEX_METADATA_FILE_NAME);
              return metaFile.exists();
          }
      }
focal_class.modifier: private static final
focal_class.original_string: private static final FileFilter LOCAL_DIR_FILTER = new FileFilter() {
          @Override
          public boolean accept(File file) {
              if (!file.isDirectory()) {
                  return false;
              }
              File metaFile = new File(file, INDEX_METADATA_FILE_NAME);
              return metaFile.exists();
          }
      };
focal_class.type: FileFilter
focal_class.var_name: LOCAL_DIR_FILTER
focal_class.declarator: log = LoggerFactory.getLogger(getClass())
focal_class.modifier: private final
focal_class.original_string: private final Logger log = LoggerFactory.getLogger(getClass());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: indexRootDir
focal_class.modifier: private final
focal_class.original_string: private final File indexRootDir;
focal_class.type: File
focal_class.var_name: indexRootDir
focal_class.file: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java
focal_class.identifier: IndexRootDirectory
focal_class.class_method_signature: IndexRootDirectory.IndexRootDirectory(File indexRootDir)
focal_class.full_signature: public  IndexRootDirectory(File indexRootDir)
focal_class.identifier: IndexRootDirectory
focal_class.modifiers: public
focal_class.parameters: (File indexRootDir)
focal_class.signature:  IndexRootDirectory(File indexRootDir)
focal_class.class_method_signature: IndexRootDirectory.IndexRootDirectory(File indexRootDir, boolean gcOnStart)
focal_class.full_signature: public  IndexRootDirectory(File indexRootDir, boolean gcOnStart)
focal_class.identifier: IndexRootDirectory
focal_class.modifiers: public
focal_class.parameters: (File indexRootDir, boolean gcOnStart)
focal_class.signature:  IndexRootDirectory(File indexRootDir, boolean gcOnStart)
focal_class.class_method_signature: IndexRootDirectory.getSize()
focal_class.full_signature: public long getSize()
focal_class.identifier: getSize
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getSize()
focal_class.class_method_signature: IndexRootDirectory.getIndexDir(IndexDefinition definition, String indexPath, String dirName)
focal_class.full_signature: public File getIndexDir(IndexDefinition definition, String indexPath, String dirName)
focal_class.identifier: getIndexDir
focal_class.modifiers: public
focal_class.parameters: (IndexDefinition definition, String indexPath, String dirName)
focal_class.return: File
focal_class.signature: File getIndexDir(IndexDefinition definition, String indexPath, String dirName)
focal_class.class_method_signature: IndexRootDirectory.getAllLocalIndexes()
focal_class.full_signature: public List<LocalIndexDir> getAllLocalIndexes()
focal_class.identifier: getAllLocalIndexes
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: List<LocalIndexDir>
focal_class.signature: List<LocalIndexDir> getAllLocalIndexes()
focal_class.class_method_signature: IndexRootDirectory.getLocalIndexes(String jcrPath)
focal_class.full_signature: public List<LocalIndexDir> getLocalIndexes(String jcrPath)
focal_class.identifier: getLocalIndexes
focal_class.modifiers: public
focal_class.parameters: (String jcrPath)
focal_class.return: List<LocalIndexDir>
focal_class.signature: List<LocalIndexDir> getLocalIndexes(String jcrPath)
focal_class.class_method_signature: IndexRootDirectory.gcEmptyDirs(File subDir)
focal_class.full_signature: public long gcEmptyDirs(File subDir)
focal_class.identifier: gcEmptyDirs
focal_class.modifiers: public
focal_class.parameters: (File subDir)
focal_class.return: long
focal_class.signature: long gcEmptyDirs(File subDir)
focal_class.class_method_signature: IndexRootDirectory.getIndexFolderBaseName(String indexPath)
focal_class.full_signature: static String getIndexFolderBaseName(String indexPath)
focal_class.identifier: getIndexFolderBaseName
focal_class.modifiers: static
focal_class.parameters: (String indexPath)
focal_class.return: String
focal_class.signature: String getIndexFolderBaseName(String indexPath)
focal_class.class_method_signature: IndexRootDirectory.getPathHash(String indexPath)
focal_class.full_signature: static String getPathHash(String indexPath)
focal_class.identifier: getPathHash
focal_class.modifiers: static
focal_class.parameters: (String indexPath)
focal_class.return: String
focal_class.signature: String getPathHash(String indexPath)
focal_class.class_method_signature: IndexRootDirectory.getIndexesPerPath()
focal_class.full_signature: private Map<String, List<LocalIndexDir>> getIndexesPerPath()
focal_class.identifier: getIndexesPerPath
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Map<String, List<LocalIndexDir>>
focal_class.signature: Map<String, List<LocalIndexDir>> getIndexesPerPath()
focal_class.class_method_signature: IndexRootDirectory.gcIndexDirs()
focal_class.full_signature: private void gcIndexDirs()
focal_class.identifier: gcIndexDirs
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void gcIndexDirs()
focal_class.class_method_signature: IndexRootDirectory.gcNRTIndexDirs(LocalIndexDir idxDir)
focal_class.full_signature: private long gcNRTIndexDirs(LocalIndexDir idxDir)
focal_class.identifier: gcNRTIndexDirs
focal_class.modifiers: private
focal_class.parameters: (LocalIndexDir idxDir)
focal_class.return: long
focal_class.signature: long gcNRTIndexDirs(LocalIndexDir idxDir)
focal_class.class_method_signature: IndexRootDirectory.findMatchingIndexDir(File dir)
focal_class.full_signature: @Nullable private LocalIndexDir findMatchingIndexDir(File dir)
focal_class.identifier: findMatchingIndexDir
focal_class.modifiers: @Nullable private
focal_class.parameters: (File dir)
focal_class.return: LocalIndexDir
focal_class.signature: LocalIndexDir findMatchingIndexDir(File dir)
focal_class.class_method_signature: IndexRootDirectory.deleteOldFormatDir(String jcrPath)
focal_class.full_signature: private long deleteOldFormatDir(String jcrPath)
focal_class.identifier: deleteOldFormatDir
focal_class.modifiers: private
focal_class.parameters: (String jcrPath)
focal_class.return: long
focal_class.signature: long deleteOldFormatDir(String jcrPath)
focal_class.class_method_signature: IndexRootDirectory.getOldFormatDir(String indexPath)
focal_class.full_signature: private File getOldFormatDir(String indexPath)
focal_class.identifier: getOldFormatDir
focal_class.modifiers: private
focal_class.parameters: (String indexPath)
focal_class.return: File
focal_class.signature: File getOldFormatDir(String indexPath)
focal_class.class_method_signature: IndexRootDirectory.getFSSafeName(String e)
focal_class.full_signature: static String getFSSafeName(String e)
focal_class.identifier: getFSSafeName
focal_class.modifiers: static
focal_class.parameters: (String e)
focal_class.return: String
focal_class.signature: String getFSSafeName(String e)
focal_class.class_method_signature: IndexRootDirectory.getTime()
focal_class.full_signature: private static long getTime()
focal_class.identifier: getTime
focal_class.modifiers: private static
focal_class.parameters: ()
focal_class.return: long
focal_class.signature: long getTime()
focal_method.body: private void gcIndexDirs() throws IOException {
          Map<String, List<LocalIndexDir>> mapping = getIndexesPerPath();
          long totalDeletedSize = 0;
          for (Map.Entry<String, List<LocalIndexDir>> e : mapping.entrySet()) {
              List<LocalIndexDir> dirs = e.getValue();
              //In startup mode we can be sure that no directory is in use
              //so be more aggressive in what we delete i.e. even not empty dir
              for (int i = 1; i < dirs.size(); i++) {
                  LocalIndexDir dir = dirs.get(i);
                  long dirSize = FileUtils.sizeOf(dir.dir);
                  if (FileUtils.deleteQuietly(dir.dir)){
                      totalDeletedSize += dirSize;
                  } else {
                      log.warn("Not able to deleted unused local index directory [{}]. " +
                              "Deletion would be retried later again.",  dir);
                  }
              }
  
              if (!dirs.isEmpty()) {
                  totalDeletedSize += gcNRTIndexDirs(dirs.get(0));
              }
              totalDeletedSize += deleteOldFormatDir(dirs.get(0).getJcrPath());
          }
  
          if (totalDeletedSize > 0){
              log.info("Reclaimed [{}] space by removing unused/old index directories",
                      IOUtils.humanReadableByteCount(totalDeletedSize));
          }
      }
focal_method.class_method_signature: IndexRootDirectory.gcIndexDirs()
focal_method.full_signature: private void gcIndexDirs()
focal_method.identifier: gcIndexDirs
focal_method.invocations: getIndexesPerPath entrySet getValue size get sizeOf deleteQuietly warn isEmpty gcNRTIndexDirs get deleteOldFormatDir getJcrPath get info humanReadableByteCount
focal_method.modifiers: private
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void gcIndexDirs()