@@ -40,6 +40,7 @@ const TIMED_OPS = Object.freeze({
4040    RUN_LIFECYLE : 'run_lifecycle' , 
4141    LIST_BUCKETS : 'list_buckets' , 
4242    CREATE_GPFS_CANDIDATES_FILES : 'create_gpfs_candidates_files' , 
43+     CREATE_GPFS_CANDIDATE_FILE_BY_ILM_POLICY : 'create_candidates_file_by_gpfs_ilm_policy' , 
4344    PROCESS_BUCKETS : 'process_buckets' , 
4445    PROCESS_BUCKET : 'process_bucket' , 
4546    PROCESS_RULE : 'process_rule' , 
@@ -82,7 +83,8 @@ class NCLifecycle {
8283            lifecycle_run_times : { } , 
8384            total_stats : this . _get_default_stats ( ) , 
8485            state : {  is_finished : false  } , 
85-             buckets_statuses : { } 
86+             buckets_statuses : { } , 
87+             mount_points_statuses : { } 
8688        } ; 
8789        this . return_short_status  =  options . short_status  ||  false ; 
8890        this . disable_service_validation  =  options . disable_service_validation  ||  false ; 
@@ -764,14 +766,15 @@ class NCLifecycle {
764766     * @param  {{ 
765767    *      op_name: string; 
766768    *      op_func: () => Promise<T>; 
769+     *      mount_point?: string, 
767770    *      bucket_name?: string, 
768771    *      rule_id?: string 
769772    * }} params 
770773    * @returns  {Promise<T> } 
771774    */ 
772-     async  _call_op_and_update_status ( {  bucket_name =  undefined ,  rule_id =  undefined ,  op_name,  op_func } )  { 
775+     async  _call_op_and_update_status ( {  mount_point  =   undefined ,   bucket_name =  undefined ,  rule_id =  undefined ,  op_name,  op_func } )  { 
773776        const  start_time  =  Date . now ( ) ; 
774-         const  update_options  =  {  op_name,  bucket_name,  rule_id } ; 
777+         const  update_options  =  {  mount_point ,   op_name,  bucket_name,  rule_id } ; 
775778        let  end_time ; 
776779        let  took_ms ; 
777780        let  error ; 
@@ -792,13 +795,15 @@ class NCLifecycle {
792795    } 
793796
794797    /** 
795-      * update_status updates rule/bucket/global based on the given parameters 
798+      * update_status updates rule/bucket/mount_point/ global based on the given parameters 
796799     * 1. initalize statuses/times/stats per level 
797800     * 2. update times 
798801     * 3. update errors 
799802     * 4. update stats if the op is at rule level 
803+      * Note - on mount_point we won't update stats/state 
800804     * @param  {{ 
801805     * op_name: string, 
806+      * mount_point?: string,  
802807     * bucket_name?: string, 
803808     * rule_id?: string, 
804809     * op_times: { start_time?: number, end_time?: number, took_ms?: number }, 
@@ -807,21 +812,23 @@ class NCLifecycle {
807812     * } params 
808813     * @returns  {Void } 
809814    */ 
810-     update_status ( {  bucket_name,  rule_id,  op_name,  op_times,  reply =  [ ] ,  error =  undefined  } )  { 
815+     update_status ( {  mount_point ,   bucket_name,  rule_id,  op_name,  op_times,  reply =  [ ] ,  error =  undefined  } )  { 
811816        if  ( op_times . start_time )  { 
812817            if  ( op_name  ===  TIMED_OPS . PROCESS_RULE )  { 
813818                this . init_rule_status ( bucket_name ,  rule_id ) ; 
814819            }  else  if  ( op_name  ===  TIMED_OPS . PROCESS_BUCKET )  { 
815820                this . init_bucket_status ( bucket_name ) ; 
821+             }  else  if  ( op_name  ===  TIMED_OPS . CREATE_GPFS_CANDIDATE_FILE_BY_ILM_POLICY )  { 
822+                 this . init_mount_status ( mount_point ) ; 
816823            } 
817824        } 
818825        if  ( op_times . end_time )  { 
819826            if  ( op_name  ===  TIMED_OPS . PROCESS_RULE )  { 
820827                this . update_rule_status_is_finished ( bucket_name ,  rule_id ) ; 
821828            } 
822829        } 
823-         this . _update_times_on_status ( {  op_name,  op_times,  bucket_name,  rule_id } ) ; 
824-         this . _update_error_on_status ( {  error,  bucket_name,  rule_id } ) ; 
830+         this . _update_times_on_status ( {  op_name,  op_times,  mount_point ,   bucket_name,  rule_id } ) ; 
831+         this . _update_error_on_status ( {  error,  mount_point ,   bucket_name,  rule_id } ) ; 
825832        if  ( bucket_name  &&  rule_id )  { 
826833            this . update_stats_on_status ( {  bucket_name,  rule_id,  op_name,  op_times,  reply } ) ; 
827834        } 
@@ -895,16 +902,18 @@ class NCLifecycle {
895902    /** 
896903     * _update_times_on_status updates start/end & took times in lifecycle status 
897904     * @param  {{op_name: String, op_times: {start_time?: number, end_time?: number, took_ms?: number }, 
898-      * bucket_name?: String, rule_id?: String }} params 
905+      * mount_point ?: String,  bucket_name?: String, rule_id?: String 
899906     * @returns  
900907     */ 
901-     _update_times_on_status ( {  op_name,  op_times,  bucket_name =  undefined ,  rule_id =  undefined  } )  { 
908+     _update_times_on_status ( {  op_name,  op_times,  mount_point  =   undefined ,   bucket_name =  undefined ,  rule_id =  undefined  } )  { 
902909        for  ( const  [ key ,  value ]  of  Object . entries ( op_times ) )  { 
903910            const  status_key  =  op_name  +  '_'  +  key ; 
904911            if  ( bucket_name  &&  rule_id )  { 
905912                this . lifecycle_run_status . buckets_statuses [ bucket_name ] . rules_statuses [ rule_id ] . rule_process_times [ status_key ]  =  value ; 
906913            }  else  if  ( bucket_name )  { 
907914                this . lifecycle_run_status . buckets_statuses [ bucket_name ] . bucket_process_times [ status_key ]  =  value ; 
915+             }  else  if  ( mount_point )  { 
916+                 this . lifecycle_run_status . mount_points_statuses [ mount_point ] . mount_point_process_times [ status_key ]  =  value ; 
908917            }  else  { 
909918                this . lifecycle_run_status . lifecycle_run_times [ status_key ]  =  value ; 
910919            } 
@@ -913,15 +922,17 @@ class NCLifecycle {
913922
914923    /** 
915924     * _update_error_on_status updates an error occured in lifecycle status 
916-      * @param  {{error: Error, bucket_name?: string, rule_id?: string} } params 
925+      * @param  {{error: Error, mount_point?: string,  bucket_name?: string, rule_id?: string} } params 
917926     * @returns  
918927     */ 
919-     _update_error_on_status ( {  error,  bucket_name =  undefined ,  rule_id =  undefined  } )  { 
928+     _update_error_on_status ( {  error,  mount_point  =   undefined ,   bucket_name =  undefined ,  rule_id =  undefined  } )  { 
920929        if  ( ! error )  return ; 
921930        if  ( bucket_name  &&  rule_id )  { 
922931            ( this . lifecycle_run_status . buckets_statuses [ bucket_name ] . rules_statuses [ rule_id ] . errors  ??=  [ ] ) . push ( error . message ) ; 
923932        }  else  if  ( bucket_name )  { 
924933            ( this . lifecycle_run_status . buckets_statuses [ bucket_name ] . errors  ??=  [ ] ) . push ( error . message ) ; 
934+         }  else  if  ( mount_point )  { 
935+             ( this . lifecycle_run_status . mount_points_statuses [ mount_point ] . errors  ??=  [ ] ) . push ( error . message ) ; 
925936        }  else  { 
926937            ( this . lifecycle_run_status . errors  ??=  [ ] ) . push ( error . message ) ; 
927938        } 
@@ -962,6 +973,18 @@ class NCLifecycle {
962973        return  this . lifecycle_run_status . buckets_statuses [ bucket_name ] ; 
963974    } 
964975
976+     /** 
977+      * init the mount_point status object statuses if they don't exist 
978+      * @param  {string } mount_point 
979+      * @returns  {Object } created or existing mount_point status 
980+      */ 
981+     init_mount_status ( mount_point )  { 
982+         this . lifecycle_run_status . mount_points_statuses [ mount_point ]  ??=  { } ; 
983+         this . lifecycle_run_status . mount_points_statuses [ mount_point ] . mount_point_process_times  ??=  { } ; 
984+         return  this . lifecycle_run_status . mount_points_statuses [ mount_point ] ; 
985+     } 
986+ 
987+ 
965988    /** 
966989     * init the rule status object statuses if they don't exist 
967990     * @param  {string } bucket_name 
@@ -1190,11 +1213,22 @@ class NCLifecycle {
11901213
11911214        await  native_fs_utils . _create_path ( ILM_POLICIES_TMP_DIR ,  this . non_gpfs_fs_context ,  config . BASE_MODE_CONFIG_DIR ) ; 
11921215        await  native_fs_utils . _create_path ( ILM_CANDIDATES_TMP_DIR ,  this . non_gpfs_fs_context ,  config . BASE_MODE_CONFIG_DIR ) ; 
1193-         for  ( const  [ mount_point ,  policy ]  of  Object . entries ( mount_point_to_policy_map ) )  { 
1194-             if  ( policy  ===  '' )  continue ; 
1195-             const  ilm_policy_path  =  await  this . write_tmp_ilm_policy ( mount_point ,  policy ) ; 
1196-             await  this . create_candidates_file_by_gpfs_ilm_policy ( mount_point ,  ilm_policy_path ) ; 
1197-         } 
1216+         await  P . map_with_concurrency ( config . NC_LIFECYCLE_GPFS_MMAPPLY_ILM_POLICY_CONCURRENCY , 
1217+             Object . entries ( mount_point_to_policy_map ) ,  async  ( [ mount_point ,  policy ] )  =>  { 
1218+             try  { 
1219+                 if  ( policy  ===  '' )  return ; 
1220+                 await  this . _call_op_and_update_status ( { 
1221+                     mount_point, 
1222+                     op_name : TIMED_OPS . CREATE_GPFS_CANDIDATE_FILE_BY_ILM_POLICY , 
1223+                     op_func : async  ( )  =>  { 
1224+                         const  ilm_policy_path  =  await  this . write_tmp_ilm_policy ( mount_point ,  policy ) ; 
1225+                         await  this . create_candidates_file_by_gpfs_ilm_policy ( mount_point ,  ilm_policy_path ) ; 
1226+                     } 
1227+                 } ) ; 
1228+             }  catch  ( err )  { 
1229+                 dbg . error ( 'create_candidates_file_by_gpfs_ilm_policy failed with error' ,  err ,  err . code ,  err . message ) ; 
1230+             } 
1231+         } ) ; 
11981232    } 
11991233
12001234    /** 
0 commit comments