code: private void removeBlockInternal(long sessionId, long blockId, BlockStoreLocation location)
        throws InvalidWorkerStateException, BlockDoesNotExistException, IOException {
      long lockId = mLockManager.lockBlock(sessionId, blockId, BlockLockType.WRITE);
      try {
        String filePath;
        BlockMeta blockMeta;
        try (LockResource r = new LockResource(mMetadataReadLock)) {
          if (mMetaManager.hasTempBlockMeta(blockId)) {
            throw new InvalidWorkerStateException(ExceptionMessage.REMOVE_UNCOMMITTED_BLOCK, blockId);
          }
          blockMeta = mMetaManager.getBlockMeta(blockId);
          filePath = blockMeta.getPath();
        }
  
        if (!blockMeta.getBlockLocation().belongsTo(location)) {
          throw new BlockDoesNotExistException(ExceptionMessage.BLOCK_NOT_FOUND_AT_LOCATION, blockId,
              location);
        }
        // Heavy IO is guarded by block lock but not metadata lock. This may throw IOException.
        Files.delete(Paths.get(filePath));
  
        try (LockResource r = new LockResource(mMetadataWriteLock)) {
          mMetaManager.removeBlockMeta(blockMeta);
        } catch (BlockDoesNotExistException e) {
          throw Throwables.propagate(e); // we shall never reach here
        }
      } finally {
        mLockManager.unlockBlock(lockId);
      }
    }
docs: Removes a block.
  
  @param sessionId session id
  @param blockId block id
  @param location the source location of the block
  @throws InvalidWorkerStateException if the block to remove is a temp block
  @throws BlockDoesNotExistException if this block can not be found