Skip to content
This repository
Browse code

Closes OOZIE-135 support multiple shared lib path in oozie

  • Loading branch information...
commit 575d71c7d7f9467479a89fe6bdf53bb08046c084 1 parent c16779a
authored August 10, 2011 Mohammad Kamrul Islam committed August 18, 2011
17  core/src/main/java/org/apache/oozie/service/WorkflowAppService.java
@@ -175,15 +175,20 @@ public XConfiguration createProtoActionConf(Configuration jobConf, String authTo
175 175
                 filePaths = new ArrayList<String>();
176 176
             }
177 177
 
178  
-            if (jobConf.get(OozieClient.LIBPATH) != null) {
179  
-                Path libPath = new Path(jobConf.get(OozieClient.LIBPATH));
180  
-                List<String> libPaths = getLibFiles(fs, libPath);
181  
-                filePaths.addAll(libPaths);
  178
+            String[] libPaths = jobConf.getStrings(OozieClient.LIBPATH);
  179
+            if (libPaths != null && libPaths.length > 0) {
  180
+                for (int i = 0; i < libPaths.length; i++) {
  181
+                    if (libPaths[i].trim().length() > 0) {
  182
+                        Path libPath = new Path(libPaths[i].trim());
  183
+                        List<String> libFilePaths = getLibFiles(fs, libPath);
  184
+                        filePaths.addAll(libFilePaths);
  185
+                    }
  186
+                }
182 187
             }
183 188
 
184 189
             if (systemLibPath != null && jobConf.getBoolean(OozieClient.USE_SYSTEM_LIBPATH, false)) {
185  
-                List<String> libPaths = getLibFiles(fs, systemLibPath);
186  
-                filePaths.addAll(libPaths);
  190
+                List<String> libFilePaths = getLibFiles(fs, systemLibPath);
  191
+                filePaths.addAll(libFilePaths);
187 192
             }
188 193
 
189 194
             conf.setStrings(APP_LIB_PATH_LIST, filePaths.toArray(new String[filePaths.size()]));
67  core/src/test/java/org/apache/oozie/service/TestLiteWorkflowAppService.java
@@ -351,6 +351,73 @@ public void testCreateprotoConfWithLibPath() throws Exception {
351 351
             services.destroy();
352 352
         }
353 353
     }
  354
+    
  355
+    public void testCreateprotoConfWithMulipleLibPath() throws Exception {
  356
+        Services services = new Services();
  357
+        try {
  358
+            services.init();
  359
+            Reader reader = IOUtils.getResourceAsReader("wf-schema-valid.xml", -1);
  360
+            Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
  361
+            IOUtils.copyCharStream(reader, writer);
  362
+
  363
+            createTestCaseSubDir("lib");
  364
+            writer = new FileWriter(getTestCaseDir() + "/lib/maputil.jar");
  365
+            writer.write("bla bla");
  366
+            writer.close();
  367
+            writer = new FileWriter(getTestCaseDir() + "/lib/reduceutil.so");
  368
+            writer.write("bla bla");
  369
+            writer.close();
  370
+            createTestCaseSubDir("libx");
  371
+            writer = new FileWriter(getTestCaseDir() + "/libx/maputil_x.jar");
  372
+            writer.write("bla bla");
  373
+            writer.close();            
  374
+            createTestCaseSubDir("liby");
  375
+            writer = new FileWriter(getTestCaseDir() + "/liby/maputil_y1.jar");
  376
+            writer.write("bla bla");
  377
+            writer.close();
  378
+            writer = new FileWriter(getTestCaseDir() + "/liby/maputil_y2.jar");
  379
+            writer.write("bla bla");
  380
+            writer.close();
  381
+            createTestCaseSubDir("libz");
  382
+            writer = new FileWriter(getTestCaseDir() + "/libz/maputil_z.jar");
  383
+            writer.write("bla bla");
  384
+            writer.close();
  385
+
  386
+            WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
  387
+            Configuration jobConf = new XConfiguration();
  388
+            jobConf.set(OozieClient.APP_PATH, "file://" + getTestCaseDir() + "/workflow.xml");
  389
+            jobConf.setStrings(OozieClient.LIBPATH, "file://" + getTestCaseDir() + "/libx",
  390
+                    "file://" + getTestCaseDir() + "/liby", "file://" + getTestCaseDir() + "/libz");
  391
+            jobConf.set(OozieClient.USER_NAME, getTestUser());
  392
+            jobConf.set(OozieClient.GROUP_NAME, getTestGroup());
  393
+            injectKerberosInfo(jobConf);
  394
+            Configuration protoConf = wps.createProtoActionConf(jobConf, "authToken", true);
  395
+            assertEquals(getTestUser(), protoConf.get(OozieClient.USER_NAME));
  396
+            assertEquals(getTestGroup(), protoConf.get(OozieClient.GROUP_NAME));
  397
+
  398
+            assertEquals(6, protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST).length);
  399
+            List<String> found = new ArrayList<String>();
  400
+            found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[0]);
  401
+            found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[1]);
  402
+            found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[2]);
  403
+            found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[3]);
  404
+            found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[4]);
  405
+            found.add(protoConf.getStrings(WorkflowAppService.APP_LIB_PATH_LIST)[5]);
  406
+            List<String> expected = new ArrayList<String>();
  407
+            expected.add(getTestCaseDir() + "/lib/reduceutil.so");
  408
+            expected.add(getTestCaseDir() + "/lib/maputil.jar");
  409
+            expected.add(getTestCaseDir() + "/libx/maputil_x.jar");
  410
+            expected.add(getTestCaseDir() + "/liby/maputil_y1.jar");
  411
+            expected.add(getTestCaseDir() + "/liby/maputil_y2.jar");
  412
+            expected.add(getTestCaseDir() + "/libz/maputil_z.jar");
  413
+            Collections.sort(found);
  414
+            Collections.sort(expected);
  415
+            assertEquals(expected, found);
  416
+        }
  417
+        finally {
  418
+            services.destroy();
  419
+        }
  420
+    }
354 421
 
355 422
     public void testCreateprotoConfWithSystemLibPath() throws Exception {
356 423
         String systemLibPath = createTestCaseSubDir("syslib");
1  release-log.txt
... ...
@@ -1,5 +1,6 @@
1 1
 -- Oozie 3.1.0 release
2 2
 
  3
+OOZIE-135 support multiple shared lib path in oozie
3 4
 OOZIE-18 Option to view Workflow job details from Coordinator job detail popup
4 5
 OOZIE-17 Group column for coordinator jobs in Oozie Web Console
5 6
 OOZIE-11  Adding Distcp Action.  

0 notes on commit 575d71c

Please sign in to comment.
Something went wrong with that request. Please try again.