Skip to content

Commit fb27e28

Browse files
author
S O'Donnell
committed
Addressed intitial set of review comments from Wei-Chiu
1 parent 2aef690 commit fb27e28

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormatProtobuf.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,9 @@
13941394
will be used for an image previously created with sub-sections.
13951395
If the image contains sub-sections and this is set to false,
13961396
parallel loading will not be used.
1397+
Parallel loading is not compatible with image compression,
1398+
so if dfs.image.compress is set to true this setting will be
1399+
ignored and no parallel loading will occur.
13971400
</description>
13981401
</property>
13991402

0 commit comments

Comments
 (0)