DataUpdateManager { public void deleteData(String collection, String schedule, DateTime minTime, DateTime maxTime) throws Exception { Lock lock = collectionLocks.get(collection); if (lock == null) { collectionLocks.putIfAbsent(collection, new ReentrantLock()); lock = collectionLocks.get(collection); } lock.lock(); LOGGER.info("Locked collection {} using lock {} for data delete", collection, lock); try { final String dataDirPrefix = StorageUtils.getDataDirPrefix(schedule, minTime, maxTime); File collectionDir = new File(rootDir, collection); File[] matchingDirs = collectionDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.startsWith(dataDirPrefix); } }); if (matchingDirs == null || matchingDirs.length == 0) { throw new FileNotFoundException("No directory with prefix " + dataDirPrefix); } for (File dataDir : matchingDirs) { FileUtils.forceDelete(dataDir); LOGGER.info("Deleted {}", dataDir); } } finally { lock.unlock(); LOGGER.info("Unlocked collection {} using lock {} for data delete", collection, lock); } } DataUpdateManager(File rootDir, boolean autoExpire); void deleteCollection(String collection); void deleteData(String collection,
                         String schedule,
                         DateTime minTime,
                         DateTime maxTime); void deleteData(String collection, String schedule, DateTime maxTime); void updateData(String collection,
                         String schedule,
                         DateTime minTime,
                         DateTime maxTime,
                         byte[] data); void updateData(String collection,
                         String schedule,
                         DateTime minTime,
                         DateTime maxTime,
                         InputStream data); void expireSegments(File collectionDir, DateTime minTime, DateTime maxTime, String schedule); void persistTree(String collection,
                          String schedule,
                          DateTime minTime,
                          DateTime maxTime,
                          final StarTree starTree); StarTree mergeTrees(Collection<StarTree> starTrees);  }
@Test public void testDeleteData() throws Exception { File collectionDir = new File(rootDir, collection); File dataDir = new File(collectionDir, StorageUtils.getDataDirName(treeId, schedule, minTime, maxTime)); FileUtils.forceMkdir(dataDir); Assert.assertTrue(dataDir.exists()); dataUpdateManager.deleteData(collection, schedule, minTime, maxTime); Assert.assertFalse(dataDir.exists()); }