@@ -368,10 +368,7 @@ public int compare(FileSummary.Section s1, FileSummary.Section s2) {
368368 * a particular step to be started for once.
369369 */
370370 Step currentStep = null ;
371- boolean loadInParallel =
372- conf .getBoolean (DFSConfigKeys .DFS_IMAGE_PARALLEL_LOAD_KEY ,
373- DFSConfigKeys .DFS_IMAGE_PARALLEL_LOAD_DEFAULT );
374- // TODO - check for compression and if enabled disable parallel
371+ boolean loadInParallel = enableParallelSaveAndLoad (conf );
375372
376373 ExecutorService executorService = null ;
377374 ArrayList <FileSummary .Section > subSections =
@@ -556,6 +553,25 @@ private void loadErasureCodingSection(InputStream in)
556553 }
557554 }
558555
556+ private static boolean enableParallelSaveAndLoad (Configuration conf ) {
557+ boolean loadInParallel =
558+ conf .getBoolean (DFSConfigKeys .DFS_IMAGE_PARALLEL_LOAD_KEY ,
559+ DFSConfigKeys .DFS_IMAGE_PARALLEL_LOAD_DEFAULT );
560+ boolean compressionEnabled = conf .getBoolean (
561+ DFSConfigKeys .DFS_IMAGE_COMPRESS_KEY ,
562+ DFSConfigKeys .DFS_IMAGE_COMPRESS_DEFAULT );
563+
564+ if (loadInParallel ) {
565+ if (compressionEnabled ) {
566+ LOG .warn ("Parallel Image loading and saving is not supported when {}" +
567+ " is set to true. Parallel will be disabled." ,
568+ DFSConfigKeys .DFS_IMAGE_COMPRESS_KEY );
569+ loadInParallel = false ;
570+ }
571+ }
572+ return loadInParallel ;
573+ }
574+
559575 public static final class Saver {
560576 public static final int CHECK_CANCEL_INTERVAL = 4096 ;
561577 private boolean writeSubSections = false ;
@@ -690,30 +706,18 @@ long save(File file, FSImageCompression compression) throws IOException {
690706 }
691707
692708 private void enableSubSectionsIfRequired () {
693- boolean parallelEnabled = conf .getBoolean (
694- DFSConfigKeys .DFS_IMAGE_PARALLEL_LOAD_KEY ,
695- DFSConfigKeys .DFS_IMAGE_PARALLEL_LOAD_DEFAULT );
709+ boolean parallelEnabled = enableParallelSaveAndLoad (conf );
696710 int inodeThreshold = conf .getInt (
697711 DFSConfigKeys .DFS_IMAGE_PARALLEL_INODE_THRESHOLD_KEY ,
698712 DFSConfigKeys .DFS_IMAGE_PARALLEL_INODE_THRESHOLD_DEFAULT );
699713 int targetSections = conf .getInt (
700714 DFSConfigKeys .DFS_IMAGE_PARALLEL_TARGET_SECTIONS_KEY ,
701715 DFSConfigKeys .DFS_IMAGE_PARALLEL_TARGET_SECTIONS_DEFAULT );
702- boolean compressionEnabled = conf .getBoolean (
703- DFSConfigKeys .DFS_IMAGE_COMPRESS_KEY ,
704- DFSConfigKeys .DFS_IMAGE_COMPRESS_DEFAULT );
705716
706717 if (parallelEnabled ) {
707- if (compressionEnabled ) {
708- LOG .warn ("Parallel Image loading is not supported when {} is set to" +
709- " true. Parallel loading will be disabled." ,
710- DFSConfigKeys .DFS_IMAGE_COMPRESS_KEY );
711- writeSubSections = false ;
712- return ;
713- }
714718 if (targetSections <= 0 ) {
715719 LOG .warn ("{} is set to {}. It must be greater than zero. Setting to" +
716- "default of {}" ,
720+ " default of {}" ,
717721 DFSConfigKeys .DFS_IMAGE_PARALLEL_TARGET_SECTIONS_KEY ,
718722 targetSections ,
719723 DFSConfigKeys .DFS_IMAGE_PARALLEL_TARGET_SECTIONS_DEFAULT );
0 commit comments