/** * Useful for overriding in actions that do subsequent job runs * such as the MapReduce Action, where the launcher job is not the * actual job that then gets monitored. * @param action * @return external ID. */ protected String getActualExternalId(WorkflowAction action) { return action.getExternalId(); }
/** * For every {@link JavaActionExecutor} that is not {@link MapReduceActionExecutor}, the effective YARN application ID of the * action is the one where {@link LauncherAM} is run, hence this default implementation. * @param context the execution context * @param action the workflow action * @return a {@code String} that depicts the application ID of the launcher ApplicationMaster of this action * @throws ActionExecutorException */ protected String findYarnApplicationId(final Context context, final WorkflowAction action) throws ActionExecutorException { return action.getExternalId(); }
/** * For every {@link JavaActionExecutor} that is not {@link MapReduceActionExecutor}, the effective YARN application ID of the * action is the one where {@link LauncherAM} is run, hence this default implementation. * @param context the execution context * @param action the workflow action * @return a {@code String} that depicts the application ID of the launcher ApplicationMaster of this action * @throws ActionExecutorException */ protected String findYarnApplicationId(final Context context, final WorkflowAction action) throws ActionExecutorException { return action.getExternalId(); }
/** * Useful for overriding in actions that do subsequent job runs * such as the MapReduce Action, where the launcher job is not the * actual job that then gets monitored. * @param action * @return external ID. */ protected String getActualExternalId(WorkflowAction action) { return action.getExternalId(); }
@Override protected String getActualExternalId(WorkflowAction action) { String launcherJobId = action.getExternalId(); String childId = action.getExternalChildIDs(); if (childId != null && !childId.isEmpty()) { return childId; } else { return launcherJobId; } }
@Override protected String getActualExternalId(WorkflowAction action) { String launcherJobId = action.getExternalId(); String childId = action.getExternalChildIDs(); if (childId != null && !childId.isEmpty()) { return childId; } else { return launcherJobId; } }
private void storeOozieLauncherLog(final File outputDir, final WorkflowAction action, final String user) { try (PrintStream fw = new PrintStream(new File(outputDir, "launcher_" + action.getName() + ".log"), StandardCharsets.UTF_8.toString())) { final ApplicationId appId = ConverterUtils.toApplicationId(action.getExternalId()); oozieLauncherLogFetcher.dumpAllContainersLogs(appId, user, fw); } catch (IOException e) { System.err.printf("Exception occurred during the retrieval of Oozie launcher logs for workflow(s): %s%n", e.getMessage()); } }
private Map<String, String> loadExtIds(List<WorkflowAction> actions) { Map<String, String> extIds = new HashMap<String, String>(); for (WorkflowAction action : actions) { extIds.put(action.getName(), action.getExternalId()); } return extIds; }
/** * Kill ssh action. * * @param context action execution context. * @param action object. * @throws org.apache.oozie.action.ActionExecutorException */ @Override public void kill(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Killing action"); String command = "ssh " + action.getTrackerUri() + " kill -KILL " + action.getExternalId(); int returnValue = getReturnValue(command); if (returnValue != 0) { throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FAILED_TO_KILL", XLog.format( "Unable to kill process {0} on {1}", action.getExternalId(), action.getTrackerUri())); } context.setEndData(WorkflowAction.Status.KILLED, "ERROR"); }
private void printWorkflowAction(WorkflowAction action, boolean contains) { System.out.println("ID : " + maskIfNull(action.getId())); System.out.println(RULER); System.out.println("Console URL : " + maskIfNull(action.getConsoleUrl())); System.out.println("Error Code : " + maskIfNull(action.getErrorCode())); System.out.println("Error Message : " + maskIfNull(action.getErrorMessage())); System.out.println("External ID : " + maskIfNull(action.getExternalId())); System.out.println("External Status : " + maskIfNull(action.getExternalStatus())); System.out.println("Name : " + maskIfNull(action.getName())); System.out.println("Retries : " + action.getRetries()); System.out.println("Tracker URI : " + maskIfNull(action.getTrackerUri())); System.out.println("Type : " + maskIfNull(action.getType())); System.out.println("Started : " + maskDate(action.getStartTime(), contains)); System.out.println("Status : " + action.getStatus()); System.out.println("Ended : " + maskDate(action.getEndTime(), contains)); System.out.println(RULER); }
/** * Kill ssh action. * * @param context action execution context. * @param action object. * @throws org.apache.oozie.action.ActionExecutorException */ @Override public void kill(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Killing action"); String command = "ssh " + action.getTrackerUri() + " kill -KILL " + action.getExternalId(); int returnValue = getReturnValue(command); if (returnValue != 0) { throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "FAILED_TO_KILL", XLog.format( "Unable to kill process {0} on {1}", action.getExternalId(), action.getTrackerUri())); } context.setEndData(WorkflowAction.Status.KILLED, "ERROR"); }
public void kill(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Killing action"); try { String subWorkflowId = action.getExternalId(); String oozieUri = action.getTrackerUri(); if (subWorkflowId != null && oozieUri != null) { OozieClient oozieClient = getWorkflowClient(context, oozieUri); oozieClient.kill(subWorkflowId); } context.setEndData(WorkflowAction.Status.KILLED, getActionSignal(WorkflowAction.Status.KILLED)); } catch (Exception ex) { throw convertException(ex); } }
public void kill(Context context, WorkflowAction action) throws ActionExecutorException { LOG.info("Killing action"); try { String subWorkflowId = action.getExternalId(); String oozieUri = action.getTrackerUri(); if (subWorkflowId != null && oozieUri != null) { OozieClient oozieClient = getWorkflowClient(context, oozieUri); oozieClient.kill(subWorkflowId); } context.setEndData(WorkflowAction.Status.KILLED, getActionSignal(WorkflowAction.Status.KILLED)); } catch (Exception ex) { throw convertException(ex); } }
public void testSubWorkflowSuspend() throws Exception { try { String workflowUri = createSubWorkflowWithLazyAction(true); LocalOozie.start(); final OozieClient wfClient = LocalOozie.getClient(); final String jobId = submitWorkflow(workflowUri, wfClient); waitForWorkflowToStart(wfClient, jobId); WorkflowJob wf = wfClient.getJobInfo(jobId); // Suspending subworkflow new SuspendXCommand(wf.getActions().get(1).getExternalId()).call(); // Check suspend for base workflow assertEquals(WorkflowJob.Status.SUSPENDED, wfClient.getJobInfo(jobId).getStatus()); //Check suspend for sub workflow assertEquals(WorkflowJob.Status.SUSPENDED, wfClient.getJobInfo(wf.getActions().get(1).getExternalId()).getStatus()); } finally { LocalOozie.stop(); } }
protected String submitAction(Context context) throws Exception { DistcpActionExecutor ae = new DistcpActionExecutor(); WorkflowAction action = context.getAction(); ae.prepareActionDir(getFileSystem(), context); ae.submitLauncher(getFileSystem(), context, action); String jobId = action.getExternalId(); String jobTracker = action.getTrackerUri(); String consoleUrl = action.getConsoleUrl(); assertNotNull(jobId); assertNotNull(jobTracker); assertNotNull(consoleUrl); ae.submitLauncher(getFileSystem(), context, context.getAction()); return context.getAction().getExternalId(); }
protected String submitAction(Context context, JavaActionExecutor javaActionExecutor) throws ActionExecutorException { WorkflowAction action = context.getAction(); javaActionExecutor.prepareActionDir(getFileSystem(), context); javaActionExecutor.submitLauncher(getFileSystem(), context, action); String jobId = action.getExternalId(); String jobTracker = action.getTrackerUri(); String consoleUrl = action.getConsoleUrl(); assertNotNull(jobId); assertNotNull(jobTracker); assertNotNull(consoleUrl); return jobId; }
public void testSimpestSleSubmitOK() throws Exception { String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>"; Context context = createContext(actionXml, null); submitAction(context); waitUntilYarnAppDoneAndAssertSuccess(context.getAction().getExternalId()); ActionExecutor ae = new JavaActionExecutor(); ae.check(context, context.getAction()); assertEquals("SUCCEEDED", context.getAction().getExternalStatus()); assertNull(context.getAction().getData()); ae.end(context, context.getAction()); assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus()); }
public void testSimplestSubmitWithResourceManagerOK() throws Exception { final String actionXml = "<java>" + "<resource-manager>" + getJobTrackerUri() + "</resource-manager>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>"; final Context context = createContext(actionXml, null); submitAction(context); waitUntilYarnAppDoneAndAssertSuccess(context.getAction().getExternalId()); final ActionExecutor ae = new JavaActionExecutor(); ae.check(context, context.getAction()); assertEquals("SUCCEEDED", context.getAction().getExternalStatus()); assertNull(context.getAction().getData()); ae.end(context, context.getAction()); assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus()); }
public void testSubmitOKWithLauncherEnvVars() throws Exception { String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + " <property><name>oozie.launcher.env</name><value>A=foo1" + File.pathSeparator + "B=foo2</value></property>" + "</configuration>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>"; Context context = createContext(actionXml, null); submitAction(context); waitUntilYarnAppDoneAndAssertSuccess(context.getAction().getExternalId()); ActionExecutor ae = new JavaActionExecutor(); ae.check(context, context.getAction()); assertEquals("SUCCEEDED", context.getAction().getExternalStatus()); assertNull(context.getAction().getData()); ae.end(context, context.getAction()); assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus()); }
public void testSubmitOKWithLauncherJavaOpts() throws Exception { String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + " <property><name>oozie.launcher.javaopts</name><value>-DtestJavaOpts=true</value></property>" + "</configuration>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>"; Context context = createContext(actionXml, null); submitAction(context); waitUntilYarnAppDoneAndAssertSuccess(context.getAction().getExternalId()); ActionExecutor ae = new JavaActionExecutor(); ae.check(context, context.getAction()); assertEquals("FAILED/KILLED", context.getAction().getExternalStatus()); assertNull(context.getAction().getData()); ae.end(context, context.getAction()); assertEquals(WorkflowAction.Status.ERROR, context.getAction().getStatus()); }