protected boolean getCaptureOutput(WorkflowAction action) throws JDOMException { Element eConf = XmlUtils.parseXml(action.getConf()); Namespace ns = eConf.getNamespace(); Element captureOutput = eConf.getChild("capture-output", ns); return captureOutput != null; }
protected boolean getCaptureOutput(WorkflowAction action) throws JDOMException { Element eConf = XmlUtils.parseXml(action.getConf()); Namespace ns = eConf.getNamespace(); Element captureOutput = eConf.getChild("capture-output", ns); return captureOutput != null; }
private void persistResolvedActionDefinition(final WorkflowAction action, final File resolvedActionsDir) throws IOException { persistWorkflowDefinition(resolvedActionsDir, action.getName(), action.getConf()); }
private Configuration createJobConfFromActionConf(final Context context, final WorkflowAction action) throws JDOMException, NoSuchAlgorithmException { final Element actionXml = XmlUtils.parseXml(action.getConf()); final Configuration jobConf = createBaseHadoopConf(context, actionXml); final String launcherTag = getActionYarnTag(context, action); jobConf.set(CHILD_MAPREDUCE_JOB_TAGS, LauncherHelper.getTag(launcherTag)); return jobConf; }
private Configuration createJobConfFromActionConf(final Context context, final WorkflowAction action) throws JDOMException, NoSuchAlgorithmException { final Element actionXml = XmlUtils.parseXml(action.getConf()); final Configuration jobConf = createBaseHadoopConf(context, actionXml); final String launcherTag = getActionYarnTag(context, action); jobConf.set(CHILD_MAPREDUCE_JOB_TAGS, LauncherHelper.getTag(launcherTag)); return jobConf; }
LOG.info("Starting action"); try { String confStr = action.getConf(); context.setStartData("-", "-", "-"); Element conf = XmlUtils.parseXml(confStr);
LOG.info("Starting action"); try { String confStr = action.getConf(); context.setStartData("-", "-", "-"); Element conf = XmlUtils.parseXml(confStr);
@Override public void start(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Starting action"); try { context.setStartData("-", "-", "-"); Element actionXml = XmlUtils.parseXml(action.getConf()); validateAndMail(context, actionXml); context.setExecutionData("OK", null); } catch (Exception ex) { throw convertException(ex); } }
@Override public void start(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Starting action"); try { context.setStartData("-", "-", "-"); Element actionXml = XmlUtils.parseXml(action.getConf()); doOperations(context, actionXml); context.setExecutionData("OK", null); } catch (Exception ex) { throw convertException(ex); } }
@Override public void start(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Starting action"); try { context.setStartData("-", "-", "-"); Element actionXml = XmlUtils.parseXml(action.getConf()); doOperations(context, actionXml); context.setExecutionData("OK", null); } catch (Exception ex) { throw convertException(ex); } }
@Override public void start(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Starting action"); try { context.setStartData("-", "-", "-"); Element actionXml = XmlUtils.parseXml(action.getConf()); validateAndMail(context, actionXml); context.setExecutionData("OK", null); } catch (Exception ex) { throw convertException(ex); } }
private XConfiguration getJavaActionConfiguration(WorkflowJob workflow) throws Exception { final WorkflowAction workflowAction = helper.getJavaAction(workflow); final Element element = XmlUtils.parseXml(workflowAction.getConf()); final String configuration = XmlUtils.prettyPrint(element.getChild("configuration", element.getNamespace())).toString(); return new XConfiguration(new StringReader(configuration)); }
public void testProperties() { WorkflowAction action = createNode(); Assert.assertEquals("a", action.getId()); Assert.assertEquals("b", action.getName()); Assert.assertEquals("c", action.getType()); Assert.assertEquals("d", action.getConf()); Assert.assertEquals(WorkflowAction.Status.RUNNING, action.getStatus()); Assert.assertEquals(1, action.getRetries()); Assert.assertEquals(JsonUtils.parseDateRfc822(START_TIME), action.getStartTime()); Assert.assertEquals(JsonUtils.parseDateRfc822(END_TIME), action.getEndTime()); Assert.assertEquals("e", action.getTransition()); Assert.assertEquals("ee", action.getData()); Assert.assertEquals("stats", action.getStats()); Assert.assertEquals("extChIDs", action.getExternalChildIDs()); Assert.assertEquals("f", action.getExternalId()); Assert.assertEquals("g", action.getExternalStatus()); Assert.assertEquals("h", action.getTrackerUri()); Assert.assertEquals("i", action.getConsoleUrl()); Assert.assertEquals("j", action.getErrorCode()); Assert.assertEquals("k", action.getErrorMessage()); }
public void end(Context context, WorkflowAction action) throws ActionExecutorException { Element eConf = getConfiguration(action.getConf()); Namespace ns = eConf.getNamespace(); String error = eConf.getChild("error", ns).getText().trim();
public void start(Context context, WorkflowAction action) throws ActionExecutorException { Element eConf = getConfiguration(action.getConf()); Namespace ns = eConf.getNamespace(); String error = eConf.getChild("error", ns).getText().trim();
@Override public void kill(Context context, WorkflowAction action) throws ActionExecutorException { YarnClient yarnClient = null; try { Element actionXml = XmlUtils.parseXml(action.getConf()); final Configuration jobConf = createBaseHadoopConf(context, actionXml); String launcherTag = getActionYarnTag(context, action); jobConf.set(LauncherMain.CHILD_MAPREDUCE_JOB_TAGS, LauncherHelper.getTag(launcherTag)); yarnClient = createYarnClient(context, jobConf); String appExternalId = action.getExternalId(); killExternalApp(action, yarnClient, appExternalId); killExternalChildApp(action, yarnClient, appExternalId); killExternalChildAppByTags(action, yarnClient, jobConf, appExternalId); context.setExternalStatus(KILLED); context.setExecutionData(KILLED, null); } catch (Exception ex) { LOG.error("Error when killing YARN application", ex); throw convertException(ex); } finally { try { FileSystem actionFs = context.getAppFileSystem(); cleanUpActionDir(actionFs, context); Closeables.closeQuietly(yarnClient); } catch (Exception ex) { LOG.error("Error when cleaning up action dir", ex); throw convertException(ex); } } }
@Override public void kill(Context context, WorkflowAction action) throws ActionExecutorException { YarnClient yarnClient = null; try { Element actionXml = XmlUtils.parseXml(action.getConf()); final Configuration jobConf = createBaseHadoopConf(context, actionXml); String launcherTag = getActionYarnTag(context, action); jobConf.set(LauncherMain.CHILD_MAPREDUCE_JOB_TAGS, LauncherHelper.getTag(launcherTag)); yarnClient = createYarnClient(context, jobConf); String appExternalId = action.getExternalId(); killExternalApp(action, yarnClient, appExternalId); killExternalChildApp(action, yarnClient, appExternalId); killExternalChildAppByTags(action, yarnClient, jobConf, appExternalId); context.setExternalStatus(KILLED); context.setExecutionData(KILLED, null); } catch (Exception ex) { LOG.error("Error when killing YARN application", ex); throw convertException(ex); } finally { try { FileSystem actionFs = context.getAppFileSystem(); cleanUpActionDir(actionFs, context); Closeables.closeQuietly(yarnClient); } catch (Exception ex) { LOG.error("Error when cleaning up action dir", ex); throw convertException(ex); } } }
public void testParentGlobalConf() throws Exception { try { Path subWorkflowAppPath = createSubWorkflowXml(); String workflowUri = createTestWorkflowXml(subWorkflowAppPath); LocalOozie.start(); final OozieClient wfClient = LocalOozie.getClient(); final String jobId = submitWorkflow(workflowUri, wfClient); waitFor(JOB_TIMEOUT, new Predicate() { public boolean evaluate() throws Exception { return (wfClient.getJobInfo(jobId).getStatus() == WorkflowJob.Status.SUCCEEDED) && (wfClient.getJobInfo(jobId).getActions().get(1).getStatus() == WorkflowAction.Status.OK); } }); WorkflowJob subWorkflow = wfClient.getJobInfo(wfClient.getJobInfo(jobId). getActions().get(1).getExternalId()); Configuration subWorkflowConf = getWorkflowConfig(subWorkflow); Element eConf = XmlUtils.parseXml(subWorkflow.getActions().get(1).getConf()); Element element = eConf.getChild("configuration", eConf.getNamespace()); Configuration actionConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(element).toString())); assertEquals("foo1", actionConf.get("foo1")); assertEquals("subconf", actionConf.get("foo2")); assertEquals("foo3", actionConf.get("foo3")); // Checking the action conf configuration. assertEquals("actionconf", subWorkflowConf.get("foo3")); } finally { LocalOozie.stop(); } }
public void testGlobalConfigurationWithActionDefaults() throws Exception { try { String workflowUri = helper.createTestWorkflowXml(getWorkflowGlobalXml(), helper.getJavaActionXml("")); LocalOozie.start(); final OozieClient wfClient = LocalOozie.getClient(); Properties conf = wfClient.createConfiguration(); conf.setProperty(OozieClient.APP_PATH, workflowUri); conf.setProperty(OozieClient.USER_NAME, getTestUser()); conf.setProperty("appName", "var-app-name"); final String jobId = wfClient.submit(conf); wfClient.start(jobId); WorkflowJob workflow = wfClient.getJobInfo(jobId); waitFor(20 * 1000, new Predicate() { @Override public boolean evaluate() throws Exception { WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId)); return javaAction != null && !javaAction.getStatus().equals("PREP"); } }); final WorkflowAction workflowAction = helper.getJavaAction(workflow); Element eConf = XmlUtils.parseXml(workflowAction.getConf()); Element element = eConf.getChild("configuration", eConf.getNamespace()); Configuration actionConf = new XConfiguration(new StringReader(XmlUtils.prettyPrint(element).toString())); assertEquals("Config value set in <global> section is not propagated correctly", "foo2", actionConf.get("action.foo")); } finally { LocalOozie.stop(); } }
public void testResourceManagerInGlobalConfigurationCanBeOverridenWithJobTrackerInAction() throws Exception { try { final String global = "<global>" + "<resource-manager>RM</resource-manager>"+ "</global>"; final String workflowUri = helper.createTestWorkflowXml(global, helper.getJavaActionXml("")); LocalOozie.start(); final OozieClient wfClient = LocalOozie.getClient(); final Properties conf = wfClient.createConfiguration(); conf.setProperty(OozieClient.APP_PATH, workflowUri); conf.setProperty(OozieClient.USER_NAME, getTestUser()); conf.setProperty("appName", "var-app-name"); final String jobId = wfClient.submit(conf); wfClient.start(jobId); WorkflowJob workflow = wfClient.getJobInfo(jobId); waitFor(20 * 1000, new Predicate() { @Override public boolean evaluate() throws Exception { WorkflowAction javaAction = helper.getJavaAction(wfClient.getJobInfo(jobId)); return javaAction != null && !javaAction.getStatus().equals("PREP"); } }); final WorkflowAction workflowAction = helper.getJavaAction(workflow); final String actualConfig = workflowAction.getConf(); final String actualJobTrackerURI = XmlUtils.parseXml(actualConfig).getChildTextNormalize("job-tracker", null); assertEquals(getJobTrackerUri(), actualJobTrackerURI); } finally { LocalOozie.stop(); } }