/** * This methos checks if asynchronous upload is in progress for @param * fileName. If @param touch is true, the lastModified is updated to current * time. */ public synchronized boolean hasEntry(String fileName, boolean touch) throws IOException { boolean contains = asyncUploadMap.containsKey(fileName) && !toBeDeleted.contains(fileName); if (touch && contains) { long timeStamp = System.currentTimeMillis(); asyncUploadMap.put(fileName, timeStamp); serializeAsyncUploadMap(); } return contains; }
/** * This methos checks if asynchronous upload is in progress for @param * fileName. If @param touch is true, the lastModified is updated to current * time. */ public synchronized boolean hasEntry(String fileName, boolean touch) throws IOException { boolean contains = asyncUploadMap.containsKey(fileName) && !toBeDeleted.contains(fileName); if (touch && contains) { long timeStamp = System.currentTimeMillis(); asyncUploadMap.put(fileName, timeStamp); serializeAsyncUploadMap(); } return contains; }
/** * This methos checks if asynchronous upload is in progress for @param * fileName. If @param touch is true, the lastModified is updated to current * time. */ public synchronized boolean hasEntry(String fileName, boolean touch) throws IOException { boolean contains = asyncUploadMap.containsKey(fileName) && !toBeDeleted.contains(fileName); if (touch && contains) { long timeStamp = System.currentTimeMillis(); asyncUploadMap.put(fileName, timeStamp); serializeAsyncUploadMap(); } return contains; }
/** * Reset the {@link AsyncUploadCache} to empty {@link #asyncUploadMap} and * {@link #toBeDeleted} */ public synchronized void reset() throws IOException { if (!pendingUploads.exists()) { pendingUploads.createNewFile(); } pendingUploads.createNewFile(); asyncUploadMap = new HashMap<String, Long>(); serializeAsyncUploadMap(); if (!toBeDeletedUploads.exists()) { toBeDeletedUploads.createNewFile(); } toBeDeletedUploads.createNewFile(); toBeDeleted = new HashSet<String>(); serializeToBeDeleted(); }
/** * Reset the {@link AsyncUploadCache} to empty {@link #asyncUploadMap} and * {@link #toBeDeleted} */ public synchronized void reset() throws IOException { if (!pendingUploads.exists()) { pendingUploads.createNewFile(); } pendingUploads.createNewFile(); asyncUploadMap = new HashMap<String, Long>(); serializeAsyncUploadMap(); if (!toBeDeletedUploads.exists()) { toBeDeletedUploads.createNewFile(); } toBeDeletedUploads.createNewFile(); toBeDeleted = new HashSet<String>(); serializeToBeDeleted(); }
/** * Reset the {@link AsyncUploadCache} to empty {@link #asyncUploadMap} and * {@link #toBeDeleted} */ public synchronized void reset() throws IOException { if (!pendingUploads.exists()) { pendingUploads.createNewFile(); } pendingUploads.createNewFile(); asyncUploadMap = new HashMap<String, Long>(); serializeAsyncUploadMap(); if (!toBeDeletedUploads.exists()) { toBeDeletedUploads.createNewFile(); } toBeDeletedUploads.createNewFile(); toBeDeleted = new HashSet<String>(); serializeToBeDeleted(); }
/** * This methods removes file (if found) from {@link #asyncUploadMap}. If * file is found, it immediately serializes the {@link #asyncUploadMap} to * disk. This method sets * {@link AsyncUploadCacheResult#setRequiresDelete(boolean)} to true, if * asynchronous upload found to be in {@link #toBeDeleted} set i.e. marked * for delete. */ public synchronized AsyncUploadCacheResult remove(String fileName) throws IOException { long startTime = System.currentTimeMillis(); Long retVal = asyncUploadMap.remove(fileName); if (retVal != null) { serializeAsyncUploadMap(); LOG.debug("removed file [{}] from asyncUploadMap took [{}] sec", fileName, ((System.currentTimeMillis() - startTime) / 1000)); LOG.debug("AsyncUploadCache size=[{}] and entries =[{}]", asyncUploadMap.size(), asyncUploadMap.keySet()); } else { LOG.debug("cannot removed file [{}] from asyncUploadMap took [{}] sec. File not found.", fileName, ((System.currentTimeMillis() - startTime) / 1000)); LOG.debug("AsyncUploadCache size=[{}] and entries =[{}]", asyncUploadMap.size(), asyncUploadMap.keySet()); } AsyncUploadCacheResult result = new AsyncUploadCacheResult(); result.setRequiresDelete(toBeDeleted.contains(fileName)); return result; }
/** * This methods removes file (if found) from {@link #asyncUploadMap}. If * file is found, it immediately serializes the {@link #asyncUploadMap} to * disk. This method sets * {@link AsyncUploadCacheResult#setRequiresDelete(boolean)} to true, if * asynchronous upload found to be in {@link #toBeDeleted} set i.e. marked * for delete. */ public synchronized AsyncUploadCacheResult remove(String fileName) throws IOException { long startTime = System.currentTimeMillis(); Long retVal = asyncUploadMap.remove(fileName); if (retVal != null) { serializeAsyncUploadMap(); LOG.debug("removed file [{}] from asyncUploadMap took [{}] sec", fileName, ((System.currentTimeMillis() - startTime) / 1000)); LOG.debug("AsyncUploadCache size=[{}] and entries =[{}]", asyncUploadMap.size(), asyncUploadMap.keySet()); } else { LOG.debug("cannot removed file [{}] from asyncUploadMap took [{}] sec. File not found.", fileName, ((System.currentTimeMillis() - startTime) / 1000)); LOG.debug("AsyncUploadCache size=[{}] and entries =[{}]", asyncUploadMap.size(), asyncUploadMap.keySet()); } AsyncUploadCacheResult result = new AsyncUploadCacheResult(); result.setRequiresDelete(toBeDeleted.contains(fileName)); return result; }
/** * This methods removes file (if found) from {@link #asyncUploadMap}. If * file is found, it immediately serializes the {@link #asyncUploadMap} to * disk. This method sets * {@link AsyncUploadCacheResult#setRequiresDelete(boolean)} to true, if * asynchronous upload found to be in {@link #toBeDeleted} set i.e. marked * for delete. */ public synchronized AsyncUploadCacheResult remove(String fileName) throws IOException { long startTime = System.currentTimeMillis(); Long retVal = asyncUploadMap.remove(fileName); if (retVal != null) { serializeAsyncUploadMap(); LOG.debug("removed file [{}] from asyncUploadMap took [{}] sec", fileName, ((System.currentTimeMillis() - startTime) / 1000)); LOG.debug("AsyncUploadCache size=[{}] and entries =[{}]", asyncUploadMap.size(), asyncUploadMap.keySet()); } else { LOG.debug("cannot removed file [{}] from asyncUploadMap took [{}] sec. File not found.", fileName, ((System.currentTimeMillis() - startTime) / 1000)); LOG.debug("AsyncUploadCache size=[{}] and entries =[{}]", asyncUploadMap.size(), asyncUploadMap.keySet()); } AsyncUploadCacheResult result = new AsyncUploadCacheResult(); result.setRequiresDelete(toBeDeleted.contains(fileName)); return result; }
pendingUploads.createNewFile(); asyncUploadMap = new HashMap<String, Long>(); serializeAsyncUploadMap();
pendingUploads.createNewFile(); asyncUploadMap = new HashMap<String, Long>(); serializeAsyncUploadMap();
serializeAsyncUploadMap(); LOG.debug("added file [{}] to asyncUploadMap upoad took [{}] sec", fileName, ((System.currentTimeMillis() - startTime) / 1000));
pendingUploads.createNewFile(); asyncUploadMap = new HashMap<String, Long>(); serializeAsyncUploadMap();
serializeAsyncUploadMap(); LOG.debug("added file [{}] to asyncUploadMap upoad took [{}] sec", fileName, ((System.currentTimeMillis() - startTime) / 1000));
serializeAsyncUploadMap(); LOG.debug("added file [{}] to asyncUploadMap upoad took [{}] sec", fileName, ((System.currentTimeMillis() - startTime) / 1000));