@ VisibleForTesting static TieredIdentity create ( AlluxioConfiguration conf ) { TieredIdentity scriptIdentity = fromScript ( conf ) ; List < LocalityTier > tiers = new ArrayList <> ( ) ; List < String > orderedTierNames = conf . getList ( PropertyKey . LOCALITY_ORDER , "," ) ; for ( int i = 0 ; i < orderedTierNames . size ( ) ; i ++ ) { String tierName = orderedTierNames . get ( i ) ; String value = null ; if ( scriptIdentity != null ) { LocalityTier scriptTier = scriptIdentity . getTier ( i ) ; Preconditions . checkState ( scriptTier . getTierName ( ) . equals ( tierName ) ) ; value = scriptTier . getValue ( ) ; } // Explicit configuration overrides script output. if ( conf . isSet ( Template . LOCALITY_TIER . format ( tierName ) ) ) { value = conf . get ( Template . LOCALITY_TIER . format ( tierName ) ) ; } tiers . add ( new LocalityTier ( tierName , value ) ) ; } // If the user doesn't specify the value of the "node" tier, we fill in a sensible default. if ( tiers . size ( ) > 0 && tiers . get ( 0 ) . getTierName ( ) . equals ( Constants . LOCALITY_NODE ) && tiers . get ( 0 ) . getValue ( ) == null ) { String name = NetworkAddressUtils . getLocalNodeName ( conf ) ; tiers . set ( 0 , new LocalityTier ( Constants . LOCALITY_NODE , name ) ) ; } return new TieredIdentity ( tiers ) ; }
Creates a tiered identity based on configuration .