test_class.declarator: rnd = new Random()
test_class.modifier: private
test_class.original_string: private Random rnd = new Random();
test_class.type: Random
test_class.var_name: rnd
test_class.declarator: local = new RAMDirectory()
test_class.modifier: private
test_class.original_string: private Directory local = new RAMDirectory();
test_class.type: Directory
test_class.var_name: local
test_class.declarator: remote = new RAMDirectory()
test_class.modifier: private
test_class.original_string: private Directory remote = new RAMDirectory();
test_class.type: Directory
test_class.var_name: remote
test_class.file: oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexSanityCheckerTest.java
test_class.identifier: IndexSanityCheckerTest
test_case.body: @Test
      public void extraLocalFiles() throws Exception{
          byte[] t1L = writeFile(local, "t1", 100);
          byte[] t3R = writeFile(remote, "t3", 140);
          writeFile(local, "t3", t3R);
  
          new IndexSanityChecker("/foo", local, remote).check();
  
          //t1 exist in local but not in remote
          //it must be removed
          assertFalse(local.fileExists("t1"));
  
          //t3 should remain present
          assertTrue(remote.fileExists("t3"));
      }
test_case.class_method_signature: IndexSanityCheckerTest.extraLocalFiles()
test_case.full_signature: @Test public void extraLocalFiles()
test_case.identifier: extraLocalFiles
test_case.invocations: writeFile writeFile writeFile check assertFalse fileExists assertTrue fileExists
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void extraLocalFiles()
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: local
focal_class.modifier: private final
focal_class.original_string: private final Directory local;
focal_class.type: Directory
focal_class.var_name: local
focal_class.declarator: remote
focal_class.modifier: private final
focal_class.original_string: private final Directory remote;
focal_class.type: Directory
focal_class.var_name: remote
focal_class.declarator: indexPath
focal_class.modifier: private final
focal_class.original_string: private final String indexPath;
focal_class.type: String
focal_class.var_name: indexPath
focal_class.declarator: localFileCount
focal_class.modifier: private
focal_class.original_string: private int localFileCount;
focal_class.type: int
focal_class.var_name: localFileCount
focal_class.declarator: remoteFileCount
focal_class.modifier: private
focal_class.original_string: private int remoteFileCount;
focal_class.type: int
focal_class.var_name: remoteFileCount
focal_class.declarator: localDirSize
focal_class.modifier: private
focal_class.original_string: private long localDirSize;
focal_class.type: long
focal_class.var_name: localDirSize
focal_class.declarator: remoteDirSize
focal_class.modifier: private
focal_class.original_string: private long remoteDirSize;
focal_class.type: long
focal_class.var_name: remoteDirSize
focal_class.file: oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexSanityChecker.java
focal_class.identifier: IndexSanityChecker
focal_class.class_method_signature: IndexSanityChecker.IndexSanityChecker(String indexPath, Directory local, Directory remote)
focal_class.full_signature: public  IndexSanityChecker(String indexPath, Directory local, Directory remote)
focal_class.identifier: IndexSanityChecker
focal_class.modifiers: public
focal_class.parameters: (String indexPath, Directory local, Directory remote)
focal_class.signature:  IndexSanityChecker(String indexPath, Directory local, Directory remote)
focal_class.class_method_signature: IndexSanityChecker.check()
focal_class.full_signature: public boolean check()
focal_class.identifier: check
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean check()
focal_class.class_method_signature: IndexSanityChecker.isThereASizeMismatch()
focal_class.full_signature: private boolean isThereASizeMismatch()
focal_class.identifier: isThereASizeMismatch
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isThereASizeMismatch()
focal_class.class_method_signature: IndexSanityChecker.deleteAllFiles(Directory dir)
focal_class.full_signature: private static void deleteAllFiles(Directory dir)
focal_class.identifier: deleteAllFiles
focal_class.modifiers: private static
focal_class.parameters: (Directory dir)
focal_class.return: void
focal_class.signature: void deleteAllFiles(Directory dir)
focal_method.body: public boolean check() throws IOException {
          boolean allFine = true;
          //TODO Add support for checksum based checks
          if (isThereASizeMismatch()){
              //In case of any mismatch just purge all local files
              deleteAllFiles(local);
              allFine = false;
          } else {
              //Remove local files which are not found in remote
              for (String fileName : local.listAll()) {
                  if (!remote.fileExists(fileName)) {
                      local.deleteFile(fileName);
                  }
              }
          }
  
          if (allFine) {
              log.info("Local index directory content found to be valid for index [{}]. " +
                      "Stats Local: {} files ({}), Remote: {} files ({})", indexPath,
                      localFileCount, IOUtils.humanReadableByteCount(localDirSize),
                      remoteFileCount, IOUtils.humanReadableByteCount(remoteDirSize));
          } else {
              log.warn("Local index directory content were not found to be in sync with remote for index [{}]. " +
                      "Local directory content has been purged and would be synced again from remote", indexPath);
          }
          return allFine;
      }
focal_method.class_method_signature: IndexSanityChecker.check()
focal_method.full_signature: public boolean check()
focal_method.identifier: check
focal_method.invocations: isThereASizeMismatch deleteAllFiles listAll fileExists deleteFile info humanReadableByteCount humanReadableByteCount warn
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: boolean
focal_method.signature: boolean check()