@Test public void gcNRTDirsOnStart() throws Exception{ configureUniqueId(); File fa0 = dir.getIndexDir(getDefn(), "/a", "default"); File nrt0 = dir.getIndexDir(getDefn(), "/a", NRTIndex.generateDirName()); File nrt1 = dir.getIndexDir(getDefn(), "/a", NRTIndex.generateDirName()); dir = new IndexRootDirectory(temporaryFolder.getRoot()); assertFalse(nrt0.exists()); assertFalse(nrt1.exists()); assertTrue(fa0.exists()); }
public File getIndexDir(IndexDefinition definition, String indexPath, String dirName) throws IOException { String uid = definition.getUniqueId(); if (uid == null) { File baseFolder = getOldFormatDir(indexPath); String version = String.valueOf(definition.getReindexCount()); File indexDir = new File(baseFolder, version); if (!indexDir.exists()){ checkState(indexDir.mkdirs(), "Not able to create folder [%s]", indexDir); } return indexDir; } else { String fileSystemSafeName = getIndexFolderBaseName(indexPath); String folderName = fileSystemSafeName + "-" + uid; File baseFolder = new File(indexRootDir, folderName); if (!baseFolder.exists()){ checkState(baseFolder.mkdir(), "Not able to create folder [%s]", baseFolder); File readMe = new File(baseFolder, INDEX_METADATA_FILE_NAME); IndexMeta meta = new IndexMeta(indexPath, getTime()); meta.writeTo(readMe); } File indexFolder = new File(baseFolder, getFSSafeName(dirName)); if (!indexFolder.exists()) { checkState(indexFolder.mkdir(), "Not able to create folder [%s]", indexFolder); } return indexFolder; } }
IndexRootDirectory { public File getIndexDir(IndexDefinition definition, String indexPath, String dirName) throws IOException { String uid = definition.getUniqueId(); if (uid == null) { File baseFolder = getOldFormatDir(indexPath); String version = String.valueOf(definition.getReindexCount()); File indexDir = new File(baseFolder, version); if (!indexDir.exists()){ checkState(indexDir.mkdirs(), "Not able to create folder [%s]", indexDir); } return indexDir; } else { String fileSystemSafeName = getIndexFolderBaseName(indexPath); String folderName = fileSystemSafeName + "-" + uid; File baseFolder = new File(indexRootDir, folderName); if (!baseFolder.exists()){ checkState(baseFolder.mkdir(), "Not able to create folder [%s]", baseFolder); File readMe = new File(baseFolder, INDEX_METADATA_FILE_NAME); IndexMeta meta = new IndexMeta(indexPath, getTime()); meta.writeTo(readMe); } File indexFolder = new File(baseFolder, getFSSafeName(dirName)); if (!indexFolder.exists()) { checkState(indexFolder.mkdir(), "Not able to create folder [%s]", indexFolder); } return indexFolder; } } }
IndexRootDirectory { public File getIndexDir(IndexDefinition definition, String indexPath, String dirName) throws IOException { String uid = definition.getUniqueId(); if (uid == null) { File baseFolder = getOldFormatDir(indexPath); String version = String.valueOf(definition.getReindexCount()); File indexDir = new File(baseFolder, version); if (!indexDir.exists()){ checkState(indexDir.mkdirs(), "Not able to create folder [%s]", indexDir); } return indexDir; } else { String fileSystemSafeName = getIndexFolderBaseName(indexPath); String folderName = fileSystemSafeName + "-" + uid; File baseFolder = new File(indexRootDir, folderName); if (!baseFolder.exists()){ checkState(baseFolder.mkdir(), "Not able to create folder [%s]", baseFolder); File readMe = new File(baseFolder, INDEX_METADATA_FILE_NAME); IndexMeta meta = new IndexMeta(indexPath, getTime()); meta.writeTo(readMe); } File indexFolder = new File(baseFolder, getFSSafeName(dirName)); if (!indexFolder.exists()) { checkState(indexFolder.mkdir(), "Not able to create folder [%s]", indexFolder); } return indexFolder; } } IndexRootDirectory(File indexRootDir);  IndexRootDirectory(File indexRootDir, boolean gcOnStart); }
IndexRootDirectory { public File getIndexDir(IndexDefinition definition, String indexPath, String dirName) throws IOException { String uid = definition.getUniqueId(); if (uid == null) { File baseFolder = getOldFormatDir(indexPath); String version = String.valueOf(definition.getReindexCount()); File indexDir = new File(baseFolder, version); if (!indexDir.exists()){ checkState(indexDir.mkdirs(), "Not able to create folder [%s]", indexDir); } return indexDir; } else { String fileSystemSafeName = getIndexFolderBaseName(indexPath); String folderName = fileSystemSafeName + "-" + uid; File baseFolder = new File(indexRootDir, folderName); if (!baseFolder.exists()){ checkState(baseFolder.mkdir(), "Not able to create folder [%s]", baseFolder); File readMe = new File(baseFolder, INDEX_METADATA_FILE_NAME); IndexMeta meta = new IndexMeta(indexPath, getTime()); meta.writeTo(readMe); } File indexFolder = new File(baseFolder, getFSSafeName(dirName)); if (!indexFolder.exists()) { checkState(indexFolder.mkdir(), "Not able to create folder [%s]", indexFolder); } return indexFolder; } } IndexRootDirectory(File indexRootDir);  IndexRootDirectory(File indexRootDir, boolean gcOnStart); long getSize(); File getIndexDir(IndexDefinition definition, String indexPath, String dirName); List<LocalIndexDir> getAllLocalIndexes(); List<LocalIndexDir> getLocalIndexes(String jcrPath); long gcEmptyDirs(File subDir); }
IndexRootDirectory { public File getIndexDir(IndexDefinition definition, String indexPath, String dirName) throws IOException { String uid = definition.getUniqueId(); if (uid == null) { File baseFolder = getOldFormatDir(indexPath); String version = String.valueOf(definition.getReindexCount()); File indexDir = new File(baseFolder, version); if (!indexDir.exists()){ checkState(indexDir.mkdirs(), "Not able to create folder [%s]", indexDir); } return indexDir; } else { String fileSystemSafeName = getIndexFolderBaseName(indexPath); String folderName = fileSystemSafeName + "-" + uid; File baseFolder = new File(indexRootDir, folderName); if (!baseFolder.exists()){ checkState(baseFolder.mkdir(), "Not able to create folder [%s]", baseFolder); File readMe = new File(baseFolder, INDEX_METADATA_FILE_NAME); IndexMeta meta = new IndexMeta(indexPath, getTime()); meta.writeTo(readMe); } File indexFolder = new File(baseFolder, getFSSafeName(dirName)); if (!indexFolder.exists()) { checkState(indexFolder.mkdir(), "Not able to create folder [%s]", indexFolder); } return indexFolder; } } IndexRootDirectory(File indexRootDir);  IndexRootDirectory(File indexRootDir, boolean gcOnStart); long getSize(); File getIndexDir(IndexDefinition definition, String indexPath, String dirName); List<LocalIndexDir> getAllLocalIndexes(); List<LocalIndexDir> getLocalIndexes(String jcrPath); long gcEmptyDirs(File subDir); static final String INDEX_METADATA_FILE_NAME; }