Exemplo n.º 1
0
 /**
  * Creates an id for a file based on the given id of the container.
  *
  * @param containerId the id of the container
  * @return a file id based on the given container id
  */
 public static long createFileId(long containerId) {
   long id = BlockId.createBlockId(containerId, BlockId.getMaxSequenceNumber());
   if (id == INVALID_FILE_ID) {
     // Right now, there's not much we can do if the file id we're returning is -1, since the file
     // id is completely determined by the container id passed in. However, by the current
     // algorithm, -1 will be the last file id generated, so the chances somebody will get to that
     // are slim. For now we just log it.
     LOG.warn("Created file id -1, which is invalid");
   }
   return id;
 }
 /**
  * * Get sorted fileIds of the files cached in the worker.
  *
  * @return a sorted fileId list
  */
 private List<Long> getSortedFileIds() {
   Set<Long> fileIds = new HashSet<Long>();
   BlockStoreMeta storeMeta = mBlockDataManager.getStoreMeta();
   for (List<Long> blockIds : storeMeta.getBlockList().values()) {
     for (long blockId : blockIds) {
       long fileId =
           BlockId.createBlockId(BlockId.getContainerId(blockId), BlockId.getMaxSequenceNumber());
       fileIds.add(fileId);
     }
   }
   List<Long> sortedFileIds = new ArrayList<Long>(fileIds);
   Collections.sort(sortedFileIds);
   return sortedFileIds;
 }