break; case UPDATE_ACTION_STATUS_PENDING: query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("pending", actionBean.getPending()); query.setParameter("pendingAge", actionBean.getPendingAgeTimestamp()); query.setParameter("consoleUrl", actionBean.getConsoleUrl()); query.setParameter("lastCheckTime", actionBean.getLastCheckTimestamp()); query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("externalStatus", actionBean.getExternalStatus()); query.setParameter("data", actionBean.getDataBlob()); query.setParameter("externalChildIDs", actionBean.getExternalChildIDsBlob()); query.setParameter("externalStatus", actionBean.getExternalStatus()); query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("data", actionBean.getDataBlob()); query.setParameter("pending", actionBean.getPending()); query.setParameter("errorMessage", actionBean.getErrorMessage()); query.setParameter("retries", actionBean.getRetries()); query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("endTime", actionBean.getEndTimestamp()); query.setParameter("pending", actionBean.getPending());
public WorkflowNotificationXCommand(WorkflowJobBean workflow, WorkflowActionBean action) { super("action.notification", "job.notification", 0); ParamChecker.notNull(workflow, "workflow"); ParamChecker.notNull(action, "action"); jobId = action.getId(); url = workflow.getWorkflowInstance().getConf().get(OozieClient.ACTION_NOTIFICATION_URL); if (url != null) { url = url.replaceAll(JOB_ID_PATTERN, workflow.getId()); url = url.replaceAll(NODE_NAME_PATTERN, action.getName()); if (action.isComplete()) { url = url.replaceAll(STATUS_PATTERN, "T:" + action.getTransition()); } else { url = url.replaceAll(STATUS_PATTERN, "S:" + action.getStatus().toString()); } proxyConf = workflow.getWorkflowInstance().getConf() .get(OozieClient.WORKFLOW_NOTIFICATION_PROXY, ConfigurationService.get(NOTIFICATION_PROXY_KEY)); LOG.debug("Proxy :" + proxyConf); } }
break; case UPDATE_ACTION_STATUS_PENDING: query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("pending", actionBean.getPending()); query.setParameter("pendingAge", actionBean.getPendingAgeTimestamp()); query.setParameter("consoleUrl", actionBean.getConsoleUrl()); query.setParameter("lastCheckTime", actionBean.getLastCheckTimestamp()); query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("externalStatus", actionBean.getExternalStatus()); query.setParameter("data", actionBean.getDataBlob()); query.setParameter("externalChildIDs", actionBean.getExternalChildIDsBlob()); query.setParameter("externalStatus", actionBean.getExternalStatus()); query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("data", actionBean.getDataBlob()); query.setParameter("pending", actionBean.getPending()); query.setParameter("errorMessage", actionBean.getErrorMessage()); query.setParameter("retries", actionBean.getRetries()); query.setParameter("status", actionBean.getStatus().toString()); query.setParameter("endTime", actionBean.getEndTimestamp()); query.setParameter("pending", actionBean.getPending());
assertEquals(query.getParameterValue("slaXml"), bean.getSlaXmlBlob()); assertEquals(query.getParameterValue("startTime"), bean.getStartTimestamp()); assertEquals(query.getParameterValue("status"), bean.getStatus().toString()); assertEquals(query.getParameterValue("wfId"), bean.getWfId()); assertEquals(query.getParameterValue("id"), bean.getId()); assertEquals(query.getParameterValue("pending"), bean.getPending()); assertEquals(query.getParameterValue("pendingAge"), bean.getPendingAgeTimestamp()); assertEquals(query.getParameterValue("status"), bean.getStatus().toString()); assertEquals(query.getParameterValue("id"), bean.getId()); assertEquals(query.getParameterValue("consoleUrl"), bean.getConsoleUrl()); assertEquals(query.getParameterValue("lastCheckTime"), bean.getLastCheckTimestamp()); assertEquals(query.getParameterValue("status"), bean.getStatus().toString()); assertEquals(query.getParameterValue("externalStatus"), bean.getExternalStatus()); assertEquals(query.getParameterValue("data"), bean.getDataBlob()); assertEquals(query.getParameterValue("externalChildIDs"), bean.getExternalChildIDsBlob()); assertEquals(query.getParameterValue("externalStatus"), bean.getExternalStatus()); assertEquals(query.getParameterValue("status"), bean.getStatus().toString()); assertEquals(query.getParameterValue("data"), bean.getDataBlob()); assertEquals(query.getParameterValue("pending"), bean.getPending()); assertEquals(query.getParameterValue("retries"), bean.getRetries()); assertEquals(query.getParameterValue("endTime"), bean.getEndTimestamp()); assertEquals(query.getParameterValue("status"), bean.getStatus().toString()); assertEquals(query.getParameterValue("retries"), bean.getRetries()); assertEquals(query.getParameterValue("pending"), bean.getPending());
"ERR_OUTPUT_EXCEED_MAX_LEN", "unknown error"); context.setExecutionData(status.toString(), PropertiesUtils.stringToProperties(outBuffer.toString())); LOG.trace("Execution data set. status={0}, properties={1}", status, PropertiesUtils.stringToProperties(outBuffer.toString())); context.setExecutionData(status.toString(), null); if (status == Status.ERROR) { LOG.warn("Execution data set to null in ERROR"); context.setExecutionData(status.toString(), null); context.setExternalStatus(status.toString());
"ERR_OUTPUT_EXCEED_MAX_LEN", "unknown error"); context.setExecutionData(status.toString(), PropertiesUtils.stringToProperties(outBuffer.toString())); LOG.trace("Execution data set. status={0}, properties={1}", status, PropertiesUtils.stringToProperties(outBuffer.toString())); context.setExecutionData(status.toString(), null); if (status == Status.ERROR) { LOG.warn("Execution data set to null in ERROR"); context.setExecutionData(status.toString(), null); context.setExternalStatus(status.toString());
.writeStringValue("Name : ", action.getName()) .writeStringValue("Type : ", action.getType()) .writeStringValue("Status : ", action.getStatus().toString()) .writeStringValue("Transition : ", action.getTransition()) .writeDateValue("Start Time : ", action.getStartTime())
signalValue = status.toString();
/** * Takes care of errors. <p> For errors while attempting to start the action, the job state is updated and an * {@link ActionEndXCommand} is queued. <p> For errors while attempting to end the action, the job state is updated. * <p> * * @param context the execution context. * @param executor the executor instance being used. * @param message * @param isStart whether the error was generated while starting or ending an action. * @param status the status to be set for the action. * @throws CommandException thrown if unable to handle action error */ protected void handleError(ActionExecutor.Context context, ActionExecutor executor, String message, boolean isStart, WorkflowAction.Status status) throws CommandException { LOG.warn("Setting Action Status to [{0}]", status); ActionExecutorContext aContext = (ActionExecutorContext) context; WorkflowActionBean action = (WorkflowActionBean) aContext.getAction(); if (!handleUserRetry(context, action)) { incrActionErrorCounter(action.getType(), "error", 1); action.setPending(); if (isStart) { action.setExecutionData(message, null); queue(new ActionEndXCommand(action.getId(), action.getType())); } else { action.setEndData(status, WorkflowAction.Status.ERROR.toString()); } } }
/** * End action execution. * * @param context action execution context. * @param action action object. * @throws ActionExecutorException thrown if action end execution fails. */ public void end(final Context context, final WorkflowAction action) throws ActionExecutorException { if (action.getExternalStatus().equals("OK")) { context.setEndData(WorkflowAction.Status.OK, WorkflowAction.Status.OK.toString()); } else { context.setEndData(WorkflowAction.Status.ERROR, WorkflowAction.Status.ERROR.toString()); } boolean deleteTmpDir = ConfigurationService.getBoolean(DELETE_TMP_DIR); if (deleteTmpDir) { String tmpDir = getRemoteFileName(context, action, null, true, false); String removeTmpDirCmd = SSH_COMMAND_BASE + action.getTrackerUri() + " rm -rf " + tmpDir; int retVal = getReturnValue(removeTmpDirCmd); if (retVal != 0) { XLog.getLog(getClass()).warn("Cannot delete temp dir {0}", tmpDir); } } LOG.info("Action ended with external status [{0}]", action.getExternalStatus()); }
/** * End action execution. * * @param context action execution context. * @param action action object. * @throws ActionExecutorException thrown if action end execution fails. */ public void end(final Context context, final WorkflowAction action) throws ActionExecutorException { if (action.getExternalStatus().equals("OK")) { context.setEndData(WorkflowAction.Status.OK, WorkflowAction.Status.OK.toString()); } else { context.setEndData(WorkflowAction.Status.ERROR, WorkflowAction.Status.ERROR.toString()); } boolean deleteTmpDir = ConfigurationService.getBoolean(DELETE_TMP_DIR); if (deleteTmpDir) { String tmpDir = getRemoteFileName(context, action, null, true, false); String removeTmpDirCmd = SSH_COMMAND_BASE + action.getTrackerUri() + " rm -rf " + tmpDir; int retVal = getReturnValue(removeTmpDirCmd); if (retVal != 0) { XLog.getLog(getClass()).warn("Cannot delete temp dir {0}", tmpDir); } } LOG.info("Action ended with external status [{0}]", action.getExternalStatus()); }
/** * Takes care of errors. <p> For errors while attempting to start the action, the job state is updated and an * {@link ActionEndXCommand} is queued. <p> For errors while attempting to end the action, the job state is updated. * <p> * * @param context the execution context. * @param executor the executor instance being used. * @param message * @param isStart whether the error was generated while starting or ending an action. * @param status the status to be set for the action. * @throws CommandException thrown if unable to handle action error */ protected void handleError(ActionExecutor.Context context, ActionExecutor executor, String message, boolean isStart, WorkflowAction.Status status) throws CommandException { LOG.warn("Setting Action Status to [{0}]", status); ActionExecutorContext aContext = (ActionExecutorContext) context; WorkflowActionBean action = (WorkflowActionBean) aContext.getAction(); if (!handleUserRetry(context, action)) { incrActionErrorCounter(action.getType(), "error", 1); action.setPending(); if (isStart) { action.setExecutionData(message, null); queue(new ActionEndXCommand(action.getId(), action.getType())); } else { action.setEndData(status, WorkflowAction.Status.ERROR.toString()); } } }
/** * Set the completion information for an action end. * * @param status action status, {@link org.apache.oozie.client.WorkflowAction.Status#OK} or * {@link org.apache.oozie.client.WorkflowAction.Status#ERROR} or * {@link org.apache.oozie.client.WorkflowAction.Status#KILLED} * @param signalValue the signal value. In most cases, the value should be * OK or ERROR. */ public void setEndData(Status status, String signalValue) { if (status == null || (status != Status.OK && status != Status.ERROR && status != Status.KILLED)) { throw new IllegalArgumentException("Action status must be OK, ERROR or KILLED. Received [" + (status == null ? "null" : status.toString()) + "]"); } if (status == Status.OK) { setErrorInfo(null, null); } setStatus(status); setSignalValue(ParamChecker.notEmpty(signalValue, "signalValue")); }
public WorkflowNotificationXCommand(WorkflowJobBean workflow, WorkflowActionBean action) { super("action.notification", "job.notification", 0); ParamChecker.notNull(workflow, "workflow"); ParamChecker.notNull(action, "action"); jobId = action.getId(); url = workflow.getWorkflowInstance().getConf().get(OozieClient.ACTION_NOTIFICATION_URL); if (url != null) { url = url.replaceAll(JOB_ID_PATTERN, workflow.getId()); url = url.replaceAll(NODE_NAME_PATTERN, action.getName()); if (action.isComplete()) { url = url.replaceAll(STATUS_PATTERN, "T:" + action.getTransition()); } else { url = url.replaceAll(STATUS_PATTERN, "S:" + action.getStatus().toString()); } proxyConf = workflow.getWorkflowInstance().getConf() .get(OozieClient.WORKFLOW_NOTIFICATION_PROXY, ConfigurationService.get(NOTIFICATION_PROXY_KEY)); LOG.debug("Proxy :" + proxyConf); } }
/** * Set the completion information for an action end. * * @param status action status, {@link org.apache.oozie.client.WorkflowAction.Status#OK} or * {@link org.apache.oozie.client.WorkflowAction.Status#ERROR} or * {@link org.apache.oozie.client.WorkflowAction.Status#KILLED} * @param signalValue the signal value. In most cases, the value should be * OK or ERROR. */ public void setEndData(Status status, String signalValue) { if (status == null || (status != Status.OK && status != Status.ERROR && status != Status.KILLED)) { throw new IllegalArgumentException("Action status must be OK, ERROR or KILLED. Received [" + (status == null ? "null" : status.toString()) + "]"); } if (status == Status.OK) { setErrorInfo(null, null); } setStatus(status); setSignalValue(ParamChecker.notEmpty(signalValue, "signalValue")); }
@Override public void onWorkflowActionEvent(WorkflowActionEvent event) { sendEventToSLAService(event, event.getStatus().toString()); }
/** * Set status of job * * @param val the status */ public void setStatus(Status val) { this.statusStr = StringUtils.intern(val.toString()); }
@Override public void onWorkflowActionEvent(WorkflowActionEvent event) { sendEventToSLAService(event, event.getStatus().toString()); }
public boolean evaluate() throws Exception { List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor); WorkflowActionBean action = null; for (WorkflowActionBean bean : actions) { if (bean.getName().contains("hadoop")) { action = bean; break; } } return action.getStatus().toString().equalsIgnoreCase(Job.Status.RUNNING.toString()); } });
/** * Set status of job * * @param val the status */ public void setStatus(Status val) { this.statusStr = StringUtils.intern(val.toString()); }