hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodePoolManager.java
private void init() throws SCMException {
    try {
      nodePoolStore.iterate(null, (key, value) -> {
        try {
          DatanodeDetails nodeId = DatanodeDetails.getFromProtoBuf(
              HddsProtos.DatanodeDetailsProto.PARSER.parseFrom(key));
          String poolName = DFSUtil.bytes2String(value);

          Set<DatanodeDetails> nodePool = null;
          if (nodePools.containsKey(poolName)) {
            nodePool = nodePools.get(poolName);
          } else {
            nodePool = new HashSet<>();
            nodePools.put(poolName, nodePool);
          }
          nodePool.add(nodeId);
          if (LOG.isDebugEnabled()) {
            LOG.debug("Adding node: {} to node pool: {}",
                nodeId, poolName);
          }
        } catch (IOException e) {
          LOG.warn("Can't add a datanode to node pool, continue next...");
        }
        return true;
      });
    } catch (IOException e) {
      LOG.error("Loading node pool error " + e);
      throw new SCMException("Failed to load node pool",
          FAILED_TO_LOAD_NODEPOOL);
    }
  }
/**
   * Initialize the in-memory store based on persist store from level db.
   * No lock is needed as init() is only invoked by constructor.
   * @throws SCMException
   */
Initialize the in-memory store based on persist store from level db.
No lock is needed as init() is only invoked by constructor.
Initialize the in - memory store based on persist store from level db . No lock is needed as init () is only invoked by constructor .
private void init() throws SCMException {
    try {
      nodePoolStore.iterate(null, (key, value) -> {
        try {
          DatanodeDetails nodeId = DatanodeDetails.getFromProtoBuf(
              HddsProtos.DatanodeDetailsProto.PARSER.parseFrom(key));
          String poolName = DFSUtil.bytes2String(value);
          Set<DatanodeDetails> nodePool = null;
          if (nodePools.containsKey(poolName)) {
            nodePool = nodePools.get(poolName);
          } else {
            nodePool = new HashSet<>();
            nodePools.put(poolName, nodePool);
          }
          nodePool.add(nodeId);
          if (LOG.isDebugEnabled()) {
            LOG.debug("Adding node: {} to node pool: {}",
                nodeId, poolName);
          }
        } catch (IOException e) {
          LOG.warn("Can't add a datanode to node pool, continue next...");
        }
        return true;
      });
    } catch (IOException e) {
      LOG.error("Loading node pool error " + e);
      throw new SCMException("Failed to load node pool",
          FAILED_TO_LOAD_NODEPOOL);
    }
  }
private void init ( ) throws SCMException { try { nodePoolStore . iterate ( null , ( key , value ) -> { try { DatanodeDetails nodeId = DatanodeDetails . getFromProtoBuf ( HddsProtos . DatanodeDetailsProto . PARSER . parseFrom ( key ) ) ; String poolName = DFSUtil . bytes2String ( value ) ; Set < DatanodeDetails > nodePool = null ; if ( nodePools . containsKey ( poolName ) ) { nodePool = nodePools . get ( poolName ) ; } else { nodePool = new HashSet < > ( ) ; nodePools . put ( poolName , nodePool ) ; } nodePool . add ( nodeId ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Adding node: {} to node pool: {}" , nodeId , poolName ) ; } } catch ( IOException e ) { LOG . warn ( "Can't add a datanode to node pool, continue next..." ) ; } return true ; } ) ; } catch ( IOException e ) { LOG . error ( "Loading node pool error " + e ) ; throw new SCMException ( "Failed to load node pool" , FAILED_TO_LOAD_NODEPOOL ) ; } }
Initialize the in-memory store based on persist store from level db.
Initialize the in - memory store based on persist store from level db .