@@ -230,6 +230,15 @@ static long getLong(Configuration conf, String key, long defaultValue) {
230230 return v ;
231231 }
232232
233+ static long getLongBytes (Configuration conf , String key , long defaultValue ) {
234+ final long v = conf .getLongBytes (key , defaultValue );
235+ LOG .info (key + " = " + v + " (default=" + defaultValue + ")" );
236+ if (v <= 0 ) {
237+ throw new HadoopIllegalArgumentException (key + " = " + v + " <= " + 0 );
238+ }
239+ return v ;
240+ }
241+
233242 static int getInt (Configuration conf , String key , int defaultValue ) {
234243 final int v = conf .getInt (key , defaultValue );
235244 LOG .info (key + " = " + v + " (default=" + defaultValue + ")" );
@@ -261,10 +270,10 @@ static int getInt(Configuration conf, String key, int defaultValue) {
261270 DFSConfigKeys .DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_KEY ,
262271 DFSConfigKeys .DFS_DATANODE_BALANCE_MAX_NUM_CONCURRENT_MOVES_DEFAULT );
263272
264- final long getBlocksSize = getLong (conf ,
273+ final long getBlocksSize = getLongBytes (conf ,
265274 DFSConfigKeys .DFS_BALANCER_GETBLOCKS_SIZE_KEY ,
266275 DFSConfigKeys .DFS_BALANCER_GETBLOCKS_SIZE_DEFAULT );
267- final long getBlocksMinBlockSize = getLong (conf ,
276+ final long getBlocksMinBlockSize = getLongBytes (conf ,
268277 DFSConfigKeys .DFS_BALANCER_GETBLOCKS_MIN_BLOCK_SIZE_KEY ,
269278 DFSConfigKeys .DFS_BALANCER_GETBLOCKS_MIN_BLOCK_SIZE_DEFAULT );
270279
@@ -279,10 +288,10 @@ static int getInt(Configuration conf, String key, int defaultValue) {
279288 this .sourceNodes = p .getSourceNodes ();
280289 this .runDuringUpgrade = p .getRunDuringUpgrade ();
281290
282- this .maxSizeToMove = getLong (conf ,
291+ this .maxSizeToMove = getLongBytes (conf ,
283292 DFSConfigKeys .DFS_BALANCER_MAX_SIZE_TO_MOVE_KEY ,
284293 DFSConfigKeys .DFS_BALANCER_MAX_SIZE_TO_MOVE_DEFAULT );
285- this .defaultBlockSize = getLong (conf ,
294+ this .defaultBlockSize = getLongBytes (conf ,
286295 DFSConfigKeys .DFS_BLOCK_SIZE_KEY ,
287296 DFSConfigKeys .DFS_BLOCK_SIZE_DEFAULT );
288297 }
0 commit comments