예제 #1
0
 /** This method is used to retrieve metaInfo during sending. */
 public static synchronized MetaInfo retrieveMetaInfo(
     String fileId,
     int blockSize,
     int thresholdSize,
     String transId,
     String originalEventId,
     int totalBlocks,
     int lastBlockSize)
     throws FileAccessException, ApplicationException {
   if (fileId == null) throw new ApplicationException("FileId cannot null!");
   if (transId == null) throw new ApplicationException("Transaction Id cannot null!");
   if (originalEventId == null) throw new ApplicationException("Original event Id cannot null!");
   if (allMetaInfo.containsKey(fileId)) {
     MetaInfo meta = (MetaInfo) allMetaInfo.get(fileId);
     meta.checkMetaInfo(
         fileId, blockSize, thresholdSize, transId, originalEventId, totalBlocks, lastBlockSize);
     return meta;
   } else {
     MetaInfo meta =
         new MetaInfo(
             fileId,
             blockSize,
             thresholdSize,
             transId,
             originalEventId,
             totalBlocks,
             lastBlockSize);
     allMetaInfo.put(fileId, meta);
     return meta;
   }
 }
예제 #2
0
 /** This method is used to retrieve metaInfo when receiving file. */
 public static synchronized MetaInfo retrieveMetaInfo(String fileId, int totalBlocks)
     throws FileAccessException, ApplicationException {
   if (fileId == null) throw new ApplicationException("FileId cannot null!");
   if (allMetaInfo.containsKey(fileId)) {
     MetaInfo meta = (MetaInfo) allMetaInfo.get(fileId);
     meta.checkMetaInfo(fileId);
     if (meta.getTotalBlocks() < totalBlocks) meta.setTotalBlocks(totalBlocks);
     return meta;
   } else {
     MetaInfo meta = new MetaInfo(fileId, totalBlocks);
     allMetaInfo.put(fileId, meta);
     return meta;
   }
 }
예제 #3
0
 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);
   }
 }