hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/BlockManagerImpl.java
private AllocatedBlock newBlock(
      ContainerInfo containerInfo, HddsProtos.LifeCycleState state)
      throws IOException {

    // TODO : Replace this with Block ID.
    String blockKey = UUID.randomUUID().toString();
    boolean createContainer = (state == HddsProtos.LifeCycleState.ALLOCATED);

    AllocatedBlock.Builder abb =
        new AllocatedBlock.Builder()
            .setKey(blockKey)
            // TODO : Use containerinfo instead of pipeline.
            .setPipeline(containerInfo.getPipeline())
            .setShouldCreateContainer(createContainer);
    LOG.trace("New block allocated : {} Container ID: {}", blockKey,
        containerInfo.toString());

    if (containerInfo.getPipeline().getMachines().size() == 0) {
      LOG.error("Pipeline Machine count is zero.");
      return null;
    }

    // Persist this block info to the blockStore DB, so getBlock(key) can
    // find which container the block lives.
    // TODO : Remove this DB in future
    // and make this a KSM operation. Category: SCALABILITY.
    if (containerInfo.getPipeline().getMachines().size() > 0) {
      blockStore.put(
          DFSUtil.string2Bytes(blockKey),
          DFSUtil.string2Bytes(containerInfo.getPipeline().getContainerName()));
    }
    return abb.build();
  }
/**
   * newBlock - returns a new block assigned to a container.
   *
   * @param containerInfo - Container Info.
   * @param state - Current state of the container.
   * @return AllocatedBlock
   */
returns a new block assigned to a container.
@param containerInfo - Container Info.
@param state - Current state of the container.
returns a new block assigned to a container . @param containerInfo - Container Info . @param state - Current state of the container .
private AllocatedBlock newBlock(
      ContainerInfo containerInfo, HddsProtos.LifeCycleState state)
      throws IOException {
    String blockKey = UUID.randomUUID().toString();
    boolean createContainer = (state == HddsProtos.LifeCycleState.ALLOCATED);
    AllocatedBlock.Builder abb =
        new AllocatedBlock.Builder()
            .setKey(blockKey)
            .setPipeline(containerInfo.getPipeline())
            .setShouldCreateContainer(createContainer);
    LOG.trace("New block allocated : {} Container ID: {}", blockKey,
        containerInfo.toString());
    if (containerInfo.getPipeline().getMachines().size() == 0) {
      LOG.error("Pipeline Machine count is zero.");
      return null;
    }
    if (containerInfo.getPipeline().getMachines().size() > 0) {
      blockStore.put(
          DFSUtil.string2Bytes(blockKey),
          DFSUtil.string2Bytes(containerInfo.getPipeline().getContainerName()));
    }
    return abb.build();
  }
private AllocatedBlock newBlock ( ContainerInfo containerInfo , HddsProtos . LifeCycleState state ) throws IOException { String blockKey = UUID . randomUUID ( ) . toString ( ) ; boolean createContainer = ( state == HddsProtos . LifeCycleState . ALLOCATED ) ; AllocatedBlock . Builder abb = new AllocatedBlock . Builder ( ) . setKey ( blockKey ) . setPipeline ( containerInfo . getPipeline ( ) ) . setShouldCreateContainer ( createContainer ) ; LOG . trace ( "New block allocated : {} Container ID: {}" , blockKey , containerInfo . toString ( ) ) ; if ( containerInfo . getPipeline ( ) . getMachines ( ) . size ( ) == 0 ) { LOG . error ( "Pipeline Machine count is zero." ) ; return null ; } if ( containerInfo . getPipeline ( ) . getMachines ( ) . size ( ) > 0 ) { blockStore . put ( DFSUtil . string2Bytes ( blockKey ) , DFSUtil . string2Bytes ( containerInfo . getPipeline ( ) . getContainerName ( ) ) ) ; } return abb . build ( ) ; }
newBlock - returns a new block assigned to a container.
newBlock - returns a new block assigned to a container .
// TODO : Replace this with Block ID. // TODO : Use containerinfo instead of pipeline. // Persist this block info to the blockStore DB, so getBlock(key) can // find which container the block lives. // TODO : Remove this DB in future // and make this a KSM operation. Category: SCALABILITY.