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

Suresh Srinivas commented on HDFS-4451:
---------------------------------------

+1 for Chris's comments earlier.

bq. If that extra test doesn't add anything, then the other option would be to 
remove the useTool flag from the twoNodeTest method signature, just so the 
unused flag doesn't cause any confusion.
Lets remove useTool from twoNodeTest and just use one node test to test the 
exit code.

One minor optional thing, you have lot of empty lines in the code. It could be 
more compact:
{code}
 private void runBalancerCli(Configuration conf,
     long totalUsedSpace, long totalCapacity) throws Exception {
   waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);

   final String[] args = { "-policy", "datanode" };
   final Tool tool = new Cli();    
   tool.setConf(conf);
   final int r = tool.run(args); // start rebalancing
   
   assertEquals("Tools should exit 0 on success", 0, r);
   waitForHeartBeat(totalUsedSpace, totalCapacity, client, cluster);
   LOG.info("Rebalancing with default ctor.");
   waitForBalancer(totalUsedSpace, totalCapacity, client, cluster);
 }

  * Verify balancer CLI exit code on success is 0
  */
 @Test(timeout=100000)
 public void testExitZeroOnSuccess() throws Exception {
   final Configuration conf = new HdfsConfiguration();   
   initConf(new HdfsConfiguration());  
   oneNodeTest(conf, true);
 }

{code}

                
> hdfs balancer exits 1 on success, it should exit 0
> --------------------------------------------------
>
>                 Key: HDFS-4451
>                 URL: https://issues.apache.org/jira/browse/HDFS-4451
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: balancer
>    Affects Versions: 2.0.2-alpha
>         Environment: Centos 6.3, JDK 1.6.0_25
>            Reporter: Joshua Blatt
>         Attachments: HDFS-4451.patch, HDFS-4451.patch
>
>
> Though the org.apache.hadoop.util.Tool interface javadocs indicate  
> implementations should return 0 on success, the 
> org.apache.hadoop.hdfs.server.balance.Balancer.Cli implementation returns the 
> int values of this enum instead:
>   // Exit status
>   enum ReturnStatus {
>     SUCCESS(1),
>     IN_PROGRESS(0),
>     ALREADY_RUNNING(-1),
>     NO_MOVE_BLOCK(-2),
>     NO_MOVE_PROGRESS(-3),
>     IO_EXCEPTION(-4),
>     ILLEGAL_ARGS(-5),
>     INTERRUPTED(-6);
> This created an issue for us when we tried to run the hdfs balancer as a cron 
> job.   Cron sends emails whenever a executable it runs exits non-zero.   We'd 
> either have to disable all emails and miss real issues or fix this bug.
> I think both SUCCESS and IN_PROGRESS ReturnStatuses should lead to exit 0.
> Marking this change as incompatible because existing scripts which interpret 
> exit 1 as success will be broken (unless they defensively/liberally interpret 
> both exit 1 and exit 0 as success).

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to