This is an automated email from the ASF dual-hosted git repository.
kmarton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/oozie.git
The following commit(s) were added to refs/heads/master by this push:
new 512360e OOZIE-2907 Delete PrepareActionsDriver from oozie-sharelib
(asalamon74 via kmarton)
512360e is described below
commit 512360e7dd584d565748e2b2881867c267222d58
Author: kmarton <[email protected]>
AuthorDate: Fri Jun 28 09:26:01 2019 +0200
OOZIE-2907 Delete PrepareActionsDriver from oozie-sharelib (asalamon74 via
kmarton)
---
.../oozie/action/hadoop/TestFSPrepareActions.java | 12 +--
.../action/hadoop/TestHCatPrepareActions.java | 2 +-
.../action/hadoop/TestPrepareActionsDriver.java | 86 ----------------------
.../java/org/apache/oozie/test/XFsTestCase.java | 21 ++++++
release-log.txt | 1 +
.../oozie/action/hadoop/PrepareActionsDriver.java | 69 -----------------
.../oozie/action/hadoop/PrepareActionsHandler.java | 5 +-
7 files changed, 32 insertions(+), 164 deletions(-)
diff --git
a/core/src/test/java/org/apache/oozie/action/hadoop/TestFSPrepareActions.java
b/core/src/test/java/org/apache/oozie/action/hadoop/TestFSPrepareActions.java
index a08c16a..34437f1 100644
---
a/core/src/test/java/org/apache/oozie/action/hadoop/TestFSPrepareActions.java
+++
b/core/src/test/java/org/apache/oozie/action/hadoop/TestFSPrepareActions.java
@@ -60,7 +60,7 @@ public class TestFSPrepareActions extends XFsTestCase {
JobConf conf = createJobConf();
LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
+ doPrepareOperations(prepareXML, conf);
assertFalse(fs.exists(newDir));
}
@@ -86,7 +86,7 @@ public class TestFSPrepareActions extends XFsTestCase {
JobConf conf = createJobConf();
LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
+ doPrepareOperations(prepareXML, conf);
assertFalse(fs.exists(new Path(newDir + "/2010/10")));
assertFalse(fs.exists(new Path(newDir + "/2011/10")));
assertTrue(fs.exists(new Path(newDir + "/2012/10")));
@@ -108,7 +108,7 @@ public class TestFSPrepareActions extends XFsTestCase {
JobConf conf = createJobConf();
LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
+ doPrepareOperations(prepareXML, conf);
assertTrue(fs.exists(newDir));
}
@@ -121,13 +121,13 @@ public class TestFSPrepareActions extends XFsTestCase {
// Construct prepare XML block with the path
String prepareXML = "<prepare>" + "<delete path='" + newDir + "'/>" +
"</prepare>";
// Parse the XML to get the node
- Document doc = PrepareActionsDriver.getDocumentFromXML(prepareXML);
+ Document doc = PrepareActionsHandler.getDocumentFromXML(prepareXML);
Node n = doc.getDocumentElement().getChildNodes().item(0);
try {
JobConf conf = createJobConf();
LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
+ doPrepareOperations(prepareXML, conf);
fail("Expected to catch an exception but did not encounter any");
} catch (LauncherException le) {
Path path = new
Path(n.getAttributes().getNamedItem("path").getNodeValue().trim());
@@ -154,7 +154,7 @@ public class TestFSPrepareActions extends XFsTestCase {
JobConf conf = createJobConf();
LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
+ doPrepareOperations(prepareXML, conf);
assertTrue(fs.exists(new Path(noSchemePath)));
}
diff --git
a/core/src/test/java/org/apache/oozie/action/hadoop/TestHCatPrepareActions.java
b/core/src/test/java/org/apache/oozie/action/hadoop/TestHCatPrepareActions.java
index 4fe9452..9626f8b 100644
---
a/core/src/test/java/org/apache/oozie/action/hadoop/TestHCatPrepareActions.java
+++
b/core/src/test/java/org/apache/oozie/action/hadoop/TestHCatPrepareActions.java
@@ -66,7 +66,7 @@ public class TestHCatPrepareActions extends XHCatTestCase {
JobConf conf = createJobConf();
LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
+ doPrepareOperations(prepareXML, conf);
FileSystem fs = getFileSystem();
assertFalse(fs.exists(new Path(part1)));
assertFalse(fs.exists(new Path(part2)));
diff --git
a/core/src/test/java/org/apache/oozie/action/hadoop/TestPrepareActionsDriver.java
b/core/src/test/java/org/apache/oozie/action/hadoop/TestPrepareActionsDriver.java
deleted file mode 100644
index 89aeab6..0000000
---
a/core/src/test/java/org/apache/oozie/action/hadoop/TestPrepareActionsDriver.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oozie.action.hadoop;
-
-import java.io.IOException;
-import org.apache.hadoop.fs.Path;
-import org.apache.oozie.service.Services;
-import org.apache.oozie.test.XFsTestCase;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.mapred.JobConf;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-public class TestPrepareActionsDriver extends XFsTestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- new Services().init();
- }
-
- @Override
- protected void tearDown() throws Exception {
- Services.get().destroy();
- super.tearDown();
- }
-
- // Test to check if prepare action is performed as expected when the
prepare XML block is a valid one
- public void testDoOperationsWithValidXML() throws LauncherException,
IOException, ParserConfigurationException, SAXException {
- Path actionDir = getFsTestCaseDir();
- FileSystem fs = getFileSystem();
- Path newDir = new Path(actionDir, "newDir");
- String prepareXML = "<prepare>" + "<mkdir path='" + newDir + "'/>" +
"</prepare>";
-
- // Delete the file if it is already there
- if (fs.exists(newDir)) {
- fs.delete(newDir, true);
- }
-
- JobConf conf = createJobConf();
- LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
- assertTrue(fs.exists(actionDir));
- }
-
- // Test to check if Exception is thrown when the prepare XML block is
invalid
- public void testDoOperationsWithInvalidXML() throws LauncherException,
IOException {
- Path actionDir = getFsTestCaseDir();
- FileSystem fs = getFileSystem();
- Path newDir = new Path(actionDir, "newDir");
- String prepareXML = "";
-
- // Delete the file if it is already there
- if (fs.exists(newDir)) {
- fs.delete(newDir, true);
- }
-
- try {
- prepareXML = "prepare>" + "<mkdir path='" + newDir + "'/>" +
"</prepare>";
- JobConf conf = createJobConf();
- LauncherHelper.setupLauncherURIHandlerConf(conf);
- PrepareActionsDriver.doOperations(prepareXML, conf);
- fail("Expected to catch an exception but did not encounter any");
- } catch (Exception ex) {
- assertEquals(ex.getClass(), org.xml.sax.SAXParseException.class);
- assertEquals(ex.getMessage(), "Content is not allowed in prolog.");
- }
- }
-}
diff --git a/core/src/test/java/org/apache/oozie/test/XFsTestCase.java
b/core/src/test/java/org/apache/oozie/test/XFsTestCase.java
index 80f5f45..c0f3c69 100644
--- a/core/src/test/java/org/apache/oozie/test/XFsTestCase.java
+++ b/core/src/test/java/org/apache/oozie/test/XFsTestCase.java
@@ -25,6 +25,9 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.mapred.JobClient;
+import org.apache.oozie.action.hadoop.LauncherException;
+import org.apache.oozie.action.hadoop.LauncherURIHandlerFactory;
+import org.apache.oozie.action.hadoop.PrepareActionsHandler;
import org.apache.oozie.util.XConfiguration;
import org.apache.oozie.util.XLog;
import org.apache.oozie.client.WorkflowJob;
@@ -32,7 +35,9 @@ import
org.apache.oozie.command.wf.ActionXCommand.ActionExecutorContext;
import org.apache.oozie.service.HadoopAccessorException;
import org.apache.oozie.service.HadoopAccessorService;
import org.apache.oozie.service.Services;
+import org.xml.sax.SAXException;
+import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.net.URI;
@@ -54,6 +59,7 @@ public abstract class XFsTestCase extends XTestCase {
private FileSystem fileSystem2;
private Path fsTestDir;
private Path fsTestDir2;
+ private PrepareActionsHandler prepareHandler;
/**
* Set up the testcase.
@@ -83,6 +89,7 @@ public abstract class XFsTestCase extends XTestCase {
fileSystem2 = has.createFileSystem(getTestUser(), new
URI(getNameNode2Uri()), jobConf);
fsTestDir2 = initFileSystem(fileSystem2);
}
+ prepareHandler = new PrepareActionsHandler(new
LauncherURIHandlerFactory(null));
}
private Path initFileSystem(FileSystem fs) throws Exception {
@@ -201,4 +208,18 @@ public abstract class XFsTestCase extends XTestCase {
fileName
);
}
+
+ /**
+ * Method to parse the prepare XML and execute the corresponding prepare
actions
+ *
+ * @param prepareXML Prepare XML block in string format
+ * @throws IOException if there is an IO error during prepare action
+ * @throws SAXException in case of xml parsing error
+ * @throws ParserConfigurationException if the parser is not well
configured
+ * @throws LauncherException when accessing resource on uri fails
+ */
+ public void doPrepareOperations(String prepareXML, Configuration conf)
+ throws IOException, SAXException, ParserConfigurationException,
LauncherException {
+ prepareHandler.prepareAction(prepareXML, conf);
+ }
}
diff --git a/release-log.txt b/release-log.txt
index 1409ed3..cf36bed 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -1,5 +1,6 @@
-- Oozie 5.2.0 release (trunk - unreleased)
+OOZIE-2907 Delete PrepareActionsDriver from oozie-sharelib (asalamon74 via
kmarton)
OOZIE-3518 [docs] Dead links in DG_HCatalogIntegration (nobigo via asalamon74)
OOZIE-3517 Invalid reference to xtheme-default.css (nobigo via asalamon74)
OOZIE-3516 Misleading warning: java.lang.IllegalArgumentException: Does not
contain a valid host:port authority: yarnRM (kmarton via asalamon74)
diff --git
a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PrepareActionsDriver.java
b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PrepareActionsDriver.java
deleted file mode 100644
index c98eb3a..0000000
---
a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PrepareActionsDriver.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.oozie.action.hadoop;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-
-import org.apache.hadoop.conf.Configuration;
-import org.xml.sax.SAXException;
-import org.w3c.dom.Document;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * Utility class to perform operations on the prepare block of Workflow
- *
- */
-@Deprecated
-public class PrepareActionsDriver {
- private static final PrepareActionsHandler prepareHandler = new
PrepareActionsHandler(new LauncherURIHandlerFactory(null));
-
- /**
- * Method to parse the prepare XML and execute the corresponding prepare
actions
- *
- * @param prepareXML Prepare XML block in string format
- * @throws LauncherException
- */
- static void doOperations(String prepareXML, Configuration conf)
- throws IOException, SAXException, ParserConfigurationException,
LauncherException {
- prepareHandler.prepareAction(prepareXML, conf);
- }
-
- // Method to return the document from the prepare XML block
- static Document getDocumentFromXML(String prepareXML) throws
ParserConfigurationException, SAXException,
- IOException {
- DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();
- docBuilderFactory.setNamespaceAware(true);
- // support for includes in the xml file
- docBuilderFactory.setXIncludeAware(true);
- // ignore all comments inside the xml file
- docBuilderFactory.setIgnoringComments(true);
- docBuilderFactory.setExpandEntityReferences(false);
-
docBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl",
true);
- DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
- InputStream is = new
ByteArrayInputStream(prepareXML.getBytes(StandardCharsets.UTF_8));
- return docBuilder.parse(is);
- }
-
-}
diff --git
a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PrepareActionsHandler.java
b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PrepareActionsHandler.java
index b9c4878..7b17fd5 100644
---
a/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PrepareActionsHandler.java
+++
b/sharelib/oozie/src/main/java/org/apache/oozie/action/hadoop/PrepareActionsHandler.java
@@ -39,7 +39,7 @@ public class PrepareActionsHandler {
private final LauncherURIHandlerFactory factory;
@VisibleForTesting
- PrepareActionsHandler(final LauncherURIHandlerFactory factory) {
+ public PrepareActionsHandler(final LauncherURIHandlerFactory factory) {
this.factory = factory;
}
@@ -53,7 +53,8 @@ public class PrepareActionsHandler {
* @throws ParserConfigurationException if the parser is not well
configured
* @throws LauncherException when accessing resource on uri fails
*/
- void prepareAction(String prepareXML, Configuration conf)
+ @VisibleForTesting
+ public void prepareAction(String prepareXML, Configuration conf)
throws IOException, SAXException, ParserConfigurationException,
LauncherException {
Document doc = getDocumentFromXML(prepareXML);
doc.getDocumentElement().normalize();