Package org.apache.oozie.action

Examples of org.apache.oozie.action.ActionExecutor$Context


        return ActionService.class;
    }

    public void register(Class<? extends ActionExecutor> klass) throws ServiceException {
        XLog log = XLog.getLog(getClass());
        ActionExecutor executor = (ActionExecutor) ReflectionUtils.newInstance(klass, services.getConf());
        if (executors.containsKey(executor.getType())) {
            throw new ServiceException(ErrorCode.E0150, XLog.format(
                    "Action executor for action type [{1}] already registered", executor.getType()));
        }
        ActionExecutor.enableInit();
        executor.initActionType();
        ActionExecutor.disableInit();
        executors.put(executor.getType(), klass);
        log.trace("Registered Action executor for action type [{0}] class [{1}]", executor.getType(), klass);
    }
View Full Code Here


        if (action.isPending()
                && (action.getStatus() == WorkflowActionBean.Status.DONE
                || action.getStatus() == WorkflowActionBean.Status.END_RETRY || action.getStatus() == WorkflowActionBean.Status.END_MANUAL)) {
            if (workflow.getStatus() == WorkflowJob.Status.RUNNING) {

                ActionExecutor executor = Services.get().get(ActionService.class).getExecutor(action.getType());
                Configuration conf = workflow.getWorkflowInstance().getConf();
                int maxRetries = conf.getInt(OozieClient.ACTION_MAX_RETRIES, executor.getMaxRetries());
                long retryInterval = conf.getLong(OozieClient.ACTION_RETRY_INTERVAL, executor.getRetryInterval());
                executor.setMaxRetries(maxRetries);
                executor.setRetryInterval(retryInterval);

                if (executor != null) {
                    boolean isRetry = false;
                    if (action.getStatus() == WorkflowActionBean.Status.END_RETRY
                            || action.getStatus() == WorkflowActionBean.Status.END_MANUAL) {
                        isRetry = true;
                    }
                    ActionExecutorContext context = new ActionCommand.ActionExecutorContext(workflow, action, isRetry);
                    try {

                        XLog.getLog(getClass()).debug(
                                "End, name [{0}] type [{1}] status[{2}] external status [{3}] signal value [{4}]",
                                action.getName(), action.getType(), action.getStatus(), action.getExternalStatus(),
                                action.getSignalValue());

                        Instrumentation.Cron cron = new Instrumentation.Cron();
                        cron.start();
                        executor.end(context, action);
                        cron.stop();
                        addActionCron(action.getType(), cron);

                        WorkflowInstance wfInstance = workflow.getWorkflowInstance();
                        DagELFunctions.setActionInfo(wfInstance, action);
                        workflow.setWorkflowInstance(wfInstance);
                        incrActionCounter(action.getType(), 1);

                        if (!context.isEnded()) {
                            XLog.getLog(getClass()).warn(XLog.OPS,
                                                         "Action Ended, ActionExecutor [{0}] must call setEndData()", executor.getType());
                            action.setErrorInfo(END_DATA_MISSING, "Execution Ended, but End Data Missing from Action");
                            failJob(context);
                            store.updateAction(action);
                            store.updateWorkflow(workflow);
                            return null;
View Full Code Here

            action.setErrorInfo(str, exMsg);
        }
    }

    public void testDecision() throws Exception {
        ActionExecutor decision = new DecisionActionExecutor();

        assertEquals(DecisionActionExecutor.ACTION_TYPE, decision.getType());

        WorkflowActionBean action = new WorkflowActionBean();
        action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" +
                "<case to='a'>true</case>" +
                "<case to='b'>true</case>" +
                "<case to='c'>false</case>" +
                "<default to='d'/></switch>");

        decision.start(new Context(action), action);
        assertEquals(WorkflowAction.Status.DONE, action.getStatus());
        decision.end(new Context(action), action);
        assertEquals(WorkflowAction.Status.OK, action.getStatus());
        assertEquals("a", action.getExternalStatus());

        action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" +
                "<case to='a'>false</case>" +
                "<case to='b'>true</case>" +
                "<case to='c'>false</case>" +
                "<default to='d'/></switch>");

        decision.start(new Context(action), action);
        assertEquals(WorkflowAction.Status.DONE, action.getStatus());
        decision.end(new Context(action), action);
        assertEquals(WorkflowAction.Status.OK, action.getStatus());
        assertEquals("b", action.getExternalStatus());


        action.setConf("<switch xmlns='uri:oozie:workflow:0.1'>" +
                "<case to='a'>false</case>" +
                "<case to='b'>false</case>" +
                "<case to='c'>false</case>" +
                "<default to='d'/></switch>");

        decision.start(new Context(action), action);
        assertEquals(WorkflowAction.Status.DONE, action.getStatus());
        decision.end(new Context(action), action);
        assertEquals(WorkflowAction.Status.OK, action.getStatus());
        assertEquals("d", action.getExternalStatus());

        try {
            action.setConf("<wrong>" +
                    "<case to='a'>false</case>" +
                    "<case to='b'>false</case>" +
                    "<case to='c'>false</case>" +
                    "<default to='d'/></switch>");

            decision.start(new Context(action), action);
            fail();
        }
        catch (ActionExecutorException ex) {
            assertEquals(ActionExecutorException.ErrorType.FAILED, ex.getErrorType());
            assertEquals(DecisionActionExecutor.XML_ERROR, ex.getErrorCode());
View Full Code Here

    @Override
    protected Void execute() throws CommandException {
        LOG.debug("STARTED WorkflowActionKillXCommand for action " + actionId);

        if (wfAction.isPending()) {
            ActionExecutor executor = Services.get().get(ActionService.class).getExecutor(wfAction.getType());
            if (executor != null) {
                try {
                    boolean isRetry = false;
                    boolean isUserRetry = false;
                    ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(wfJob, wfAction,
                            isRetry, isUserRetry);
                    incrActionCounter(wfAction.getType(), 1);

                    Instrumentation.Cron cron = new Instrumentation.Cron();
                    cron.start();
                    executor.kill(context, wfAction);
                    cron.stop();
                    addActionCron(wfAction.getType(), cron);

                    wfAction.resetPending();
                    wfAction.setStatus(WorkflowActionBean.Status.KILLED);
View Full Code Here

        if (action.isPending()
                && (action.getStatus() == WorkflowActionBean.Status.DONE
                || action.getStatus() == WorkflowActionBean.Status.END_RETRY || action.getStatus() == WorkflowActionBean.Status.END_MANUAL)) {
            if (workflow.getStatus() == WorkflowJob.Status.RUNNING) {

                ActionExecutor executor = Services.get().get(ActionService.class).getExecutor(action.getType());
                Configuration conf = workflow.getWorkflowInstance().getConf();
                int maxRetries = conf.getInt(OozieClient.ACTION_MAX_RETRIES, executor.getMaxRetries());
                long retryInterval = conf.getLong(OozieClient.ACTION_RETRY_INTERVAL, executor.getRetryInterval());
                executor.setMaxRetries(maxRetries);
                executor.setRetryInterval(retryInterval);

                if (executor != null) {
                    boolean isRetry = false;
                    if (action.getStatus() == WorkflowActionBean.Status.END_RETRY
                            || action.getStatus() == WorkflowActionBean.Status.END_MANUAL) {
                        isRetry = true;
                    }
                    ActionExecutorContext context = new ActionCommand.ActionExecutorContext(workflow, action, isRetry);
                    try {

                        XLog.getLog(getClass()).debug(
                                "End, name [{0}] type [{1}] status[{2}] external status [{3}] signal value [{4}]",
                                action.getName(), action.getType(), action.getStatus(), action.getExternalStatus(),
                                action.getSignalValue());

                        Instrumentation.Cron cron = new Instrumentation.Cron();
                        cron.start();
                        executor.end(context, action);
                        cron.stop();
                        addActionCron(action.getType(), cron);

                        WorkflowInstance wfInstance = workflow.getWorkflowInstance();
                        DagELFunctions.setActionInfo(wfInstance, action);
                        workflow.setWorkflowInstance(wfInstance);
                        incrActionCounter(action.getType(), 1);

                        if (!context.isEnded()) {
                            XLog.getLog(getClass()).warn(XLog.OPS,
                                                         "Action Ended, ActionExecutor [{0}] must call setEndData()", executor.getType());
                            action.setErrorInfo(END_DATA_MISSING, "Execution Ended, but End Data Missing from Action");
                            failJob(context);
                            store.updateAction(action);
                            store.updateWorkflow(workflow);
                            return null;
View Full Code Here

            public boolean evaluate() throws Exception {
                return runningJob.isComplete();
            }
        });
        assertTrue(runningJob.isSuccessful());
        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());
    }
View Full Code Here

            public boolean evaluate() throws Exception {
                return runningJob.isComplete();
            }
        });
        assertTrue(runningJob.isSuccessful());
        ActionExecutor ae = new JavaActionExecutor();
        ae.check(context, context.getAction());
        assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
        assertNotNull(context.getAction().getData());
        StringReader sr = new StringReader(context.getAction().getData());
        Properties props = new Properties();
        props.load(sr);
        assertEquals("A", props.get("a"));

        ae.end(context, context.getAction());
        assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
    }
View Full Code Here

            public boolean evaluate() throws Exception {
                return runningJob.isComplete();
            }
        });
        assertTrue(runningJob.isSuccessful());
        ActionExecutor ae = new JavaActionExecutor();
        try {
            ae.check(context, context.getAction());
        }
        catch (ActionExecutorException ex) {
            if (!ex.getMessage().contains("IDSWAP")) {
                fail();
            }
View Full Code Here

                "<file>" + appJarPath.toString() + "</file>" +
                "</java>";

        Context context = createContext(actionXml);
        final RunningJob runningJob = submitAction(context);
        ActionExecutor ae = new JavaActionExecutor();
        assertFalse(ae.isCompleted(context.getAction().getExternalStatus()));
        waitFor(60 * 1000, new Predicate() {
            public boolean evaluate() throws Exception {
                return runningJob.isComplete();
            }
        });
        assertTrue(runningJob.isSuccessful());
        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());
    }
View Full Code Here

        if (action.isPending()
                && (action.getStatus() == WorkflowActionBean.Status.PREP
                || action.getStatus() == WorkflowActionBean.Status.START_RETRY || action.getStatus() == WorkflowActionBean.Status.START_MANUAL)) {
            if (workflow.getStatus() == WorkflowJob.Status.RUNNING) {

                ActionExecutor executor = Services.get().get(ActionService.class).getExecutor(action.getType());
                Configuration conf = workflow.getWorkflowInstance().getConf();

                int maxRetries = conf.getInt(OozieClient.ACTION_MAX_RETRIES, executor.getMaxRetries());
                long retryInterval = conf.getLong(OozieClient.ACTION_RETRY_INTERVAL, executor.getRetryInterval());
                executor.setMaxRetries(maxRetries);
                executor.setRetryInterval(retryInterval);

                if (executor != null) {
                    ActionExecutorContext context = null;
                    try {
                        boolean isRetry = false;
                        if (action.getStatus() == WorkflowActionBean.Status.START_RETRY
                                || action.getStatus() == WorkflowActionBean.Status.START_MANUAL) {
                            isRetry = true;
                        }
                        context = new ActionCommand.ActionExecutorContext(workflow, action, isRetry);
                        try {
                            String tmpActionConf = XmlUtils.removeComments(action.getConf());
                            String actionConf = context.getELEvaluator().evaluate(tmpActionConf, String.class);
                            action.setConf(actionConf);

                            XLog.getLog(getClass()).debug("Start, name [{0}] type [{1}] configuration{E}{E}{2}{E}",
                                                          action.getName(), action.getType(), actionConf);

                        }
                        catch (ELEvaluationException ex) {
                            throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT,
                                                              EL_EVAL_ERROR, ex.getMessage(), ex);
                        }
                        catch (ELException ex) {
                            context.setErrorInfo(EL_ERROR, ex.getMessage());
                            XLog.getLog(getClass()).warn("ELException in ActionStartCommand ", ex.getMessage(), ex);
                            handleError(context, store, workflow, action);
                            return null;
                        }
                        catch (org.jdom.JDOMException je) {
                            context.setErrorInfo("ParsingError", je.getMessage());
                            XLog.getLog(getClass()).warn("JDOMException in ActionStartCommand ", je.getMessage(), je);
                            handleError(context, store, workflow, action);
                            return null;
                        }
                        catch (Exception ex) {
                            context.setErrorInfo(EL_ERROR, ex.getMessage());
                            XLog.getLog(getClass()).warn("Exception in ActionStartCommand ", ex.getMessage(), ex);
                            handleError(context, store, workflow, action);
                            return null;
                        }
                        action.setErrorInfo(null, null);
                        incrActionCounter(action.getType(), 1);

                        Instrumentation.Cron cron = new Instrumentation.Cron();
                        cron.start();
                        executor.start(context, action);
                        cron.stop();
                        FaultInjection.activate("org.apache.oozie.command.SkipCommitFaultInjection");
                        addActionCron(action.getType(), cron);

                        action.setRetries(0);
                        if (action.isExecutionComplete()) {
                            if (!context.isExecuted()) {
                                XLog.getLog(getClass()).warn(XLog.OPS,
                                                             "Action Completed, ActionExecutor [{0}] must call setExecutionData()",
                                                             executor.getType());
                                action.setErrorInfo(EXEC_DATA_MISSING,
                                                    "Execution Complete, but Execution Data Missing from Action");
                                failJob(context);
                                store.updateAction(action);
                                store.updateWorkflow(workflow);
                                return null;
                            }
                            action.setPending();
                            queueCallable(new ActionEndCommand(action.getId(), action.getType()));
                        }
                        else {
                            if (!context.isStarted()) {
                                XLog.getLog(getClass()).warn(XLog.OPS,
                                                             "Action Started, ActionExecutor [{0}] must call setStartData()",
                                                             executor.getType());
                                action.setErrorInfo(START_DATA_MISSING,
                                                    "Execution Started, but Start Data Missing from Action");
                                failJob(context);
                                store.updateAction(action);
                                store.updateWorkflow(workflow);
View Full Code Here

TOP

Related Classes of org.apache.oozie.action.ActionExecutor$Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.