Examples of WorkflowActionBean


Examples of org.apache.oozie.WorkflowActionBean

        workflow.setConf(wfConf.toXmlString());
        workflow.setAppPath(wfConf.get(OozieClient.APP_PATH));
        workflow.setProtoActionConf(protoConf.toXmlString());
        workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));

        final WorkflowActionBean action = new WorkflowActionBean();
        action.setId("actionId");
        action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" +
                       "<host>localhost</host>" +
                       "<command>echo</command>" +
                       "<capture-output/>" +
                       "<args>\"prop1=something\"</args>" +
                       "</ssh>");
        action.setName("ssh");
        final SshActionExecutor ssh = new SshActionExecutor();
        final Context context = new Context(workflow, action);
        ssh.start(context, action);

        Thread.sleep(200);
        final WorkflowActionBean action1 = new WorkflowActionBean();
        action1.setId("actionId");
        action1.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" +
                       "<host>localhost</host>" +
                       "<command>echo</command>" +
                       "<capture-output/>" +
                       "<args>\"prop1=nothing\"</args>" +
                       "</ssh>");
        action1.setName("ssh");
        final SshActionExecutor ssh1 = new SshActionExecutor();
        final Context context1 = new Context(workflow, action1);
        Thread.sleep(500);
        ssh1.start(context1, action1);
        assertEquals(action1.getExternalId(), action.getExternalId());

        waitFor(30 * 1000, new Predicate() {
            public boolean evaluate() throws Exception {
                ssh.check(context1, action1);
                return Status.DONE == action1.getStatus();
            }
        });
        ssh1.end(context1, action1);
        assertEquals(Status.OK, action1.getStatus());
        assertEquals("something", PropertiesUtils.stringToProperties(action1.getData()).getProperty("prop1"));
    }
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

        workflow.setConf(wfConf.toXmlString());
        workflow.setAppPath(wfConf.get(OozieClient.APP_PATH));
        workflow.setProtoActionConf(protoConf.toXmlString());
        workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));

        final WorkflowActionBean action = new WorkflowActionBean();
        action.setId("actionId");
        action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" +
                "<host>blabla</host>" +
                "<command>echo</command>" +
                "<args>\"prop1=something\"</args>" +
                "</ssh>");
        action.setName("ssh");
        final SshActionExecutor ssh = new SshActionExecutor();
        final Context context = new Context(workflow, action);
        try {
            ssh.start(context, action);
        }
        catch (ActionExecutorException ex) {
            System.out.println("Testing COULD_NOT_RESOLVE_HOST");

            assertEquals("COULD_NOT_RESOLVE_HOST", ex.getErrorCode());
            assertEquals(ActionExecutorException.ErrorType.TRANSIENT, ex.getErrorType());
        }
        action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" +
                "<host>11.11.11.11</host>" +
                "<command>echo</command>" +
                "<args>\"prop1=something\"</args>" +
                "</ssh>");
        try {
            ssh.start(context, action);
        }
        catch (ActionExecutorException ex) {
            System.out.println("Testing COULD_NOT_CONNECT");

            assertEquals("COULD_NOT_CONNECT", ex.getErrorCode());
            assertEquals(ActionExecutorException.ErrorType.TRANSIENT, ex.getErrorType());
        }
        action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" +
                "<host>y@localhost</host>" +
                "<command>echo</command>" +
                "<args>\"prop1=something\"</args>" +
                "</ssh>");
        try {
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

        wfApp.addNode(new EndNodeDef("a"));
        WorkflowInstance wi = new LiteWorkflowInstance(wfApp, new XConfiguration(), "1");

        workflow.setWorkflowInstance(wi);
        workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));
        final WorkflowActionBean action = new WorkflowActionBean();
        action.setName("H");

        ActionXCommand.ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(workflow, action, false, false);
        context.setVar(MapReduceActionExecutor.HADOOP_COUNTERS, counters);

        ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("workflow");
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

        wfApp.addNode(new EndNodeDef("a"));
        WorkflowInstance wi = new LiteWorkflowInstance(wfApp, new XConfiguration(), "1");

        workflow.setWorkflowInstance(wi);
        workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));
        final WorkflowActionBean action = new WorkflowActionBean();
        action.setName("H");

        ActionXCommand.ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(workflow, action, false, false);
        context.setVar(MapReduceActionExecutor.HADOOP_COUNTERS, pigStats);

        ELEvaluator eval = Services.get().get(ELService.class).createEvaluator("workflow");
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

        assertEquals(wfBean1.getId(), id);
        store.commitTrx();
    }

    private void _testSaveAction() throws StoreException, SQLException {
        WorkflowActionBean a11 = new WorkflowActionBean();
        store.beginTrx();
        StringBuilder str = new StringBuilder();
        str.append(System.currentTimeMillis());
        str.append("11");
        this.actionId = str.toString();
        a11.setId(actionId);
        a11.setJobId(wfBean1.getId());
        a11.setName("a11");
        a11.setStatus(WorkflowAction.Status.PREP);
        store.insertAction(a11);
        store.commitTrx();
/*
* WorkflowActionBean a12 = new WorkflowActionBean(); store.beginTrx();
* a12.setId("12"); a12.setName("a12"); a12.setJobId(wfBean1.getId());
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

*/
    }

    private void _testLoadAction() throws StoreException {
        store.beginTrx();
        WorkflowActionBean a11 = store.getAction(actionId, false);
        assertEquals(a11.getId(), actionId);
        assertEquals(a11.getJobId(), wfBean1.getId());
        assertEquals(a11.getStatus(), WorkflowAction.Status.PREP);
        store.commitTrx();
    }
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

        assertEquals(a11.getStatus(), WorkflowAction.Status.PREP);
        store.commitTrx();
    }

    private void _testUpdateAction() throws StoreException {
        WorkflowActionBean a11 = store.getAction(actionId, false);
        a11.setStatus(WorkflowAction.Status.OK);
        a11.setPending();
        a11.setPendingAge(new Date(System.currentTimeMillis() - 10000));
        store.beginTrx();
        store.updateAction(a11);
        store.getEntityManager().flush();
        store.getEntityManager().merge(a11);
        store.commitTrx();
        WorkflowActionBean a = store.getAction(a11.getId(), false);
        assertEquals(a.getId(), a11.getId());
        assertEquals(a.getStatus(), WorkflowAction.Status.OK);
    }
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

        store.insertWorkflow(wfBean3);
        store.updateWorkflow(wfBean2);
        store.updateWorkflow(wfBean1);
        store.commitTrx();
        WorkflowActionBean a31 = new WorkflowActionBean();
        StringBuilder str = new StringBuilder();
        str.append(System.currentTimeMillis());
        str.append("31");
        a31.setId(str.toString());
        a31.setJobId(wfBean3.getId());
        a31.setStatus(WorkflowAction.Status.PREP);
        a31.setCred("null");
        store.beginTrx();
        store.insertAction(a31);
        store.commitTrx();
        store.beginTrx();
        store.purge(30, 10000);
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

     */
    protected boolean handleTransient(ActionExecutor.Context context, ActionExecutor executor,
            WorkflowAction.Status status) throws CommandException {
        LOG.debug("Attempting to retry");
        ActionExecutorContext aContext = (ActionExecutorContext) context;
        WorkflowActionBean action = (WorkflowActionBean) aContext.getAction();
        incrActionErrorCounter(action.getType(), "transient", 1);

        int actionRetryCount = action.getRetries();
        if (actionRetryCount >= executor.getMaxRetries()) {
            LOG.warn("Exceeded max retry count [{0}]. Suspending Job", executor.getMaxRetries());
            return false;
        }
        else {
            action.setStatus(status);
            action.setPending();
            action.incRetries();
            long retryDelayMillis = executor.getRetryInterval() * 1000;
            action.setPendingAge(new Date(System.currentTimeMillis() + retryDelayMillis));
            LOG.info("Next Retry, Attempt Number [{0}] in [{1}] milliseconds", actionRetryCount + 1, retryDelayMillis);
            this.resetUsed();
            queue(this, retryDelayMillis);
            return true;
        }
View Full Code Here

Examples of org.apache.oozie.WorkflowActionBean

     * @throws CommandException thrown if unable to suspend job
     */
    protected void handleNonTransient(ActionExecutor.Context context, ActionExecutor executor,
            WorkflowAction.Status status) throws CommandException {
        ActionExecutorContext aContext = (ActionExecutorContext) context;
        WorkflowActionBean action = (WorkflowActionBean) aContext.getAction();
        incrActionErrorCounter(action.getType(), "nontransient", 1);
        WorkflowJobBean workflow = (WorkflowJobBean) context.getWorkflow();
        String id = workflow.getId();
        action.setStatus(status);
        action.resetPendingOnly();
        LOG.warn("Suspending Workflow Job id=" + id);
        try {
            SuspendXCommand.suspendJob(Services.get().get(JPAService.class), workflow, id, action.getId());
        }
        catch (Exception e) {
            throw new CommandException(ErrorCode.E0727, e.getMessage());
        }
        finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.