hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/ScmBlockLocationProtocolClientSideTranslatorPB.java
@Override
  public AllocatedBlock allocateBlock(long size,
      HddsProtos.ReplicationType type, HddsProtos.ReplicationFactor factor,
      String owner) throws IOException {
    Preconditions.checkArgument(size > 0, "block size must be greater than 0");

    AllocateScmBlockRequestProto request =
        AllocateScmBlockRequestProto.newBuilder().setSize(size).setType(type)
            .setFactor(factor).setOwner(owner).build();
    final AllocateScmBlockResponseProto response;
    try {
      response = rpcProxy.allocateScmBlock(NULL_RPC_CONTROLLER, request);
    } catch (ServiceException e) {
      throw ProtobufHelper.getRemoteException(e);
    }
    if (response.getErrorCode() !=
        AllocateScmBlockResponseProto.Error.success) {
      throw new IOException(response.hasErrorMessage() ?
          response.getErrorMessage() : "Allocate block failed.");
    }
    AllocatedBlock.Builder builder = new AllocatedBlock.Builder()
        .setKey(response.getKey())
        .setPipeline(Pipeline.getFromProtoBuf(response.getPipeline()))
        .setShouldCreateContainer(response.getCreateContainer());
    return builder.build();
  }
/**
   * Asks SCM where a block should be allocated. SCM responds with the
   * set of datanodes that should be used creating this block.
   * @param size - size of the block.
   * @return allocated block accessing info (key, pipeline).
   * @throws IOException
   */
Asks SCM where a block should be allocated. SCM responds with the
set of datanodes that should be used creating this block.
@param size - size of the block.
@return allocated block accessing info (key, pipeline).
Asks SCM where a block should be allocated . SCM responds with the set of datanodes that should be used creating this block . @param size - size of the block . @return allocated block accessing info ( key pipeline ) .
@Override
  public AllocatedBlock allocateBlock(long size,
      HddsProtos.ReplicationType type, HddsProtos.ReplicationFactor factor,
      String owner) throws IOException {
    Preconditions.checkArgument(size > 0, "block size must be greater than 0");
    AllocateScmBlockRequestProto request =
        AllocateScmBlockRequestProto.newBuilder().setSize(size).setType(type)
            .setFactor(factor).setOwner(owner).build();
    final AllocateScmBlockResponseProto response;
    try {
      response = rpcProxy.allocateScmBlock(NULL_RPC_CONTROLLER, request);
    } catch (ServiceException e) {
      throw ProtobufHelper.getRemoteException(e);
    }
    if (response.getErrorCode() !=
        AllocateScmBlockResponseProto.Error.success) {
      throw new IOException(response.hasErrorMessage() ?
          response.getErrorMessage() : "Allocate block failed.");
    }
    AllocatedBlock.Builder builder = new AllocatedBlock.Builder()
        .setKey(response.getKey())
        .setPipeline(Pipeline.getFromProtoBuf(response.getPipeline()))
        .setShouldCreateContainer(response.getCreateContainer());
    return builder.build();
  }
@ Override public AllocatedBlock allocateBlock ( long size , HddsProtos . ReplicationType type , HddsProtos . ReplicationFactor factor , String owner ) throws IOException { Preconditions . checkArgument ( size > 0 , "block size must be greater than 0" ) ; AllocateScmBlockRequestProto request = AllocateScmBlockRequestProto . newBuilder ( ) . setSize ( size ) . setType ( type ) . setFactor ( factor ) . setOwner ( owner ) . build ( ) ; final AllocateScmBlockResponseProto response ; try { response = rpcProxy . allocateScmBlock ( NULL_RPC_CONTROLLER , request ) ; } catch ( ServiceException e ) { throw ProtobufHelper . getRemoteException ( e ) ; } if ( response . getErrorCode ( ) != AllocateScmBlockResponseProto . Error . success ) { throw new IOException ( response . hasErrorMessage ( ) ? response . getErrorMessage ( ) : "Allocate block failed." ) ; } AllocatedBlock . Builder builder = new AllocatedBlock . Builder ( ) . setKey ( response . getKey ( ) ) . setPipeline ( Pipeline . getFromProtoBuf ( response . getPipeline ( ) ) ) . setShouldCreateContainer ( response . getCreateContainer ( ) ) ; return builder . build ( ) ; }
Asks SCM where a block should be allocated.
Asks SCM where a block should be allocated .