/** * This method tries to delete a file. If it is not able to delete file due * to any reason, it add it toBeDeleted list. * * @param fileName name of the file which will be deleted. * @return true if this method deletes file successfuly else return false. */ boolean tryDelete(final String fileName) { LOG.debug("try deleting file [{}]", fileName); File f = getFile(fileName); if (f.exists() && f.delete()) { LOG.info("File [{}] deleted successfully", f.getAbsolutePath()); toBeDeleted.remove(fileName); while (true) { f = f.getParentFile(); if (f.equals(directory) || f.list().length > 0) { break; } // delete empty parent folders (except the main directory) f.delete(); } return true; } else if (f.exists()) { LOG.info("not able to delete file [{}]", f.getAbsolutePath()); toBeDeleted.add(fileName); return false; } return true; }
/** * This method tries to delete a file. If it is not able to delete file due * to any reason, it add it toBeDeleted list. * * @param fileName name of the file which will be deleted. * @return true if this method deletes file successfuly else return false. */ boolean tryDelete(final String fileName) { LOG.debug("try deleting file [{}]", fileName); File f = getFile(fileName); if (f.exists() && f.delete()) { LOG.info("File [{}] deleted successfully", f.getAbsolutePath()); toBeDeleted.remove(fileName); while (true) { f = f.getParentFile(); if (f.equals(directory) || f.list().length > 0) { break; } // delete empty parent folders (except the main directory) f.delete(); } return true; } else if (f.exists()) { LOG.info("not able to delete file [{}]", f.getAbsolutePath()); toBeDeleted.add(fileName); return false; } return true; }
/** * This method tries to delete a file. If it is not able to delete file due * to any reason, it add it toBeDeleted list. * * @param fileName name of the file which will be deleted. * @return true if this method deletes file successfuly else return false. */ boolean tryDelete(final String fileName) { LOG.debug("try deleting file [{}]", fileName); File f = getFile(fileName); if (f.exists() && f.delete()) { LOG.info("File [{}] deleted successfully", f.getAbsolutePath()); toBeDeleted.remove(fileName); while (true) { f = f.getParentFile(); if (f.equals(directory) || f.list().length > 0) { break; } // delete empty parent folders (except the main directory) f.delete(); } return true; } else if (f.exists()) { LOG.info("not able to delete file [{}]", f.getAbsolutePath()); toBeDeleted.add(fileName); return false; } return true; }
public File getFileIfStored(String fileName) throws IOException { fileName = fileName.replace("\\", "/"); File f = getFile(fileName); long diff = (System.currentTimeMillis() - cacheMissDuration.get()) / 1000; // logged at 5 minute interval minimum if (diff > 5 * 60) { LOG.info("local cache misses [{}] in [{}] sec", new Object[] { cacheMissCounter.getAndSet(0), diff }); cacheMissDuration.set(System.currentTimeMillis()); } // return file in purge mode = true and file present in asyncUploadCache // as asyncUploadCache's files will be not be deleted in cache purge. if (!f.exists() || (isInPurgeMode() && !asyncUploadCache.hasEntry(fileName, false))) { LOG.debug( "getFileIfStored returned: purgeMode=[{}], file=[{}] exists=[{}]", new Object[] { isInPurgeMode(), f.getAbsolutePath(), f.exists() }); cacheMissCounter.incrementAndGet(); return null; } else { // touch entry in LRU caches f.setLastModified(System.currentTimeMillis()); cache.get(fileName); return f; } }
currentSizeInBytes -= flength.longValue(); } else if (!getFile(fileName).exists()) {
public File getFileIfStored(String fileName) throws IOException { fileName = fileName.replace("\\", "/"); File f = getFile(fileName); long diff = (System.currentTimeMillis() - cacheMissDuration.get()) / 1000; // logged at 5 minute interval minimum if (diff > 5 * 60) { LOG.info("local cache misses [{}] in [{}] sec", new Object[] { cacheMissCounter.getAndSet(0), diff }); cacheMissDuration.set(System.currentTimeMillis()); } // return file in purge mode = true and file present in asyncUploadCache // as asyncUploadCache's files will be not be deleted in cache purge. if (!f.exists() || (isInPurgeMode() && !asyncUploadCache.hasEntry(fileName, false))) { LOG.debug( "getFileIfStored returned: purgeMode=[{}], file=[{}] exists=[{}]", new Object[] { isInPurgeMode(), f.getAbsolutePath(), f.exists() }); cacheMissCounter.incrementAndGet(); return null; } else { // touch entry in LRU caches f.setLastModified(System.currentTimeMillis()); cache.get(fileName); return f; } }
public File getFileIfStored(String fileName) throws IOException { fileName = fileName.replace("\\", "/"); File f = getFile(fileName); long diff = (System.currentTimeMillis() - cacheMissDuration.get()) / 1000; // logged at 5 minute interval minimum if (diff > 5 * 60) { LOG.info("local cache misses [{}] in [{}] sec", new Object[] { cacheMissCounter.getAndSet(0), diff }); cacheMissDuration.set(System.currentTimeMillis()); } // return file in purge mode = true and file present in asyncUploadCache // as asyncUploadCache's files will be not be deleted in cache purge. if (!f.exists() || (isInPurgeMode() && !asyncUploadCache.hasEntry(fileName, false))) { LOG.debug( "getFileIfStored returned: purgeMode=[{}], file=[{}] exists=[{}]", new Object[] { isInPurgeMode(), f.getAbsolutePath(), f.exists() }); cacheMissCounter.incrementAndGet(); return null; } else { // touch entry in LRU caches f.setLastModified(System.currentTimeMillis()); cache.get(fileName); return f; } }
currentSizeInBytes -= flength.longValue(); } else if (!getFile(fileName).exists()) {
currentSizeInBytes -= flength.longValue(); } else if (!getFile(fileName).exists()) {
throws IOException { fileName = fileName.replace("\\", "/"); File f = getFile(fileName); long length = 0; if (!f.exists() || isInPurgeMode()) {
boolean tryForAsyncUpload) throws IOException { fileName = fileName.replace("\\", "/"); File dest = getFile(fileName); File parent = dest.getParentFile(); AsyncUploadCacheResult result = new AsyncUploadCacheResult();
throws IOException { fileName = fileName.replace("\\", "/"); File f = getFile(fileName); long length = 0; if (!f.exists() || isInPurgeMode()) {
throws IOException { fileName = fileName.replace("\\", "/"); File f = getFile(fileName); long length = 0; if (!f.exists() || isInPurgeMode()) {
boolean tryForAsyncUpload) throws IOException { fileName = fileName.replace("\\", "/"); File dest = getFile(fileName); File parent = dest.getParentFile(); AsyncUploadCacheResult result = new AsyncUploadCacheResult();
boolean tryForAsyncUpload) throws IOException { fileName = fileName.replace("\\", "/"); File dest = getFile(fileName); File parent = dest.getParentFile(); AsyncUploadCacheResult result = new AsyncUploadCacheResult();