Repository: oozie
Updated Branches:
  refs/heads/master 5afd961d9 -> 6e9486bf6


OOZIE-1621 Add proper error code and error message for sharelib exceptions. 
(rkanter)


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

Branch: refs/heads/master
Commit: ebe1afa2f38705546307692b1d5bfaeec2c67039
Parents: 5afd961
Author: Robert Kanter <[email protected]>
Authored: Wed Apr 23 14:59:59 2014 -0700
Committer: Robert Kanter <[email protected]>
Committed: Wed Apr 23 14:59:59 2014 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/oozie/ErrorCode.java   |  1 +
 .../oozie/action/hadoop/JavaActionExecutor.java |  4 ++++
 .../apache/oozie/service/ShareLibService.java   | 21 ++++++++++++++------
 core/src/main/resources/oozie-default.xml       |  4 ++--
 .../action/hadoop/TestJavaActionExecutor.java   | 21 ++++++++++++++------
 release-log.txt                                 |  1 +
 6 files changed, 38 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/ebe1afa2/core/src/main/java/org/apache/oozie/ErrorCode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/ErrorCode.java 
b/core/src/main/java/org/apache/oozie/ErrorCode.java
index ee7292b..8b573ce 100644
--- a/core/src/main/java/org/apache/oozie/ErrorCode.java
+++ b/core/src/main/java/org/apache/oozie/ErrorCode.java
@@ -42,6 +42,7 @@ public enum ErrorCode {
     E0101(XLog.OPS, "Service [{0}] does not implement declared interface 
[{1}]"),
     E0102(XLog.OPS, "Could not instantiate service class [{0}], {1}"),
     E0103(XLog.OPS, "Could not load service classes, {0}"),
+    E0104(XLog.OPS, "Could not fully initialize service [{0}], {1}"),
     E0110(XLog.OPS, "Could not parse or validate EL definition [{0}], {1}"),
     E0111(XLog.OPS, "class#method not found [{0}#{1}]"),
     E0112(XLog.OPS, "class#method does not have PUBLIC or STATIC modifier 
[{0}#{1}]"),

http://git-wip-us.apache.org/repos/asf/oozie/blob/ebe1afa2/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java 
b/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
index 44bb7d2..6fcdf2a 100644
--- a/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
+++ b/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
@@ -554,6 +554,10 @@ public class JavaActionExecutor extends ActionExecutor {
         if (shareLibService != null) {
             try {
                 List<Path> listOfPaths = 
shareLibService.getSystemLibJars(JavaActionExecutor.OOZIE_COMMON_LIBDIR);
+                if (listOfPaths == null || listOfPaths.isEmpty()) {
+                    throw new 
ActionExecutorException(ActionExecutorException.ErrorType.FAILED, "EJ001",
+                            "Could not locate Oozie sharelib");
+                }
                 FileSystem fs = listOfPaths.get(0).getFileSystem(conf);
                 for (Path actionLibPath : listOfPaths) {
                     DistributedCache.addFileToClassPath(actionLibPath, conf, 
fs);

http://git-wip-us.apache.org/repos/asf/oozie/blob/ebe1afa2/core/src/main/java/org/apache/oozie/service/ShareLibService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/service/ShareLibService.java 
b/core/src/main/java/org/apache/oozie/service/ShareLibService.java
index 73ca492..353b382 100644
--- a/core/src/main/java/org/apache/oozie/service/ShareLibService.java
+++ b/core/src/main/java/org/apache/oozie/service/ShareLibService.java
@@ -53,6 +53,7 @@ import org.apache.oozie.util.Instrumentation;
 import org.apache.oozie.util.XLog;
 
 import com.google.common.annotations.VisibleForTesting;
+import org.apache.oozie.ErrorCode;
 
 public class ShareLibService implements Service, Instrumentable {
 
@@ -97,15 +98,23 @@ public class ShareLibService implements Service, 
Instrumentable {
     @Override
     public void init(Services services) throws ServiceException {
         this.services = services;
+        sharelibMappingFile = services.getConf().get(SHARELIB_MAPPING_FILE, 
"");
+        isShipLauncherEnabled = 
services.getConf().getBoolean(SHIP_LAUNCHER_JAR, false);
+        Path launcherlibPath = getLauncherlibPath();
+        HadoopAccessorService has = 
Services.get().get(HadoopAccessorService.class);
+        URI uri = launcherlibPath.toUri();
         try {
-            sharelibMappingFile = 
services.getConf().get(SHARELIB_MAPPING_FILE, "");
-            isShipLauncherEnabled = 
services.getConf().getBoolean(SHIP_LAUNCHER_JAR, false);
-            Path launcherlibPath = getLauncherlibPath();
-            HadoopAccessorService has = 
Services.get().get(HadoopAccessorService.class);
-            URI uri = launcherlibPath.toUri();
             fs = FileSystem.get(has.createJobConf(uri.getAuthority()));
             updateLauncherLib();
             updateShareLib();
+        } catch(IOException ioe) {
+            // We don't want to actually fail init by throwing an Exception, 
so only create the ServiceException and log it
+            ServiceException se = new ServiceException(ErrorCode.E0104, 
getClass().getName(),
+                    "Not able to cache sharelib.  An Admin needs to install 
the sharelib with oozie-setup.sh and issue the "
+                            + "'oozie admin' CLI command to update the 
sharelib", ioe);
+            LOG.error(se);
+        }
+        try {
             //Only one server should purge sharelib
             if 
(Services.get().get(JobsConcurrencyService.class).isFirstServer()) {
                 final Date current = 
Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime();
@@ -114,7 +123,7 @@ public class ShareLibService implements Service, 
Instrumentable {
             }
         }
         catch (Exception e) {
-            LOG.error("Not able to cache shareLib. Admin need to issue oozlie 
cli command to update sharelib.", e);
+            LOG.error("There was an issue purging the sharelib", e);
         }
 
     }

http://git-wip-us.apache.org/repos/asf/oozie/blob/ebe1afa2/core/src/main/resources/oozie-default.xml
----------------------------------------------------------------------
diff --git a/core/src/main/resources/oozie-default.xml 
b/core/src/main/resources/oozie-default.xml
index 47fa0e4..70620f6 100644
--- a/core/src/main/resources/oozie-default.xml
+++ b/core/src/main/resources/oozie-default.xml
@@ -104,6 +104,7 @@
             org.apache.oozie.service.AuthorizationService,
             org.apache.oozie.service.UserGroupInformationService,
             org.apache.oozie.service.HadoopAccessorService,
+            org.apache.oozie.service.JobsConcurrencyService,
             org.apache.oozie.service.URIHandlerService,
             org.apache.oozie.service.MemoryLocksService,
             org.apache.oozie.service.DagXLogInfoService,
@@ -128,8 +129,7 @@
             org.apache.oozie.service.PauseTransitService,
             org.apache.oozie.service.GroupsService,
             org.apache.oozie.service.ProxyUserService,
-            org.apache.oozie.service.XLogStreamingService,
-            org.apache.oozie.service.JobsConcurrencyService
+            org.apache.oozie.service.XLogStreamingService
         </value>
         <description>
             All services to be created and managed by Oozie Services singleton.

http://git-wip-us.apache.org/repos/asf/oozie/blob/ebe1afa2/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java 
b/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
index 6d4d7a4..62c57a8 100644
--- 
a/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
+++ 
b/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
@@ -1193,12 +1193,6 @@ public class TestJavaActionExecutor extends 
ActionExecutorTestCase {
         Path jar5Path = new Path(otherShareLibPath, "jar5.jar");
         getFileSystem().create(jar5Path).close();
 
-        Path launcherPath = new Path(systemLibPath, "oozie");
-        getFileSystem().mkdirs(launcherPath);
-        Path jar6Path = new Path(launcherPath, "jar5.jar");
-        getFileSystem().create(jar6Path).close();
-
-
         String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + 
"</job-tracker>" +
                 "<name-node>" + getNameNodeUri() + "</name-node>" +
                 "<job-xml>job.xml</job-xml>" + "<job-xml>job2.xml</job-xml>" +
@@ -1223,6 +1217,18 @@ public class TestJavaActionExecutor extends 
ActionExecutorTestCase {
 
         Configuration jobConf = ae.createBaseHadoopConf(context, eActionXml);
         ae.setupLauncherConf(jobConf, eActionXml, getAppPath(), context);
+        try {
+            ae.setLibFilesArchives(context, eActionXml, getAppPath(), jobConf);
+            fail();
+        } catch (ActionExecutorException aee) {
+            assertEquals("EJ001", aee.getErrorCode());
+            assertEquals("Could not locate Oozie sharelib", aee.getMessage());
+        }
+        Path launcherPath = new Path(systemLibPath, "oozie");
+        getFileSystem().mkdirs(launcherPath);
+        Path jar6Path = new Path(launcherPath, "jar6.jar");
+        getFileSystem().create(jar6Path).close();
+        Services.get().get(ShareLibService.class).updateShareLib();
         ae.setLibFilesArchives(context, eActionXml, getAppPath(), jobConf);
 
         URI[] cacheFiles = DistributedCache.getCacheFiles(jobConf);
@@ -1231,6 +1237,8 @@ public class TestJavaActionExecutor extends 
ActionExecutorTestCase {
         assertTrue(cacheFilesStr.contains(jar2Path.toString()));
         assertTrue(cacheFilesStr.contains(jar3Path.toString()));
         assertTrue(cacheFilesStr.contains(jar4Path.toString()));
+        assertFalse(cacheFilesStr.contains(jar5Path.toString()));
+        assertTrue(cacheFilesStr.contains(jar6Path.toString()));
 
         // Test per workflow action sharelib setting
         workflow = (WorkflowJobBean) context.getWorkflow();
@@ -1256,6 +1264,7 @@ public class TestJavaActionExecutor extends 
ActionExecutorTestCase {
         assertTrue(cacheFilesStr.contains(jar3Path.toString()));
         assertTrue(cacheFilesStr.contains(jar4Path.toString()));
         assertTrue(cacheFilesStr.contains(jar5Path.toString()));
+        assertTrue(cacheFilesStr.contains(jar6Path.toString()));
     }
 
     public void testAddShareLibSchemeAndAuthority() throws Exception {

http://git-wip-us.apache.org/repos/asf/oozie/blob/ebe1afa2/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index b7daf42..ceff86b 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
 -- Oozie 4.1.0 release (trunk - unreleased)
 
+OOZIE-1621 Add proper error code and error message for sharelib exceptions. 
(rkanter)
 OOZIE-1785 Add oozie email action xsd to OozieCli.java (jagatsingh via rohini)
 OOZIE-1527 Fix scalability issues with coordinator materialization (puru via 
rohini)
 OOZIE-1797 Workflow rerun command should use existing workflow properties 
(puru via rohini)

Reply via email to