You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by gd...@apache.org on 2011/11/18 11:18:39 UTC

svn commit: r1203569 - in /pig/trunk: CHANGES.txt src/org/apache/pig/Main.java

Author: gdfm
Date: Fri Nov 18 10:18:39 2011
New Revision: 1203569

URL: http://svn.apache.org/viewvc?rev=1203569&view=rev
Log:
PIG-2380: Expose version information more cleanly (jcoveney via azaroth)


Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/Main.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1203569&r1=1203568&r2=1203569&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri Nov 18 10:18:39 2011
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
 
 IMPROVEMENTS
 
+PIG-2380: Expose version information more cleanly (jcoveney via azaroth)
+
 PIG-2311: STRSPLIT needs to allow bytearray arguments (xuting via olgan)
 
 PIG-2365: Current TOP implementation needlessly results in a null bag name (jcoveney via dvryaboy) 

Modified: pig/trunk/src/org/apache/pig/Main.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/Main.java?rev=1203569&r1=1203568&r2=1203569&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/Main.java (original)
+++ pig/trunk/src/org/apache/pig/Main.java Fri Nov 18 10:18:39 2011
@@ -84,23 +84,60 @@ import org.apache.pig.tools.timer.Perfor
 @InterfaceAudience.LimitedPrivate({"Oozie"})
 @InterfaceStability.Stable
 public class Main {
-   
+
     private final static Log log = LogFactory.getLog(Main.class);
-    
+
     private static final String LOG4J_CONF = "log4jconf";
     private static final String BRIEF = "brief";
     private static final String DEBUG = "debug";
     private static final String VERBOSE = "verbose";
 
+    private static final String version;
+    private static final String majorVersion;
+    private static final String minorVersion;
+    private static final String patchVersion;
+    private static final String svnRevision;
+    private static final String buildTime;
+
     private enum ExecMode {STRING, FILE, SHELL, UNKNOWN}
 
-    private static final String PROP_FILT_SIMPL_OPT 
+    private static final String PROP_FILT_SIMPL_OPT
         = "pig.exec.filterLogicExpressionSimplifier";
-    
+
+    static {
+       Attributes attr=null;
+       try {
+            String findContainingJar = JarManager.findContainingJar(Main.class);
+            JarFile jar = new JarFile(findContainingJar);
+            final Manifest manifest = jar.getManifest();
+            final Map<String,Attributes> attrs = manifest.getEntries();
+            attr = attrs.get("org/apache/pig");
+        } catch (Exception e) {
+            log.warn("Unable to read pigs manifest file, version information unavailable");
+            log.warn("Exception: "+e);
+        }
+        if (attr!=null) {
+            version = attr.getValue("Implementation-Version");
+            svnRevision = attr.getValue("Svn-Revision");
+            buildTime = attr.getValue("Build-TimeStamp");
+            String[] split = version.split("-")[0].split("\\.");
+            majorVersion=split[0];
+            minorVersion=split[1];
+            patchVersion=split[2];
+        } else {
+            version=null;
+            majorVersion=null;
+            minorVersion=null;
+            patchVersion=null;
+            svnRevision=null;
+            buildTime=null;
+        }
+    }
+
 /**
  * The Main-Class for the Pig Jar that will provide a shell and setup a classpath appropriate
  * for executing Jar files.  Warning, this method calls System.exit().
- * 
+ *
  * @param args
  *            -jar can be used to add additional jar files (colon separated). - will start a
  *            shell. -e will execute the rest of the command line as if it was input to the
@@ -116,21 +153,21 @@ static int run(String args[], PigProgres
     boolean verbose = false;
     boolean gruntCalled = false;
     String logFileName = null;
-    
+
     try {
         Configuration conf = new Configuration(false);
         GenericOptionsParser parser = new GenericOptionsParser(conf, args);
-        conf = parser.getConfiguration();    
-        
+        conf = parser.getConfiguration();
+
         Properties properties = new Properties();
         PropertiesUtil.loadDefaultProperties(properties);
         properties.putAll(ConfigurationUtil.toProperties(conf));
-        
+
         String[] pigArgs = parser.getRemainingArgs();
-                
-        boolean userSpecifiedLog = false;        
+
+        boolean userSpecifiedLog = false;
         boolean checkScriptOnly = false;
-    
+
         BufferedReader pin = null;
         boolean debug = false;
         boolean dryrun = false;
@@ -148,7 +185,7 @@ static int run(String args[], PigProgres
         opts.registerOpt('f', "file", CmdLineParser.ValueExpected.REQUIRED);
         opts.registerOpt('g', "embedded", CmdLineParser.ValueExpected.REQUIRED);
         opts.registerOpt('h', "help", CmdLineParser.ValueExpected.OPTIONAL);
-        opts.registerOpt('i', "version", CmdLineParser.ValueExpected.OPTIONAL);        
+        opts.registerOpt('i', "version", CmdLineParser.ValueExpected.OPTIONAL);
         opts.registerOpt('l', "logfile", CmdLineParser.ValueExpected.REQUIRED);
         opts.registerOpt('m', "param_file", CmdLineParser.ValueExpected.OPTIONAL);
         opts.registerOpt('p', "param", CmdLineParser.ValueExpected.OPTIONAL);
@@ -169,12 +206,12 @@ static int run(String args[], PigProgres
         if(execTypeString!=null && execTypeString.length()>0){
             execType = PigServer.parseExecType(execTypeString);
         }
-                
+
         if (properties.getProperty("aggregate.warning") == null) {
             //by default warning aggregation is on
             properties.setProperty("aggregate.warning", ""+true);
         }
-                
+
         if (properties.getProperty("opt.multiquery") == null) {
             //by default multiquery optimization is on
             properties.setProperty("opt.multiquery", ""+true);
@@ -184,7 +221,7 @@ static int run(String args[], PigProgres
             //by default we keep going on error on the backend
             properties.setProperty("stop.on.failure", ""+false);
         }
-        
+
         // set up client side system properties in UDF context
         UDFContext.getUDFContext().setClientSystemProps(properties);
 
@@ -202,8 +239,8 @@ static int run(String args[], PigProgres
                 properties.setProperty(BRIEF, "true");
                 break;
 
-            case 'c': 
-                checkScriptOnly = true;                
+            case 'c':
+                checkScriptOnly = true;
                 break;
 
             case 'd':
@@ -213,8 +250,8 @@ static int run(String args[], PigProgres
                 }
                 debug = true;
                 break;
-                
-            case 'e': 
+
+            case 'e':
                 mode = ExecMode.STRING;
                 break;
 
@@ -227,7 +264,7 @@ static int run(String args[], PigProgres
                 embedded = true;
                 engine = opts.getValStr();
                 break;
-                
+
             case 'F':
                 properties.setProperty("stop.on.failure", ""+true);
                 break;
@@ -250,8 +287,8 @@ static int run(String args[], PigProgres
                 return ReturnCode.SUCCESS;
 
             case 'l':
-                //call to method that validates the path to the log file 
-                //and sets up the file to store the client side log file                
+                //call to method that validates the path to the log file
+                //and sets up the file to store the client side log file
                 String logFileParameter = opts.getValStr();
                 if (logFileParameter != null && logFileParameter.length() > 0) {
                     logFileName = validateLogFile(logFileParameter, null);
@@ -270,12 +307,12 @@ static int run(String args[], PigProgres
                 // turns off multiquery optimization
                 properties.setProperty("opt.multiquery",""+false);
                 break;
-                            
-            case 'p': 
+
+            case 'p':
                 params.add(opts.getValStr());
                 break;
-                            
-            case 'r': 
+
+            case 'r':
                 // currently only used for parameter substitution
                 // will be extended in the future
                 dryrun = true;
@@ -284,7 +321,7 @@ static int run(String args[], PigProgres
             case 't':
             	optimizerRules.add(opts.getValStr());
                 break;
-                            
+
             case 'v':
                 properties.setProperty(VERBOSE, ""+true);
                 verbose = true;
@@ -301,7 +338,7 @@ static int run(String args[], PigProgres
                         throw new RuntimeException("ERROR: Unrecognized exectype.", e);
                     }
                 break;
-                
+
             case 'P':
             {
                 InputStream inputStream = null;
@@ -316,12 +353,12 @@ static int run(String args[], PigProgres
                         try {
                             inputStream.close();
                         } catch (IOException e) {
-                        } 
+                        }
                     }
                 }
             }
             break;
-            
+
             default: {
                 Character cc = Character.valueOf(opt);
                 throw new AssertionError("Unhandled option " + cc.toString());
@@ -330,37 +367,37 @@ static int run(String args[], PigProgres
         }
         // create the context with the parameter
         PigContext pigContext = new PigContext(execType, properties);
-        
+
         // create the static script state object
         String commandLine = LoadFunc.join((AbstractList<String>)Arrays.asList(args), " ");
         ScriptState scriptState = ScriptState.start(commandLine, pigContext);
         if (listener != null) {
             scriptState.registerListener(listener);
         }
-        
+
 
         if(logFileName == null && !userSpecifiedLog) {
             logFileName = validateLogFile(properties.getProperty("pig.logfile"), null);
         }
-        
+
         pigContext.getProperties().setProperty("pig.logfile", (logFileName == null? "": logFileName));
-     
+
         // configure logging
         configureLog4J(properties, pigContext);
-        
+
         if(logFileName != null) {
             log.info("Logging error messages to: " + logFileName);
         }
-        
+
         if( ! Boolean.valueOf(properties.getProperty(PROP_FILT_SIMPL_OPT, "false"))){
-            //turn off if the user has not explicitly turned on this optimization 
+            //turn off if the user has not explicitly turned on this optimization
             optimizerRules.add("FilterLogicExpressionSimplifier");
         }
-        
+
         if(optimizerRules.size() > 0) {
             pigContext.getProperties().setProperty("pig.optimizer.rules", ObjectSerializer.serialize(optimizerRules));
         }
-        
+
         if (properties.get("udf.import.list")!=null)
             PigContext.initializeImportList((String)properties.get("udf.import.list"));
 
@@ -370,21 +407,21 @@ static int run(String args[], PigProgres
         Grunt grunt = null;
         BufferedReader in;
         String substFile = null;
-        
+
         paramFiles = fetchRemoteParamFiles(paramFiles, properties);
         pigContext.setParams(params);
         pigContext.setParamFiles(paramFiles);
-        
+
         switch (mode) {
-        
+
         case FILE: {
             FileLocalizer.FetchFileRet localFileRet = FileLocalizer.fetchFile(properties, file);
             if (localFileRet.didFetch) {
                 properties.setProperty("pig.jars.relative.to.dfs", "true");
-            }            
-            
+            }
+
             scriptState.setFileName(file);
-            
+
             if (embedded) {
                 return runEmbeddedScript(pigContext, localFileRet.file.getPath(), engine);
             } else {
@@ -394,12 +431,12 @@ static int run(String args[], PigProgres
                                 .getPath(), type.name().toLowerCase());
                 }
             }
-                        
+
             in = new BufferedReader(new FileReader(localFileRet.file));
-            
+
             // run parameter substitution preprocessor first
             substFile = file + ".substituted";
-            
+
                 pin = runParamPreprocessor(pigContext, in,
                         substFile, debug || dryrun || checkScriptOnly);
             if (dryrun) {
@@ -414,25 +451,25 @@ static int run(String args[], PigProgres
                 }
                 return ReturnCode.SUCCESS;
             }
-            
+
 
             logFileName = validateLogFile(logFileName, file);
             pigContext.getProperties().setProperty("pig.logfile", logFileName);
 
             // Set job name based on name of the script
-            pigContext.getProperties().setProperty(PigContext.JOB_NAME, 
+            pigContext.getProperties().setProperty(PigContext.JOB_NAME,
                                                    "PigLatin:" +new File(file).getName()
             );
-            
+
             if (!debug) {
                 new File(substFile).deleteOnExit();
             }
-            
+
             scriptState.setScript(new File(file));
-            
+
             grunt = new Grunt(pin, pigContext);
             gruntCalled = true;
-            
+
             if(checkScriptOnly) {
                 grunt.checkScript(substFile);
                 System.err.println(file + " syntax OK");
@@ -441,7 +478,7 @@ static int run(String args[], PigProgres
                 int results[] = grunt.exec();
                 rc = getReturnCodeForStats(results);
             }
-            
+
             return rc;
         }
 
@@ -460,11 +497,11 @@ static int run(String args[], PigProgres
                 if (i != 0) sb.append(' ');
                 sb.append(remainders[i]);
             }
-            
+
             scriptState.setScript(sb.toString());
-            
+
             in = new BufferedReader(new StringReader(sb.toString()));
-            
+
             grunt = new Grunt(in, pigContext);
             gruntCalled = true;
             int results[] = grunt.exec();
@@ -506,14 +543,14 @@ static int run(String args[], PigProgres
                    throw new RuntimeException("Encountered unexpected arguments on command line - please check the command line.");
             }
             mode = ExecMode.FILE;
-            
+
             FileLocalizer.FetchFileRet localFileRet = FileLocalizer.fetchFile(properties, remainders[0]);
             if (localFileRet.didFetch) {
                 properties.setProperty("pig.jars.relative.to.dfs", "true");
-            }            
+            }
 
             scriptState.setFileName(remainders[0]);
-            
+
             if (embedded) {
                 return runEmbeddedScript(pigContext, localFileRet.file.getPath(), engine);
             } else {
@@ -523,9 +560,9 @@ static int run(String args[], PigProgres
                                 .getPath(), type.name().toLowerCase());
                 }
             }
-            
+
             in = new BufferedReader(new FileReader(localFileRet.file));
-            
+
             // run parameter substitution preprocessor first
             substFile = remainders[0] + ".substituted";
             pin = runParamPreprocessor(pigContext, in, substFile, debug || dryrun || checkScriptOnly);
@@ -541,7 +578,7 @@ static int run(String args[], PigProgres
                 }
                 return ReturnCode.SUCCESS;
             }
-            
+
             logFileName = validateLogFile(logFileName, remainders[0]);
             pigContext.getProperties().setProperty("pig.logfile", logFileName);
 
@@ -550,15 +587,15 @@ static int run(String args[], PigProgres
             }
 
             // Set job name based on name of the script
-            pigContext.getProperties().setProperty(PigContext.JOB_NAME, 
+            pigContext.getProperties().setProperty(PigContext.JOB_NAME,
                                                    "PigLatin:" +new File(remainders[0]).getName()
             );
 
             scriptState.setScript(localFileRet.file);
-            
+
             grunt = new Grunt(pin, pigContext);
             gruntCalled = true;
-            
+
             if(checkScriptOnly) {
                 grunt.checkScript(substFile);
                 System.err.println(remainders[0] + " syntax OK");
@@ -582,7 +619,7 @@ static int run(String args[], PigProgres
     } catch (IOException e) {
         if (e instanceof PigException) {
             PigException pe = (PigException)e;
-            rc = (pe.retriable()) ? ReturnCode.RETRIABLE_EXCEPTION 
+            rc = (pe.retriable()) ? ReturnCode.RETRIABLE_EXCEPTION
                     : ReturnCode.PIG_EXCEPTION;
             PigStatsUtil.setErrorMessage(pe.getMessage());
             PigStatsUtil.setErrorCode(pe.getErrorCode());
@@ -590,7 +627,7 @@ static int run(String args[], PigProgres
             rc = ReturnCode.IO_EXCEPTION;
             PigStatsUtil.setErrorMessage(e.getMessage());
         }
-        
+
         if(!gruntCalled) {
         	LogUtils.writeLog(e, logFileName, log, verbose, "Error before Pig is launched");
         }
@@ -599,13 +636,13 @@ static int run(String args[], PigProgres
         PigStatsUtil.setErrorMessage(e.getMessage());
         if(!gruntCalled) {
         	LogUtils.writeLog(e, logFileName, log, verbose, "Error before Pig is launched");
-        }      
+        }
     } finally {
         // clear temp files
         FileLocalizer.deleteTempFiles();
-        PerformanceTimerFactory.getPerfTimerFactory().dumpTimers();        
+        PerformanceTimerFactory.getPerfTimerFactory().dumpTimers();
     }
-    
+
     return rc;
 }
 
@@ -639,7 +676,7 @@ private static void configureLog4J(Prope
     // TODO Add a file appender for the logs
     // TODO Need to create a property in the properties file for it.
     // sgroschupf, 25Feb2008: this method will be obsolete with PIG-115.
-     
+
     String log4jconf = properties.getProperty(LOG4J_CONF);
     String trueString = "true";
     boolean brief = trueString.equalsIgnoreCase(properties.getProperty(BRIEF));
@@ -649,7 +686,7 @@ private static void configureLog4J(Prope
     if (logLevelString != null){
         logLevel = Level.toLevel(logLevelString, Level.INFO);
     }
-    
+
     Properties props = new Properties();
     FileReader propertyReader = null;
     if (log4jconf != null) {
@@ -680,9 +717,9 @@ private static void configureLog4J(Prope
             props.setProperty("log4j.appender.F.layout","org.apache.log4j.PatternLayout");
             props.setProperty("log4j.appender.F.layout.ConversionPattern", brief ? "%m%n" : "%d [%t] %-5p %c - %m%n");
         }
-        
-        props.setProperty("log4j.appender.PIGCONSOLE","org.apache.log4j.ConsoleAppender");    
-        props.setProperty("log4j.appender.PIGCONSOLE.target", "System.err");        
+
+        props.setProperty("log4j.appender.PIGCONSOLE","org.apache.log4j.ConsoleAppender");
+        props.setProperty("log4j.appender.PIGCONSOLE.target", "System.err");
         props.setProperty("log4j.appender.PIGCONSOLE.layout","org.apache.log4j.PatternLayout");
         props.setProperty("log4j.appender.PIGCONSOLE.layout.ConversionPattern", brief ? "%m%n" : "%d [%t] %-5p %c - %m%n");
     }
@@ -709,45 +746,72 @@ private static List<String> fetchRemoteP
     return paramFiles2;
 }
 // returns the stream of final pig script to be passed to Grunt
-private static BufferedReader runParamPreprocessor(PigContext context, BufferedReader origPigScript, 
-                                            String scriptFile, boolean createFile) 
+private static BufferedReader runParamPreprocessor(PigContext context, BufferedReader origPigScript,
+                                            String scriptFile, boolean createFile)
                                 throws org.apache.pig.tools.parameters.ParseException, IOException{
-    
+
     ParameterSubstitutionPreprocessor psp = new ParameterSubstitutionPreprocessor(50);
     String[] type1 = new String[1];
     String[] type2 = new String[1];
 
     if (createFile){
         BufferedWriter fw = new BufferedWriter(new FileWriter(scriptFile));
-        psp.genSubstitutedFile (origPigScript, fw, context.getParams().size() > 0 ? context.getParams().toArray(type1) : null, 
+        psp.genSubstitutedFile (origPigScript, fw, context.getParams().size() > 0 ? context.getParams().toArray(type1) : null,
                                 context.getParamFiles().size() > 0 ? context.getParamFiles().toArray(type2) : null);
         return new BufferedReader(new FileReader (scriptFile));
 
     } else {
         StringWriter writer = new StringWriter();
-        psp.genSubstitutedFile (origPigScript, writer,  context.getParams().size() > 0 ? context.getParams().toArray(type1) : null, 
+        psp.genSubstitutedFile (origPigScript, writer,  context.getParams().size() > 0 ? context.getParams().toArray(type1) : null,
                                 context.getParamFiles().size() > 0 ? context.getParamFiles().toArray(type2) : null);
         return new BufferedReader(new StringReader(writer.toString()));
     }
 }
-    
-private static String getVersionString() {
-	String findContainingJar = JarManager.findContainingJar(Main.class);
-	  try { 
-          JarFile jar = new JarFile(findContainingJar); 
-          final Manifest manifest = jar.getManifest(); 
-          final Map <String,Attributes> attrs = manifest.getEntries(); 
-          Attributes attr = attrs.get("org/apache/pig");
-          String version = attr.getValue("Implementation-Version");
-          String svnRevision = attr.getValue("Svn-Revision");
-          String buildTime = attr.getValue("Build-TimeStamp");
-          // we use a version string similar to svn 
-          //svn, version 1.4.4 (r25188)
-          // compiled Sep 23 2007, 22:32:34
-          return "Apache Pig version " + version + " (r" + svnRevision + ") \ncompiled "+buildTime;
-      } catch (Exception e) { 
-          throw new RuntimeException("unable to read pigs manifest file", e); 
-      } 
+
+/**
+ * Returns the major version of Pig being run.
+ */
+public static String getMajorVersion() {
+    return majorVersion;
+}
+
+/**
+ * Returns the major version of the Pig build being run.
+ */
+public static String getMinorVersion() {
+    return minorVersion;
+}
+
+/**
+ * Returns the patch version of the Pig build being run.
+ */
+public static String getPatchVersion() {
+    return patchVersion;
+}
+
+/**
+ * Returns the svn revision number of the Pig build being run.
+ */
+public static String getSvnRevision() {
+    return svnRevision;
+}
+
+/**
+ * Returns the built time of the Pig build being run.
+ */
+public static String getBuildTime() {
+    return buildTime;
+}
+
+/**
+ * Returns a version string formatted similarly to that of svn.
+ * <pre>
+ * Apache Pig version 0.11.0-SNAPSHOT (r1202387)
+ * compiled Nov 15 2011, 15:22:09
+ * </pre>
+ */
+public static String getVersionString() {
+    return "Apache Pig version " + version + " (r" + svnRevision + ") \ncompiled "+buildTime;
 }
 
 /**
@@ -797,14 +861,14 @@ public static void usage()
 public static void printProperties(){
 	System.out.println("The following properties are supported:");
 	System.out.println("    Logging:");
-        System.out.println("        verbose=true|false; default is false. This property is the same as -v switch");    
+        System.out.println("        verbose=true|false; default is false. This property is the same as -v switch");
         System.out.println("        brief=true|false; default is false. This property is the same as -b switch");
         System.out.println("        debug=OFF|ERROR|WARN|INFO|DEBUG; default is INFO. This property is the same as -d switch");
         System.out.println("        aggregate.warning=true|false; default is true. If true, prints count of warnings");
         System.out.println("            of each type rather than logging each warning.");
         System.out.println("    Performance tuning:");
         System.out.println("        pig.cachedbag.memusage=<mem fraction>; default is 0.2 (20% of all memory).");
-	System.out.println("            Note that this memory is shared across all large bags used by the application.");     	
+	System.out.println("            Note that this memory is shared across all large bags used by the application.");
         System.out.println("        pig.skewedjoin.reduce.memusagea=<mem fraction>; default is 0.3 (30% of all memory).");
         System.out.println("            Specifies the fraction of heap available for the reducer to perform the join.");
         System.out.println("        pig.exec.nocombiner=true|false; default is false. ");
@@ -814,7 +878,7 @@ public static void printProperties(){
         System.out.println("        pig.tmpfilecompression=true|false; compression is off by default.");
         System.out.println("            Determines whether output of intermediate jobs is compressed.");
         System.out.println("        pig.tmpfilecompression.codec=lzo|gzip; default is gzip.");
-        System.out.println("            Used in conjunction with pig.tmpfilecompression. Defines compression type."); 
+        System.out.println("            Used in conjunction with pig.tmpfilecompression. Defines compression type.");
         System.out.println("        pig.noSplitCombination=true|false. Split combination is on by default.");
         System.out.println("            Determines if multiple small files are combined into a single map.");
         System.out.println("        pig.exec.mapPartAgg=true|false. Default is false.");
@@ -822,7 +886,7 @@ public static void printProperties(){
         System.out.println("            before records are sent to combiner.");
         System.out.println("        pig.exec.mapPartAgg.minReduction=<min aggregation factor>. Default is 10.");
         System.out.println("            If the in-map partial aggregation does not reduce the output num records");
-        System.out.println("            by this factor, it gets disabled.");        
+        System.out.println("            by this factor, it gets disabled.");
         System.out.println("        " + PROP_FILT_SIMPL_OPT + "=true|false; Default is false.");
         System.out.println("            Enable optimizer rules to simplify filter expressions.");
         System.out.println("    Miscellaneous:");
@@ -835,7 +899,7 @@ public static void printProperties(){
 
 private static String validateLogFile(String logFileName, String scriptName) {
     String strippedDownScriptName = null;
-    
+
     if(scriptName != null) {
         File scriptFile = new File(scriptName);
         if(!scriptFile.isDirectory()) {
@@ -845,20 +909,20 @@ private static String validateLogFile(St
             } catch (IOException ioe) {
                 log.warn("Could not compute canonical path to the script file " + ioe.getMessage());
                 return null;
-            }            
+            }
             strippedDownScriptName = getFileFromCanonicalPath(scriptFileAbsPath);
         }
     }
-    
+
     String defaultLogFileName = (strippedDownScriptName == null ? "pig_" : strippedDownScriptName) + new Date().getTime() + ".log";
-    File logFile;    
-    
+    File logFile;
+
     if(logFileName != null) {
         logFile = new File(logFileName);
-    
-        //Check if the file name is a directory 
+
+        //Check if the file name is a directory
         //append the default file name to the file
-        if(logFile.isDirectory()) {            
+        if(logFile.isDirectory()) {
             if(logFile.canWrite()) {
                 try {
                     logFileName = logFile.getCanonicalPath() + File.separator + defaultLogFileName;
@@ -874,7 +938,7 @@ private static String validateLogFile(St
         } else {
             //we have a relative path or an absolute path to the log file
             //check if we can write to the directory where this file is/will be stored
-            
+
             if (logFile.exists()) {
                 if(logFile.canWrite()) {
                     try {
@@ -892,7 +956,7 @@ private static String validateLogFile(St
                 }
             } else {
                 logFile = logFile.getParentFile();
-                
+
                 if(logFile != null) {
                     //if the directory is writable we are good to go
                     if(logFile.canWrite()) {
@@ -907,19 +971,19 @@ private static String validateLogFile(St
                         log.warn("Need write permission in the directory: " + logFile + " to create log file.");
                         return logFileName;
                     }
-                }//end if logFile != null else is the default in fall through                
+                }//end if logFile != null else is the default in fall through
             }//end else part of logFile.exists()
         }//end else part of logFile.isDirectory()
     }//end if logFileName != null
-    
-    //file name is null or its in the current working directory 
+
+    //file name is null or its in the current working directory
     //revert to the current working directory
     String currDir = System.getProperty("user.dir");
     logFile = new File(currDir);
     logFileName = currDir + File.separator + (logFileName == null? defaultLogFileName : logFileName);
-    if(logFile.canWrite()) {        
+    if(logFile.canWrite()) {
         return logFileName;
-    }    
+    }
     log.warn("Cannot write to log file: " + logFileName);
     return null;
 }
@@ -940,12 +1004,12 @@ private static int runEmbeddedScript(Pig
     ScriptEngine scriptEngine = ScriptEngine.getInstance(engine);
     Map<String, List<PigStats>> statsMap = scriptEngine.run(pigContext, file);
     PigStatsUtil.setStatsMap(statsMap);
-    
+
     int failCount = 0;
     int totalCount = 0;
     for (List<PigStats> lst : statsMap.values()) {
         if (lst != null && !lst.isEmpty()) {
-            for (PigStats stats : lst) {                
+            for (PigStats stats : lst) {
                 if (!stats.isSuccessful()) failCount++;
                 totalCount++;
             }