@@ -133,7 +133,9 @@ impl HotTierManager {
133
133
total_space,
134
134
used_space,
135
135
..
136
- } = get_disk_usage ( ) . expect ( "Codepath should only be hit if hottier is enabled" ) ;
136
+ } = self
137
+ . get_disk_usage ( )
138
+ . expect ( "Codepath should only be hit if hottier is enabled" ) ;
137
139
138
140
let ( total_hot_tier_size, total_hot_tier_used_size) =
139
141
self . get_hot_tiers_size ( stream) . await ?;
@@ -642,7 +644,7 @@ impl HotTierManager {
642
644
total_space,
643
645
available_space,
644
646
used_space,
645
- } ) = get_disk_usage ( )
647
+ } ) = self . get_disk_usage ( )
646
648
{
647
649
if available_space < size_to_download {
648
650
return Ok ( false ) ;
@@ -726,6 +728,34 @@ impl HotTierManager {
726
728
}
727
729
Ok ( ( ) )
728
730
}
731
+
732
+ /// Get the disk usage for the hot tier storage path. If we have a three disk paritions
733
+ /// mounted as follows:
734
+ /// 1. /
735
+ /// 2. /home/parseable
736
+ /// 3. /home/example/ignore
737
+ ///
738
+ /// And parseable is running with `P_HOT_TIER_DIR` pointing to a directory in
739
+ /// `/home/parseable`, we should return the usage stats of the disk mounted there.
740
+ fn get_disk_usage ( & self ) -> Option < DiskUtil > {
741
+ let mut disks = Disks :: new_with_refreshed_list ( ) ;
742
+ // Order the disk partitions by decreasing length of mount path
743
+ disks. sort_by_key ( |disk| disk. mount_point ( ) . to_str ( ) . unwrap ( ) . len ( ) ) ;
744
+ disks. reverse ( ) ;
745
+
746
+ for disk in disks. iter ( ) {
747
+ // Returns disk utilisation of first matching mount point
748
+ if self . hot_tier_path . starts_with ( disk. mount_point ( ) ) {
749
+ return Some ( DiskUtil {
750
+ total_space : disk. total_space ( ) ,
751
+ available_space : disk. available_space ( ) ,
752
+ used_space : disk. total_space ( ) - disk. available_space ( ) ,
753
+ } ) ;
754
+ }
755
+ }
756
+
757
+ None
758
+ }
729
759
}
730
760
731
761
/// get the hot tier file path for the stream
@@ -743,35 +773,6 @@ struct DiskUtil {
743
773
used_space : u64 ,
744
774
}
745
775
746
- /// Get the disk usage for the hot tier storage path. If we have a three disk paritions
747
- /// mounted as follows:
748
- /// 1. /
749
- /// 2. /home/parseable
750
- /// 3. /home/example/ignore
751
- ///
752
- /// And parseable is running with `P_HOT_TIER_DIR` pointing to a directory in
753
- /// `/home/parseable`, we should return the usage stats of the disk mounted there.
754
- fn get_disk_usage ( ) -> Option < DiskUtil > {
755
- let path = CONFIG . options . hot_tier_storage_path . as_ref ( ) ?;
756
- let mut disks = Disks :: new_with_refreshed_list ( ) ;
757
- // Order the disk partitions by decreasing length of mount path
758
- disks. sort_by_key ( |disk| disk. mount_point ( ) . to_str ( ) . unwrap ( ) . len ( ) ) ;
759
- disks. reverse ( ) ;
760
-
761
- for disk in disks. iter ( ) {
762
- // Returns disk utilisation of first matching mount point
763
- if path. starts_with ( disk. mount_point ( ) ) {
764
- return Some ( DiskUtil {
765
- total_space : disk. total_space ( ) ,
766
- available_space : disk. available_space ( ) ,
767
- used_space : disk. total_space ( ) - disk. available_space ( ) ,
768
- } ) ;
769
- }
770
- }
771
-
772
- None
773
- }
774
-
775
776
async fn delete_empty_directory_hot_tier ( path : & Path ) -> io:: Result < ( ) > {
776
777
async fn delete_helper ( path : & Path ) -> io:: Result < ( ) > {
777
778
if path. is_dir ( ) {
0 commit comments