code: private TempBlockMeta createBlockMetaInternal(long sessionId, long blockId,
        BlockStoreLocation location, long initialBlockSize, boolean newBlock)
            throws BlockAlreadyExistsException {
      // NOTE: a temp block is supposed to be visible for its own writer, unnecessary to acquire
      // block lock here since no sharing
      try (LockResource r = new LockResource(mMetadataWriteLock)) {
        if (newBlock) {
          checkTempBlockIdAvailable(blockId);
        }
        StorageDirView dirView =
            mAllocator.allocateBlockWithView(sessionId, initialBlockSize, location, getUpdatedView());
        if (dirView == null) {
          // Allocator fails to find a proper place for this new block.
          return null;
        }
        // TODO(carson): Add tempBlock to corresponding storageDir and remove the use of
        // StorageDirView.createTempBlockMeta.
        TempBlockMeta tempBlock = dirView.createTempBlockMeta(sessionId, blockId, initialBlockSize);
        try {
          // Add allocated temp block to metadata manager. This should never fail if allocator
          // correctly assigns a StorageDir.
          mMetaManager.addTempBlockMeta(tempBlock);
        } catch (WorkerOutOfSpaceException | BlockAlreadyExistsException e) {
          // If we reach here, allocator is not working properly
          LOG.error("Unexpected failure: {} bytes allocated at {} by allocator, "
              + "but addTempBlockMeta failed", initialBlockSize, location);
          throw Throwables.propagate(e);
        }
        return tempBlock;
      }
    }
docs: Creates a temp block meta only if allocator finds available space. This method will not trigger
  any eviction.
  
  @param sessionId session id
  @param blockId block id
  @param location location to create the block
  @param initialBlockSize initial block size in bytes
  @param newBlock true if this temp block is created for a new block
  @return a temp block created if successful, or null if allocation failed (instead of throwing
  {@link WorkerOutOfSpaceException} because allocation failure could be an expected case)
  @throws BlockAlreadyExistsException if there is already a block with the same block id