Package org.apache.oozie.action

Examples of org.apache.oozie.action.ActionExecutor


    }

    public void testDecision() throws Exception {
        new Services().init();
        try {
            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


                    insertList.add(newAction);
                    LOG.debug("SignalXCommand: Name: " + newAction.getName() + ", Id: " + newAction.getId()
                            + ", Authcode:" + newAction.getCred());
                    if (wfAction != null) { // null during wf job submit
                        ActionService as = Services.get().get(ActionService.class);
                        ActionExecutor current = as.getExecutor(wfAction.getType());
                        LOG.trace("Current Action Type:" + current.getClass());
                        if (!suspendNewAction) {
                            if (!(current instanceof ForkActionExecutor) && !(current instanceof StartActionExecutor)) {
                                // Excluding :start: here from executing first action synchronously since it
                                // blocks the consumer thread till the action is submitted to Hadoop,
                                // in turn reducing the number of new submissions the threads can accept.
View Full Code Here

    public Class<? extends Service> getInterface() {
        return ActionService.class;
    }

    public void register(Class<? extends ActionExecutor> klass) throws ServiceException {
        ActionExecutor executor = (ActionExecutor) ReflectionUtils.newInstance(klass, services.getConf());
        LOG.trace("Registering action type [{0}] class [{1}]", executor.getType(), klass);
        if (executors.containsKey(executor.getType())) {
            throw new ServiceException(ErrorCode.E0150, 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

     *
     * @see org.apache.oozie.command.XCommand#execute()
     */
    @Override
    protected Void execute() throws CommandException {
        ActionExecutor executor = Services.get().get(ActionService.class).getExecutor(this.wfactionBean.getType());
        // this is done because oozie notifications (of sub-wfs) is send
        // every status change, not only on completion.
        if (executor.isCompleted(externalStatus)) {
            queue(new ActionCheckXCommand(this.wfactionBean.getId(), getPriority(), -1));
        }
        return null;
    }
View Full Code Here

        List<Class> classes = JavaActionExecutor.getCommonLauncherClasses();
        Path baseDir = new Path(tmpLauncherLibPath, JavaActionExecutor.OOZIE_COMMON_LIBDIR);
        copyJarContainingClasses(classes, fs, baseDir, JavaActionExecutor.OOZIE_COMMON_LIBDIR);
        Set<String> actionTypes = actionService.getActionTypes();
        for (String key : actionTypes) {
            ActionExecutor executor = actionService.getExecutor(key);
            if (executor instanceof JavaActionExecutor) {
                JavaActionExecutor jexecutor = (JavaActionExecutor) executor;
                classes = jexecutor.getLauncherClasses();
                if (classes != null) {
                    String type = executor.getType();
                    Path executorDir = new Path(tmpLauncherLibPath, type);
                    copyJarContainingClasses(classes, fs, executorDir, type);
                }
            }
        }
View Full Code Here

            catch (JDOMException e) {
                throw new WorkflowException(ErrorCode.E0700, "Error while processing action conf");
            }
        }
        else {
            ActionExecutor ae = Services.get().get(ActionService.class).getExecutor(eActionConf.getName());
            if (ae == null) {
                throw new WorkflowException(ErrorCode.E0723, eActionConf.getName(), ActionService.class.getName());
            }
            if (ae.requiresNNJT) {
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

            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

TOP

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

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.