Ejemplo n.º 1
0
 /**
  * Attempts to promote a block in Alluxio space. If the block is not present, this method will
  * return without an error. If the block is present in multiple workers, only one worker will
  * receive the promotion request.
  *
  * @param blockId the id of the block to promote
  * @throws IOException if the block does not exist
  */
 public void promote(long blockId) throws IOException {
   BlockInfo info;
   try (CloseableResource<BlockMasterClient> blockMasterClientResource =
       mContext.acquireMasterClientResource()) {
     info = blockMasterClientResource.get().getBlockInfo(blockId);
   } catch (AlluxioException e) {
     throw new IOException(e);
   }
   if (info.getLocations().isEmpty()) {
     // Nothing to promote
     return;
   }
   // Get the first worker address for now, as this will likely be the location being read from
   // TODO(calvin): Get this location via a policy (possibly location is a parameter to promote)
   WorkerNetAddress workerAddr = info.getLocations().get(0).getWorkerAddress();
   BlockWorkerClient blockWorkerClient = mContext.acquireWorkerClient(workerAddr.getHost());
   try {
     blockWorkerClient.promoteBlock(blockId);
   } catch (AlluxioException e) {
     throw new IOException(e);
   } finally {
     mContext.releaseWorkerClient(blockWorkerClient);
   }
 }