You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by rb...@apache.org on 2015/10/29 18:24:33 UTC

tez git commit: TEZ-2814. ATSImportTool has a return statement in a finally block (rbalamohan)

Repository: tez
Updated Branches:
  refs/heads/master 19808b7cd -> dcc51085e


TEZ-2814. ATSImportTool has a return statement in a finally block (rbalamohan)


Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/dcc51085
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/dcc51085
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/dcc51085

Branch: refs/heads/master
Commit: dcc51085ee46a813ee05aeb067cab04d76ba21cf
Parents: 19808b7
Author: Rajesh Balamohan <rb...@apache.org>
Authored: Thu Oct 29 10:25:29 2015 -0700
Committer: Rajesh Balamohan <rb...@apache.org>
Committed: Thu Oct 29 10:25:29 2015 -0700

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/tez/history/ATSImportTool.java   | 22 +++++---------------
 .../apache/tez/history/TestHistoryParser.java   | 14 ++++++++-----
 3 files changed, 15 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/dcc51085/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 809ebf9..07ad182 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,7 @@ INCOMPATIBLE CHANGES
   TEZ-2679. Admin forms of launch env settings
 
 ALL CHANGES:
+  TEZ-2814. ATSImportTool has a return statement in a finally block
   TEZ-2906. Compilation fails with hadoop 2.2.0
   TEZ-2900. Ignore V_INPUT_DATA_INFORMATION when vertex is in Failed/Killed/Error
   TEZ-2244. PipelinedSorter: Progressive allocation for sort-buffers

http://git-wip-us.apache.org/repos/asf/tez/blob/dcc51085/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java
----------------------------------------------------------------------
diff --git a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java
index 5fddd00..3efeb5a 100644
--- a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java
+++ b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/ATSImportTool.java
@@ -121,13 +121,11 @@ public class ATSImportTool extends Configured implements Tool {
   private final String baseUri;
   private final String dagId;
 
-  private final File downloadDir;
   private final File zipFile;
   private final Client httpClient;
   private final TezDAGID tezDAGID;
 
-  public ATSImportTool(String baseUri, String dagId, File downloadDir, int batchSize)
-      throws TezException {
+  public ATSImportTool(String baseUri, String dagId, File downloadDir, int batchSize) {
     Preconditions.checkArgument(!Strings.isNullOrEmpty(dagId), "dagId can not be null or empty");
     Preconditions.checkArgument(downloadDir != null, "downloadDir can not be null");
     tezDAGID = TezDAGID.fromString(dagId);
@@ -138,7 +136,6 @@ public class ATSImportTool extends Configured implements Tool {
 
     this.httpClient = getHttpClient();
 
-    this.downloadDir = downloadDir;
     this.zipFile = new File(downloadDir, this.dagId + ".zip");
 
     boolean result = downloadDir.mkdirs();
@@ -268,8 +265,7 @@ public class ATSImportTool extends Configured implements Tool {
     }
   }
 
-  private String logErrorMessage(ClientResponse response) throws IOException {
-    StringBuilder sb = new StringBuilder();
+  private void logErrorMessage(ClientResponse response) throws IOException {
     LOG.error("Response status={}", response.getClientResponseStatus().toString());
     LineIterator it = null;
     try {
@@ -283,7 +279,6 @@ public class ATSImportTool extends Configured implements Tool {
         it.close();
       }
     }
-    return sb.toString();
   }
 
   //For secure cluster, this should work as long as valid ticket is available in the node.
@@ -433,9 +428,8 @@ public class ATSImportTool extends Configured implements Tool {
   }
 
   @VisibleForTesting
-  public static int process(String[] args) {
+  public static int process(String[] args) throws Exception {
     Options options = buildOptions();
-    int result = -1;
     try {
       Configuration conf = new Configuration();
       CommandLine cmdLine = new GnuParser().parse(options, args);
@@ -449,21 +443,15 @@ public class ATSImportTool extends Configured implements Tool {
       int batchSize = (cmdLine.hasOption(BATCH_SIZE)) ?
           (Integer.parseInt(cmdLine.getOptionValue(BATCH_SIZE))) : BATCH_SIZE_DEFAULT;
 
-      result = ToolRunner.run(conf, new ATSImportTool(baseTimelineURL, dagId,
+      return ToolRunner.run(conf, new ATSImportTool(baseTimelineURL, dagId,
           downloadDir, batchSize), args);
-
-      return result;
-    } catch (MissingOptionException missingOptionException) {
-      LOG.error("Error in parsing options ", missingOptionException);
-      printHelp(options);
     } catch (ParseException e) {
       LOG.error("Error in parsing options ", e);
       printHelp(options);
+      throw e;
     } catch (Exception e) {
       LOG.error("Error in processing ", e);
       throw e;
-    } finally {
-      return result;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tez/blob/dcc51085/tez-plugins/tez-history-parser/src/test/java/org/apache/tez/history/TestHistoryParser.java
----------------------------------------------------------------------
diff --git a/tez-plugins/tez-history-parser/src/test/java/org/apache/tez/history/TestHistoryParser.java b/tez-plugins/tez-history-parser/src/test/java/org/apache/tez/history/TestHistoryParser.java
index dedd9ef..2b23294 100644
--- a/tez-plugins/tez-history-parser/src/test/java/org/apache/tez/history/TestHistoryParser.java
+++ b/tez-plugins/tez-history-parser/src/test/java/org/apache/tez/history/TestHistoryParser.java
@@ -19,6 +19,8 @@
 package org.apache.tez.history;
 
 import com.google.common.collect.Sets;
+import com.sun.tools.internal.ws.processor.ProcessorException;
+import org.apache.commons.cli.ParseException;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.hadoop.conf.Configuration;
@@ -92,9 +94,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 public class TestHistoryParser {
 
@@ -342,8 +342,12 @@ public class TestHistoryParser {
         atsAddress
       };
 
-    int result = ATSImportTool.process(args);
-    assertTrue(result == -1);
+    try {
+      int result = ATSImportTool.process(args);
+      fail("Should have failed with processException");
+    } catch(ParseException e) {
+      //expects exception
+    }
   }
 
   /**