[65/84] [abbrv] hive git commit: HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right away if we are unable to clean any old files (Hari Subramaniyan, reviewed by Xuefu Zhang)

2015-05-28 Thread xuefu
HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right 
away if we are unable to clean any old files (Hari Subramaniyan, reviewed by 
Xuefu Zhang)


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

Branch: refs/heads/spark
Commit: f078dd4272ae0e27bb118cff5a76b850045e1673
Parents: 5b423a8
Author: Hari Subramaniyan 
Authored: Wed May 27 00:35:19 2015 -0700
Committer: Hari Subramaniyan 
Committed: Wed May 27 00:35:19 2015 -0700

--
 .../apache/hadoop/hive/ant/QTestGenTask.java| 35 
 1 file changed, 28 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/f078dd42/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
--
diff --git a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java 
b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
index b3315c7..7fffe13 100644
--- a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
+++ b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
@@ -35,6 +35,7 @@ import java.util.HashMap;
 
 import com.google.common.base.Splitter;
 import com.google.common.collect.Sets;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
@@ -312,6 +313,23 @@ public class QTestGenTask extends Task {
 return queryFileRegex;
   }
 
+  private String createAlternativeFile(File file) throws Exception {
+String fileParentDir = file.getParent();
+String fileName = file.getName();
+int dotIndex = fileName.lastIndexOf('.');
+String fileNameWithoutExtension = dotIndex == -1 ? fileName : 
fileName.substring(0, dotIndex);
+String fileNameExtension = dotIndex == -1 ? "" : 
fileName.substring(dotIndex);
+
+// If prefix length is < 3, File.createTempFile() will throw an 
IllegalArgumentException.
+// We need to avoid this case.
+if (fileNameWithoutExtension.length() < 3) {
+  fileNameWithoutExtension = fileNameWithoutExtension + "_tmp";
+}
+File alternativeFile = File.createTempFile(fileNameWithoutExtension, 
fileNameExtension,
+  new File(fileParentDir));
+return alternativeFile.getCanonicalPath();
+  }
+
   public void execute() throws BuildException {
 if (getTemplatePath().equals("")) {
   throw new BuildException("No templatePath attribute specified");
@@ -436,8 +454,10 @@ public class QTestGenTask extends Task {
   if (logFile != null) {
 File lf = new File(logFile);
 if (lf.exists()) {
+  System.out.println("Log file already exists: " + 
lf.getCanonicalPath());
   if (!lf.delete()) {
-throw new Exception("Could not delete log file " + 
lf.getCanonicalPath());
+System.out.println("Could not delete log file " + 
lf.getCanonicalPath());
+logFile = createAlternativeFile(lf);
   }
 }
 
@@ -458,16 +478,17 @@ public class QTestGenTask extends Task {
   String qFileNamesFile = qFileNames.toURI().getPath();
 
   if (qFileNames.exists()) {
+System.out.println("Query file names containing file already exists: " 
+ qFileNamesFile);
 if (!qFileNames.delete()) {
-  throw new Exception("Could not delete old query file names 
containing file " +
+  System.out.println("Could not delete query file names containing 
file " +
+qFileNames.getCanonicalPath());
+  qFileNamesFile = createAlternativeFile(qFileNames);
+} else if (!qFileNames.createNewFile()) {
+  System.out.println("Could not create query file names containing 
file " +
 qFileNamesFile);
+  qFileNamesFile = createAlternativeFile(qFileNames);
 }
   }
-  if (!qFileNames.createNewFile()) {
-throw new Exception("Could not create query file names containing file 
" +
-  qFileNamesFile);
-  }
-
   FileWriter fw = new FileWriter(qFileNames.getCanonicalFile());
   BufferedWriter bw = new BufferedWriter(fw);
 



[65/82] [abbrv] hive git commit: HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right away if we are unable to clean any old files (Hari Subramaniyan, reviewed by Xuefu Zhang)

2015-05-28 Thread gopalv
HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right 
away if we are unable to clean any old files (Hari Subramaniyan, reviewed by 
Xuefu Zhang)


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

Branch: refs/heads/llap
Commit: f078dd4272ae0e27bb118cff5a76b850045e1673
Parents: 5b423a8
Author: Hari Subramaniyan 
Authored: Wed May 27 00:35:19 2015 -0700
Committer: Hari Subramaniyan 
Committed: Wed May 27 00:35:19 2015 -0700

--
 .../apache/hadoop/hive/ant/QTestGenTask.java| 35 
 1 file changed, 28 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/f078dd42/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
--
diff --git a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java 
b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
index b3315c7..7fffe13 100644
--- a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
+++ b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
@@ -35,6 +35,7 @@ import java.util.HashMap;
 
 import com.google.common.base.Splitter;
 import com.google.common.collect.Sets;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
@@ -312,6 +313,23 @@ public class QTestGenTask extends Task {
 return queryFileRegex;
   }
 
+  private String createAlternativeFile(File file) throws Exception {
+String fileParentDir = file.getParent();
+String fileName = file.getName();
+int dotIndex = fileName.lastIndexOf('.');
+String fileNameWithoutExtension = dotIndex == -1 ? fileName : 
fileName.substring(0, dotIndex);
+String fileNameExtension = dotIndex == -1 ? "" : 
fileName.substring(dotIndex);
+
+// If prefix length is < 3, File.createTempFile() will throw an 
IllegalArgumentException.
+// We need to avoid this case.
+if (fileNameWithoutExtension.length() < 3) {
+  fileNameWithoutExtension = fileNameWithoutExtension + "_tmp";
+}
+File alternativeFile = File.createTempFile(fileNameWithoutExtension, 
fileNameExtension,
+  new File(fileParentDir));
+return alternativeFile.getCanonicalPath();
+  }
+
   public void execute() throws BuildException {
 if (getTemplatePath().equals("")) {
   throw new BuildException("No templatePath attribute specified");
@@ -436,8 +454,10 @@ public class QTestGenTask extends Task {
   if (logFile != null) {
 File lf = new File(logFile);
 if (lf.exists()) {
+  System.out.println("Log file already exists: " + 
lf.getCanonicalPath());
   if (!lf.delete()) {
-throw new Exception("Could not delete log file " + 
lf.getCanonicalPath());
+System.out.println("Could not delete log file " + 
lf.getCanonicalPath());
+logFile = createAlternativeFile(lf);
   }
 }
 
@@ -458,16 +478,17 @@ public class QTestGenTask extends Task {
   String qFileNamesFile = qFileNames.toURI().getPath();
 
   if (qFileNames.exists()) {
+System.out.println("Query file names containing file already exists: " 
+ qFileNamesFile);
 if (!qFileNames.delete()) {
-  throw new Exception("Could not delete old query file names 
containing file " +
+  System.out.println("Could not delete query file names containing 
file " +
+qFileNames.getCanonicalPath());
+  qFileNamesFile = createAlternativeFile(qFileNames);
+} else if (!qFileNames.createNewFile()) {
+  System.out.println("Could not create query file names containing 
file " +
 qFileNamesFile);
+  qFileNamesFile = createAlternativeFile(qFileNames);
 }
   }
-  if (!qFileNames.createNewFile()) {
-throw new Exception("Could not create query file names containing file 
" +
-  qFileNamesFile);
-  }
-
   FileWriter fw = new FileWriter(qFileNames.getCanonicalFile());
   BufferedWriter bw = new BufferedWriter(fw);
 



hive git commit: HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right away if we are unable to clean any old files (Hari Subramaniyan, reviewed by Xuefu Zhang)

2015-05-27 Thread harisankar
Repository: hive
Updated Branches:
  refs/heads/branch-1.2 d7f566696 -> a3d338a9b


HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right 
away if we are unable to clean any old files (Hari Subramaniyan, reviewed by 
Xuefu Zhang)


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

Branch: refs/heads/branch-1.2
Commit: a3d338a9b7ff9124f43a70e1c4e816ec713d9527
Parents: d7f5666
Author: Hari Subramaniyan 
Authored: Wed May 27 00:35:19 2015 -0700
Committer: Hari Subramaniyan 
Committed: Wed May 27 00:36:12 2015 -0700

--
 .../apache/hadoop/hive/ant/QTestGenTask.java| 35 
 1 file changed, 28 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/a3d338a9/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
--
diff --git a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java 
b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
index b3315c7..7fffe13 100644
--- a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
+++ b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
@@ -35,6 +35,7 @@ import java.util.HashMap;
 
 import com.google.common.base.Splitter;
 import com.google.common.collect.Sets;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
@@ -312,6 +313,23 @@ public class QTestGenTask extends Task {
 return queryFileRegex;
   }
 
+  private String createAlternativeFile(File file) throws Exception {
+String fileParentDir = file.getParent();
+String fileName = file.getName();
+int dotIndex = fileName.lastIndexOf('.');
+String fileNameWithoutExtension = dotIndex == -1 ? fileName : 
fileName.substring(0, dotIndex);
+String fileNameExtension = dotIndex == -1 ? "" : 
fileName.substring(dotIndex);
+
+// If prefix length is < 3, File.createTempFile() will throw an 
IllegalArgumentException.
+// We need to avoid this case.
+if (fileNameWithoutExtension.length() < 3) {
+  fileNameWithoutExtension = fileNameWithoutExtension + "_tmp";
+}
+File alternativeFile = File.createTempFile(fileNameWithoutExtension, 
fileNameExtension,
+  new File(fileParentDir));
+return alternativeFile.getCanonicalPath();
+  }
+
   public void execute() throws BuildException {
 if (getTemplatePath().equals("")) {
   throw new BuildException("No templatePath attribute specified");
@@ -436,8 +454,10 @@ public class QTestGenTask extends Task {
   if (logFile != null) {
 File lf = new File(logFile);
 if (lf.exists()) {
+  System.out.println("Log file already exists: " + 
lf.getCanonicalPath());
   if (!lf.delete()) {
-throw new Exception("Could not delete log file " + 
lf.getCanonicalPath());
+System.out.println("Could not delete log file " + 
lf.getCanonicalPath());
+logFile = createAlternativeFile(lf);
   }
 }
 
@@ -458,16 +478,17 @@ public class QTestGenTask extends Task {
   String qFileNamesFile = qFileNames.toURI().getPath();
 
   if (qFileNames.exists()) {
+System.out.println("Query file names containing file already exists: " 
+ qFileNamesFile);
 if (!qFileNames.delete()) {
-  throw new Exception("Could not delete old query file names 
containing file " +
+  System.out.println("Could not delete query file names containing 
file " +
+qFileNames.getCanonicalPath());
+  qFileNamesFile = createAlternativeFile(qFileNames);
+} else if (!qFileNames.createNewFile()) {
+  System.out.println("Could not create query file names containing 
file " +
 qFileNamesFile);
+  qFileNamesFile = createAlternativeFile(qFileNames);
 }
   }
-  if (!qFileNames.createNewFile()) {
-throw new Exception("Could not create query file names containing file 
" +
-  qFileNamesFile);
-  }
-
   FileWriter fw = new FileWriter(qFileNames.getCanonicalFile());
   BufferedWriter bw = new BufferedWriter(fw);
 



hive git commit: HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right away if we are unable to clean any old files (Hari Subramaniyan, reviewed by Xuefu Zhang)

2015-05-27 Thread harisankar
Repository: hive
Updated Branches:
  refs/heads/master 5b423a87f -> f078dd427


HIVE-10768 : In QTestGenTask.execute() we should not throw an exception right 
away if we are unable to clean any old files (Hari Subramaniyan, reviewed by 
Xuefu Zhang)


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

Branch: refs/heads/master
Commit: f078dd4272ae0e27bb118cff5a76b850045e1673
Parents: 5b423a8
Author: Hari Subramaniyan 
Authored: Wed May 27 00:35:19 2015 -0700
Committer: Hari Subramaniyan 
Committed: Wed May 27 00:35:19 2015 -0700

--
 .../apache/hadoop/hive/ant/QTestGenTask.java| 35 
 1 file changed, 28 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/hive/blob/f078dd42/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
--
diff --git a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java 
b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
index b3315c7..7fffe13 100644
--- a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
+++ b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
@@ -35,6 +35,7 @@ import java.util.HashMap;
 
 import com.google.common.base.Splitter;
 import com.google.common.collect.Sets;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
@@ -312,6 +313,23 @@ public class QTestGenTask extends Task {
 return queryFileRegex;
   }
 
+  private String createAlternativeFile(File file) throws Exception {
+String fileParentDir = file.getParent();
+String fileName = file.getName();
+int dotIndex = fileName.lastIndexOf('.');
+String fileNameWithoutExtension = dotIndex == -1 ? fileName : 
fileName.substring(0, dotIndex);
+String fileNameExtension = dotIndex == -1 ? "" : 
fileName.substring(dotIndex);
+
+// If prefix length is < 3, File.createTempFile() will throw an 
IllegalArgumentException.
+// We need to avoid this case.
+if (fileNameWithoutExtension.length() < 3) {
+  fileNameWithoutExtension = fileNameWithoutExtension + "_tmp";
+}
+File alternativeFile = File.createTempFile(fileNameWithoutExtension, 
fileNameExtension,
+  new File(fileParentDir));
+return alternativeFile.getCanonicalPath();
+  }
+
   public void execute() throws BuildException {
 if (getTemplatePath().equals("")) {
   throw new BuildException("No templatePath attribute specified");
@@ -436,8 +454,10 @@ public class QTestGenTask extends Task {
   if (logFile != null) {
 File lf = new File(logFile);
 if (lf.exists()) {
+  System.out.println("Log file already exists: " + 
lf.getCanonicalPath());
   if (!lf.delete()) {
-throw new Exception("Could not delete log file " + 
lf.getCanonicalPath());
+System.out.println("Could not delete log file " + 
lf.getCanonicalPath());
+logFile = createAlternativeFile(lf);
   }
 }
 
@@ -458,16 +478,17 @@ public class QTestGenTask extends Task {
   String qFileNamesFile = qFileNames.toURI().getPath();
 
   if (qFileNames.exists()) {
+System.out.println("Query file names containing file already exists: " 
+ qFileNamesFile);
 if (!qFileNames.delete()) {
-  throw new Exception("Could not delete old query file names 
containing file " +
+  System.out.println("Could not delete query file names containing 
file " +
+qFileNames.getCanonicalPath());
+  qFileNamesFile = createAlternativeFile(qFileNames);
+} else if (!qFileNames.createNewFile()) {
+  System.out.println("Could not create query file names containing 
file " +
 qFileNamesFile);
+  qFileNamesFile = createAlternativeFile(qFileNames);
 }
   }
-  if (!qFileNames.createNewFile()) {
-throw new Exception("Could not create query file names containing file 
" +
-  qFileNamesFile);
-  }
-
   FileWriter fw = new FileWriter(qFileNames.getCanonicalFile());
   BufferedWriter bw = new BufferedWriter(fw);