@@ -107,7 +107,7 @@ public void testParsebandwidth() {
107107 DistCpOptions options = OptionsParser .parse (new String [] {
108108 "hdfs://localhost:9820/source/first" ,
109109 "hdfs://localhost:9820/target/" });
110- Assert .assertEquals (options .getMapBandwidth (), DistCpConstants . DEFAULT_BANDWIDTH_MB , DELTA );
110+ Assert .assertEquals (options .getMapBandwidth (), 0 , DELTA );
111111
112112 options = OptionsParser .parse (new String [] {
113113 "-bandwidth" ,
@@ -389,7 +389,7 @@ public void testToString() {
389389 + "deleteMissing=false, ignoreFailures=false, overwrite=false, "
390390 + "append=false, useDiff=false, fromSnapshot=null, toSnapshot=null, "
391391 + "skipCRC=false, blocking=true, numListstatusThreads=0, maxMaps=20, "
392- + "mapBandwidth=100 .0, "
392+ + "mapBandwidth=0 .0, "
393393 + "copyStrategy='uniformsize', preserveStatus=[], "
394394 + "preserveRawXattrs=false, atomicWorkPath=null, logPath=null, "
395395 + "sourceFileListing=abc, sourcePaths=null, targetPath=xyz, "
@@ -572,6 +572,8 @@ public void testOptionsAppendToConf() {
572572 Configuration conf = new Configuration ();
573573 Assert .assertFalse (conf .getBoolean (DistCpOptionSwitch .IGNORE_FAILURES .getConfigLabel (), false ));
574574 Assert .assertFalse (conf .getBoolean (DistCpOptionSwitch .ATOMIC_COMMIT .getConfigLabel (), false ));
575+ Assert .assertEquals (
576+ conf .getRaw (DistCpOptionSwitch .BANDWIDTH .getConfigLabel ()), null );
575577 DistCpOptions options = OptionsParser .parse (new String [] {
576578 "-atomic" ,
577579 "-i" ,
@@ -581,7 +583,7 @@ public void testOptionsAppendToConf() {
581583 Assert .assertTrue (conf .getBoolean (DistCpOptionSwitch .IGNORE_FAILURES .getConfigLabel (), false ));
582584 Assert .assertTrue (conf .getBoolean (DistCpOptionSwitch .ATOMIC_COMMIT .getConfigLabel (), false ));
583585 Assert .assertEquals (conf .getFloat (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), -1 ),
584- DistCpConstants . DEFAULT_BANDWIDTH_MB , DELTA );
586+ - 1.0 , DELTA );
585587
586588 conf = new Configuration ();
587589 Assert .assertFalse (conf .getBoolean (DistCpOptionSwitch .SYNC_FOLDERS .getConfigLabel (), false ));
@@ -602,6 +604,62 @@ public void testOptionsAppendToConf() {
602604 Assert .assertEquals (conf .getFloat (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), -1 ), 11.2 , DELTA );
603605 }
604606
607+ @ Test
608+ public void testOptionsAppendToConfDoesntOverwriteBandwidth () {
609+ Configuration conf = new Configuration ();
610+ Assert .assertEquals (
611+ conf .getRaw (DistCpOptionSwitch .BANDWIDTH .getConfigLabel ()), null );
612+ DistCpOptions options = OptionsParser .parse (new String [] {
613+ "hdfs://localhost:8020/source/first" ,
614+ "hdfs://localhost:8020/target/" });
615+ options .appendToConf (conf );
616+ Assert .assertEquals (
617+ conf .getFloat (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), -1 ), -1.0 ,
618+ DELTA );
619+
620+ conf = new Configuration ();
621+ Assert .assertEquals (
622+ conf .getRaw (DistCpOptionSwitch .BANDWIDTH .getConfigLabel ()), null );
623+ options = OptionsParser .parse (new String [] {
624+ "-update" ,
625+ "-delete" ,
626+ "-pu" ,
627+ "-bandwidth" ,
628+ "77" ,
629+ "hdfs://localhost:8020/source/first" ,
630+ "hdfs://localhost:8020/target/" });
631+ options .appendToConf (conf );
632+ Assert .assertEquals (
633+ conf .getFloat (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), -1 ), 77.0 ,
634+ DELTA );
635+
636+ conf = new Configuration ();
637+ conf .set (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), "88" );
638+ Assert .assertEquals (
639+ conf .getRaw (DistCpOptionSwitch .BANDWIDTH .getConfigLabel ()), "88" );
640+ options = OptionsParser .parse (new String [] {
641+ "hdfs://localhost:8020/source/first" ,
642+ "hdfs://localhost:8020/target/" });
643+ options .appendToConf (conf );
644+ Assert .assertEquals (
645+ conf .getFloat (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), -1 ), 88.0 ,
646+ DELTA );
647+
648+ conf = new Configuration ();
649+ conf .set (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), "88.0" );
650+ Assert .assertEquals (
651+ conf .getRaw (DistCpOptionSwitch .BANDWIDTH .getConfigLabel ()), "88.0" );
652+ options = OptionsParser .parse (new String [] {
653+ "-bandwidth" ,
654+ "99" ,
655+ "hdfs://localhost:8020/source/first" ,
656+ "hdfs://localhost:8020/target/" });
657+ options .appendToConf (conf );
658+ Assert .assertEquals (
659+ conf .getFloat (DistCpOptionSwitch .BANDWIDTH .getConfigLabel (), -1 ), 99.0 ,
660+ DELTA );
661+ }
662+
605663 @ Test
606664 public void testAppendOption () {
607665 Configuration conf = new Configuration ();
0 commit comments