hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/ratis/RatisManagerImpl.java
public PipelineChannel allocatePipelineChannel(ReplicationFactor factor) {
    List<DatanodeDetails> newNodesList = new LinkedList<>();
    List<DatanodeDetails> datanodes = nodeManager.getNodes(NodeState.HEALTHY);
    int count = getReplicationCount(factor);
    //TODO: Add Raft State to the Nodes, so we can query and skip nodes from
    // data from datanode instead of maintaining a set.
    for (DatanodeDetails datanode : datanodes) {
      Preconditions.checkNotNull(datanode);
      if (!ratisMembers.contains(datanode)) {
        newNodesList.add(datanode);
        if (newNodesList.size() == count) {
          // once a datanode has been added to a pipeline, exclude it from
          // further allocations
          ratisMembers.addAll(newNodesList);
          LOG.info("Allocating a new ratis pipelineChannel of size: {}", count);
          // Start all channel names with "Ratis", easy to grep the logs.
          String conduitName = PREFIX +
              UUID.randomUUID().toString().substring(PREFIX.length());
          PipelineChannel pipelineChannel =
              PipelineSelector.newPipelineFromNodes(newNodesList,
              LifeCycleState.OPEN, ReplicationType.RATIS, factor, conduitName);
          Pipeline pipeline =
              new Pipeline("setup", pipelineChannel);
          try (XceiverClientRatis client =
              XceiverClientRatis.newXceiverClientRatis(pipeline, conf)) {
            client.createPipeline(pipeline.getPipelineName(), newNodesList);
          } catch (IOException e) {
            return null;
          }
          return pipelineChannel;
        }
      }
    }
    return null;
  }
/**
   * Allocates a new ratis PipelineChannel from the free nodes.
   *
   * @param factor - One or Three
   * @return PipelineChannel.
   */
Allocates a new ratis PipelineChannel from the free nodes.
@param factor - One or Three
@return PipelineChannel.
Allocates a new ratis PipelineChannel from the free nodes . @param factor - One or Three @return PipelineChannel .
public PipelineChannel allocatePipelineChannel(ReplicationFactor factor) {
    List<DatanodeDetails> newNodesList = new LinkedList<>();
    List<DatanodeDetails> datanodes = nodeManager.getNodes(NodeState.HEALTHY);
    int count = getReplicationCount(factor);
    for (DatanodeDetails datanode : datanodes) {
      Preconditions.checkNotNull(datanode);
      if (!ratisMembers.contains(datanode)) {
        newNodesList.add(datanode);
        if (newNodesList.size() == count) {
          ratisMembers.addAll(newNodesList);
          LOG.info("Allocating a new ratis pipelineChannel of size: {}", count);
          String conduitName = PREFIX +
              UUID.randomUUID().toString().substring(PREFIX.length());
          PipelineChannel pipelineChannel =
              PipelineSelector.newPipelineFromNodes(newNodesList,
              LifeCycleState.OPEN, ReplicationType.RATIS, factor, conduitName);
          Pipeline pipeline =
              new Pipeline("setup", pipelineChannel);
          try (XceiverClientRatis client =
              XceiverClientRatis.newXceiverClientRatis(pipeline, conf)) {
            client.createPipeline(pipeline.getPipelineName(), newNodesList);
          } catch (IOException e) {
            return null;
          }
          return pipelineChannel;
        }
      }
    }
    return null;
  }
public PipelineChannel allocatePipelineChannel ( ReplicationFactor factor ) { List < DatanodeDetails > newNodesList = new LinkedList < > ( ) ; List < DatanodeDetails > datanodes = nodeManager . getNodes ( NodeState . HEALTHY ) ; int count = getReplicationCount ( factor ) ; for ( DatanodeDetails datanode : datanodes ) { Preconditions . checkNotNull ( datanode ) ; if ( ! ratisMembers . contains ( datanode ) ) { newNodesList . add ( datanode ) ; if ( newNodesList . size ( ) == count ) { ratisMembers . addAll ( newNodesList ) ; LOG . info ( "Allocating a new ratis pipelineChannel of size: {}" , count ) ; String conduitName = PREFIX + UUID . randomUUID ( ) . toString ( ) . substring ( PREFIX . length ( ) ) ; PipelineChannel pipelineChannel = PipelineSelector . newPipelineFromNodes ( newNodesList , LifeCycleState . OPEN , ReplicationType . RATIS , factor , conduitName ) ; Pipeline pipeline = new Pipeline ( "setup" , pipelineChannel ) ; try ( XceiverClientRatis client = XceiverClientRatis . newXceiverClientRatis ( pipeline , conf ) ) { client . createPipeline ( pipeline . getPipelineName ( ) , newNodesList ) ; } catch ( IOException e ) { return null ; } return pipelineChannel ; } } } return null ; }
Allocates a new ratis PipelineChannel from the free nodes.
Allocates a new ratis PipelineChannel from the free nodes .
//TODO: Add Raft State to the Nodes, so we can query and skip nodes from // data from datanode instead of maintaining a set. // once a datanode has been added to a pipeline, exclude it from // further allocations // Start all channel names with "Ratis", easy to grep the logs.