hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uma Maheswara Rao G (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-3482) hdfs balancer throws ArrayIndexOutOfBoundsException if option is specified without arguments
Date Wed, 04 Jul 2012 02:01:34 GMT

    [ https://issues.apache.org/jira/browse/HDFS-3482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13406239#comment-13406239
] 

Uma Maheswara Rao G commented on HDFS-3482:
-------------------------------------------

Madhu, Thanks a lot for the patch. A few comments:


- 
{code}
try {
+      Balancer.Cli.parse(parameters);
+      fail(reason);
+    } catch (Exception e) {
+      assertTrue(e instanceof IllegalArgumentException);
+    }
{code}

Please handle specific exception instead of handling genric one and checking for instanceOf.

- 
{code}
   try {
+      Balancer.Cli.parse(parameters);
+      fail(reason);
+    } catch (Exception e) {
+       assertTrue(e instanceof IllegalArgumentException);
+    }
{code}
same as above

- 
How about adding below part before the if statements?

{code}
 Preconditions.checkArgument(args.length >= 2, "args = "
        + Arrays.toString(args));
{code}

- 
{code}
-      
       return new Parameters(policy, threshold);
-    }
+  }
{code}
seems like wrong format here?

- 
{code}
 /**
+   * Test parse method in Balancer#Cli class with wrong number of params
+   */
{code}
format the header comment correctly. and also need not have empty line between header comment
and @Test annotation.

- 
args.length>= 2  ---->   args.length >= 2 please note here, there should be one space
before operator.
                
> hdfs balancer throws ArrayIndexOutOfBoundsException if option is specified without arguments
> --------------------------------------------------------------------------------------------
>
>                 Key: HDFS-3482
>                 URL: https://issues.apache.org/jira/browse/HDFS-3482
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: balancer
>    Affects Versions: 2.0.0-alpha
>            Reporter: Stephen Chu
>            Assignee: madhukara phatak
>            Priority: Minor
>              Labels: newbie
>         Attachments: HDFS-3482-1.patch, HDFS-3482-2.patch, HDFS-3482.patch
>
>
> When running the hdfs balancer with an option but no argument, we run into an ArrayIndexOutOfBoundsException.
It's preferable to print the usage.
> {noformat}
> bash-3.2$ hdfs balancer -threshold
> Usage: java Balancer
>     [-policy <policy>]	the balancing policy: datanode or blockpool
>     [-threshold <threshold>]	Percentage of disk capacity
> Balancing took 261.0 milliseconds
> 12/05/31 09:38:46 ERROR balancer.Balancer: Exiting balancer due an exception
> java.lang.ArrayIndexOutOfBoundsException: 1
> 	at org.apache.hadoop.hdfs.server.balancer.Balancer$Cli.parse(Balancer.java:1505)
> 	at org.apache.hadoop.hdfs.server.balancer.Balancer$Cli.run(Balancer.java:1482)
> 	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
> 	at org.apache.hadoop.hdfs.server.balancer.Balancer.main(Balancer.java:1555)
> bash-3.2$ hdfs balancer -policy
> Usage: java Balancer
>     [-policy <policy>]	the balancing policy: datanode or blockpool
>     [-threshold <threshold>]	Percentage of disk capacity
> Balancing took 261.0 milliseconds
> 12/05/31 09:39:03 ERROR balancer.Balancer: Exiting balancer due an exception
> java.lang.ArrayIndexOutOfBoundsException: 1
> 	at org.apache.hadoop.hdfs.server.balancer.Balancer$Cli.parse(Balancer.java:1520)
> 	at org.apache.hadoop.hdfs.server.balancer.Balancer$Cli.run(Balancer.java:1482)
> 	at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
> 	at org.apache.hadoop.hdfs.server.balancer.Balancer.main(Balancer.java:1555)
> {noformat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message