public synchronized boolean isProcessing() { if (_processing) { if (_processingTime > TimeUtil.localToUtc()) return true; else _processing = false; } return _processing; }
public static synchronized void clearExpiredMetaInfoInMem() { Enumeration fileIdList = allMetaInfo.keys(); Vector expiredFileIdList = new Vector(); MetaInfo metaInfo = null; String fileId = null; while (fileIdList.hasMoreElements()) { fileId = (String) fileIdList.nextElement(); metaInfo = (MetaInfo) allMetaInfo.get(fileId); if ((metaInfo.getTimeLastAction() + 300000) < TimeUtil.localToUtc()) expiredFileIdList.add(fileId); } for (int i = 0; i < expiredFileIdList.size(); i++) { fileId = (String) expiredFileIdList.get(i); removeMetaInfoInMem(fileId); } }
private synchronized void storeMetaInfoIntoFile() throws FileAccessException { _timeLastAction = TimeUtil.localToUtc(); File tmpFile = new File(META_INFO_FILENAME); FileWriter file = null; BufferedWriter bw = null; PrintWriter pw = null; try { file = new FileWriter(tmpFile); bw = new BufferedWriter(file); pw = new PrintWriter(bw); pw.println(_blockSize); pw.println(parseBlockReceivedToString()); pw.println(_totalBlocks); pw.println(_fileId); pw.println(_lastBlock); pw.println(_lastBlockSent); pw.println(_lastBlockSize); pw.println(_subPath); pw.println(_thresholdSize); pw.println(_transId); pw.println(parseBlockFilenameToString()); pw.println(_timeCreated); pw.println(_originalEventId); pw.println(_GNCI); pw.println(_finishedOnce); int originalDataLen = (_originalData == null) ? -1 : _originalData.length; pw.println(originalDataLen); for (int i = 0; i < originalDataLen; i++) { if (_originalData[i] != null) pw.println(_originalData[i]); else pw.println(NULL_DELIMITER); } pw.println(_timeLastAction); close(pw); if (FileHelper.exist(IPackagingConstants.PACKAGING_PATH, _subPath, META_INFO_FILENAME)) FileHelper.replace( IPackagingConstants.PACKAGING_PATH, _subPath, META_INFO_FILENAME, tmpFile); else FileHelper.create( IPackagingConstants.PACKAGING_PATH, _subPath, META_INFO_FILENAME, tmpFile); tmpFile.delete(); } catch (IOException ioe) { throw new FileAccessException("Unable to store meta info to file."); } finally { close(pw); } }
public synchronized void setProcessing(boolean flag) { _processingTime = TimeUtil.localToUtc() + 60000; _processing = true; }