Author: rkanter
Date: Mon Feb  4 17:57:05 2013
New Revision: 1442210

URL: http://svn.apache.org/viewvc?rev=1442210&view=rev
Log:
OOZIE-739 a coord action fails because the uri points to a namenode that is not 
in whitelist. the E0901 error shows in the oozie.log, but not written to the 
database (mona,mbattisha via virag)

Modified:
    
oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
    
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
    oozie/branches/branch-3.3/release-log.txt

Modified: 
oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java?rev=1442210&r1=1442209&r2=1442210&view=diff
==============================================================================
--- 
oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
 (original)
+++ 
oozie/branches/branch-3.3/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
 Mon Feb  4 17:57:05 2013
@@ -152,14 +152,22 @@ public class CoordActionInputCheckXComma
                     queue(new 
CoordActionInputCheckXCommand(coordAction.getId(), coordAction.getJobId()), 
getCoordInputCheckRequeueInterval());
                 }
             }
-            coordAction.setLastModifiedTime(new Date());
-            jpaService.execute(new 
org.apache.oozie.executor.jpa.CoordActionUpdateForInputCheckJPAExecutor(coordAction));
         }
         catch (Exception e) {
             throw new CommandException(ErrorCode.E1021, e.getMessage(), e);
         }
-        cron.stop();
-
+        finally {
+            coordAction.setLastModifiedTime(new Date());
+            cron.stop();
+            if(jpaService != null) {
+                try {
+                    jpaService.execute(new 
org.apache.oozie.executor.jpa.CoordActionUpdateForInputCheckJPAExecutor(coordAction));
+                }
+                catch(JPAExecutorException jex) {
+                    throw new CommandException(ErrorCode.E1021, 
jex.getMessage(), jex);
+                }
+            }
+        }
         return null;
     }
 
@@ -412,7 +420,7 @@ public class CoordActionInputCheckXComma
      * @return true if path exists
      * @throws IOException thrown if unable to access the path
      */
-    private boolean pathExists(String sPath, Configuration actionConf) throws 
IOException {
+    protected boolean pathExists(String sPath, Configuration actionConf) 
throws IOException {
         LOG.debug("checking for the file " + sPath);
         Path path = new Path(sPath);
         String user = 
ParamChecker.notEmpty(actionConf.get(OozieClient.USER_NAME), 
OozieClient.USER_NAME);
@@ -422,6 +430,8 @@ public class CoordActionInputCheckXComma
             return has.createFileSystem(user, path.toUri(), 
fsConf).exists(path);
         }
         catch (HadoopAccessorException e) {
+            coordAction.setErrorCode(e.getErrorCode().toString());
+            coordAction.setErrorMessage(e.getMessage());
             throw new IOException(e);
         }
     }
@@ -462,6 +472,26 @@ public class CoordActionInputCheckXComma
         return uris.toString();
     }
 
+    /**
+     * getting the error code of the coord action. (used mainly for unit 
testing)
+     */
+    protected String getCoordActionErrorCode() {
+        if (coordAction != null) {
+            return coordAction.getErrorCode();
+        }
+        return null;
+    }
+
+    /**
+     * getting the error message of the coord action. (used mainly for unit 
testing)
+     */
+    protected String getCoordActionErrorMsg() {
+        if (coordAction != null) {
+            return coordAction.getErrorMessage();
+        }
+        return null;
+    }
+
     /* (non-Javadoc)
      * @see org.apache.oozie.command.XCommand#getEntityKey()
      */

Modified: 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java?rev=1442210&r1=1442209&r2=1442210&view=diff
==============================================================================
--- 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
 (original)
+++ 
oozie/branches/branch-3.3/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
 Mon Feb  4 17:57:05 2013
@@ -22,6 +22,8 @@ import java.io.Reader;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+
+import org.apache.hadoop.fs.Path;
 import org.apache.oozie.CoordinatorActionBean;
 import org.apache.oozie.CoordinatorJobBean;
 import org.apache.oozie.client.CoordinatorAction;
@@ -35,6 +37,7 @@ import org.apache.oozie.executor.jpa.Coo
 import org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor;
 import org.apache.oozie.executor.jpa.JPAExecutorException;
 import org.apache.oozie.service.CallableQueueService;
+import org.apache.oozie.service.HadoopAccessorService;
 import org.apache.oozie.service.JPAService;
 import org.apache.oozie.service.Services;
 import org.apache.oozie.service.XLogService;
@@ -195,6 +198,44 @@ public class TestCoordActionInputCheckXC
     }
 
     /**
+     * Testing a non existing namenode path
+     *
+     * @throws Exception
+     */
+    public void testNonExistingNameNode() throws Exception {
+        String jobId = "0000000-" + new Date().getTime() + 
"-TestCoordActionInputCheckXCommand-C";
+        Date startTime = DateUtils.parseDateUTC("2009-02-01T23:59Z");
+        Date endTime = DateUtils.parseDateUTC("2009-02-02T23:59Z");
+        CoordinatorJobBean job = addRecordToCoordJobTable(jobId, startTime, 
endTime);
+        new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
+        CoordActionInputCheckXCommand caicc = new 
CoordActionInputCheckXCommand(job.getId() + "@1", job.getId());
+        caicc.loadState();
+
+        // Override the name node while list for testing purpose only.
+        String[] whiteList = new String[1];
+        whiteList[0] = "localhost:5330";
+        setSystemProperty(HadoopAccessorService.NAME_NODE_WHITELIST, 
whiteList[0]);
+        new Services().init();
+
+        // setting the configuration
+        XConfiguration jobConf = new XConfiguration();
+        jobConf.set(OozieClient.USER_NAME, getTestUser());
+
+        // setting the test path with nonExistDir
+        Path appPath = new Path(getFsTestCaseDir(), "coord");
+        String inputDir = appPath.toString() + "/coord-input/2010/07/09/01/00";
+        String nonExistDir = inputDir.replaceFirst("localhost", "nonExist");
+        try {
+            caicc.pathExists(nonExistDir, jobConf);
+            fail("Should throw exception due to non-existent NN path. 
Therefore fail");
+        }
+        catch (IOException ioe) {
+            assertEquals(caicc.getCoordActionErrorCode(), "E0901");
+            assertTrue(caicc.getCoordActionErrorMsg().contains("not in Oozies 
whitelist"));
+        }
+    }
+
+    /**
      * This test case verifies if getCoordInputCheckRequeueInterval picks up 
the
      * overridden value. In reality, the value could be overridden in
      * oozie-site.xml.

Modified: oozie/branches/branch-3.3/release-log.txt
URL: 
http://svn.apache.org/viewvc/oozie/branches/branch-3.3/release-log.txt?rev=1442210&r1=1442209&r2=1442210&view=diff
==============================================================================
--- oozie/branches/branch-3.3/release-log.txt (original)
+++ oozie/branches/branch-3.3/release-log.txt Mon Feb  4 17:57:05 2013
@@ -1,5 +1,6 @@
 -- Oozie 3.3.2 (unreleased)
 
+OOZIE-739 a coord action fails because the uri points to a namenode that is 
not in whitelist. the E0901 error shows in the oozie.log, but not written to 
the database (mona,mbattisha via virag)
 OOZIE-987 Fix minor bug in one of the uber jar tests (rkanter via tucu)
 OOZIE-988 Improve verification of TestJavaActionExecutor.testLibFileArchives 
(rkanter via tucu)
 OOZIE-973 Allow Oozie to run against Hadoop trunk branch (rkanter via tucu)


Reply via email to