Author: sms
Date: Mon Mar  9 22:17:31 2009
New Revision: 751875

URL: http://svn.apache.org/viewvc?rev=751875&view=rev
Log:
PIG-705: Pig should display a better error message when backend error messages 
cannot be parsed

Modified:
    hadoop/pig/trunk/CHANGES.txt
    
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/Launcher.java
    
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java

Modified: hadoop/pig/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=751875&r1=751874&r2=751875&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Mon Mar  9 22:17:31 2009
@@ -454,3 +454,6 @@
     is malformed(thejas via sms)
 
     PIG-532: Casting a field removes its alias.(thejas via sms)
+
+    PIG-705: Pig should display a better error message when backend error
+    messages cannot be parsed (sms)

Modified: 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/Launcher.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/Launcher.java?rev=751875&r1=751874&r2=751875&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/Launcher.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/Launcher.java
 Mon Mar  9 22:17:31 2009
@@ -120,9 +120,20 @@
     
     protected void getStats(Job job, JobClient jobClient, boolean errNotDbg, 
PigContext pigContext) throws Exception {
         JobID MRJobID = job.getAssignedJobID();
-
+        String jobMessage = job.getMessage();
         if(MRJobID == null) {
-               throw getExceptionFromString(job.getMessage()); 
+               try {
+                throw getExceptionFromString(jobMessage);
+            } catch (Exception e) {
+                //just get the first line in the message and log the rest
+                String firstLine = getFirstLineFromMessage(jobMessage);
+
+                LogUtils.writeLog(new Exception(jobMessage), 
pigContext.getProperties().getProperty("pig.logfile"), 
+                        log, false, null, false, false);
+                int errCode = 2997;
+                String msg = "Unable to recreate exception from backend error: 
" + firstLine;
+                throw new ExecException(msg, errCode, PigException.BUG, e);
+            } 
         }
         try {
             TaskReport[] mapRep = jobClient.getMapTaskReports(MRJobID);
@@ -137,7 +148,7 @@
                 // we were unable to get statistics
                 log.warn("Unable to get job related diagnostics");
             } else {
-               throw e;
+                throw e;
             }
         }
     }
@@ -172,8 +183,17 @@
                                if (errNotDbg) {
                                        //errNotDbg is used only for failed jobs
                                    //keep track of all the unique exceptions
-                                       Exception e = 
getExceptionFromString(msgs[j]);
-                                       exceptions.add(e);
+                            try {
+                                Exception e = getExceptionFromString(msgs[j]);
+                                exceptions.add(e);
+                            } catch (Exception e1) {
+                                String firstLine = 
getFirstLineFromMessage(msgs[j]);                                
+                                LogUtils.writeLog(new Exception(msgs[j]), 
pigContext.getProperties().getProperty("pig.logfile"), 
+                                        log, false, null, false, false);
+                                int errCode = 2997;
+                                String msg = "Unable to recreate exception 
from backed error: " + firstLine;
+                                throw new ExecException(msg, errCode, 
PigException.BUG, e1);
+                            }
                                } else {
                                    log.debug("Error message from task (" + 
type + ") " +
                                        reports[i].getTaskID() + msgs[j]);
@@ -526,6 +546,15 @@
             lineNumber = Integer.parseInt(items[1]);
         }
         return new StackTraceElement(declaringClass, methodName, fileName, 
lineNumber);
-    }  
+    }
+    
+    private String getFirstLineFromMessage(String message) {
+        String[] messages = message.split(newLine);
+        if(messages.length > 0) {
+            return messages[0];
+        } else {
+            return new String(message);
+        }        
+    }
 
 }

Modified: 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
URL: 
http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java?rev=751875&r1=751874&r2=751875&view=diff
==============================================================================
--- 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
 (original)
+++ 
hadoop/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/MapReduceLauncher.java
 Mon Mar  9 22:17:31 2009
@@ -241,12 +241,14 @@
        RunningJob runningJob = null;
        try {
                runningJob = jobClient.getJob(mapRedJobID);
+               if(runningJob != null) {
                Counters counters = runningJob.getCounters();
-               for(Enum e : PigWarning.values()) {
-                       Long currentCount = aggMap.get(e);
-                       currentCount = (currentCount == null? 0 : currentCount);
-                       currentCount += counters.getCounter(e);
-                       aggMap.put(e, currentCount);
+                       for(Enum e : PigWarning.values()) {
+                               Long currentCount = aggMap.get(e);
+                               currentCount = (currentCount == null? 0 : 
currentCount);
+                               currentCount += counters.getCounter(e);
+                               aggMap.put(e, currentCount);
+                       }
                }
        } catch (IOException ioe) {
                String msg = "Unable to retrieve job to compute warning 
aggregation.";


Reply via email to