code: private StorageDirView allocateBlock(long sessionId, long blockSize,
        BlockStoreLocation location) {
      Preconditions.checkNotNull(location, "location");
      StorageDirView candidateDirView = null;
  
      if (location.equals(BlockStoreLocation.anyTier())) {
        for (StorageTierView tierView : mManagerView.getTierViews()) {
          candidateDirView = getCandidateDirInTier(tierView, blockSize);
          if (candidateDirView != null) {
            break;
          }
        }
      } else if (location.equals(BlockStoreLocation.anyDirInTier(location.tierAlias()))) {
        StorageTierView tierView = mManagerView.getTierView(location.tierAlias());
        candidateDirView = getCandidateDirInTier(tierView, blockSize);
      } else {
        StorageTierView tierView = mManagerView.getTierView(location.tierAlias());
        StorageDirView dirView = tierView.getDirView(location.dir());
        if (dirView.getAvailableBytes() >= blockSize) {
          candidateDirView = dirView;
        }
      }
  
      return candidateDirView;
    }
docs: Allocates a block from the given block store location. The location can be a specific location,
  or {@link BlockStoreLocation#anyTier()} or {@link BlockStoreLocation#anyDirInTier(String)}.
  
  @param sessionId the id of session to apply for the block allocation
  @param blockSize the size of block in bytes
  @param location the location in block store
  @return a {@link StorageDirView} in which to create the temp block meta if success, null
  otherwise
  @throws IllegalArgumentException if block location is invalid