Search in sources :

Example 11 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class ForTestWorkflowStoreService method create.

public WorkflowStore create() throws StoreException {
    final WorkflowStore wfs = super.create();
    return new WorkflowStore() {

        public void insertWorkflow(WorkflowJobBean workflow) throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        public WorkflowJobBean getWorkflow(String id, boolean locking) throws StoreException {
            WorkflowJobBean wf = new WorkflowJobBean();
            wf.setId(id);
            wf.setUser("u");
            wf.setGroup("g");
            return wf;
        }

        public WorkflowJobBean getWorkflowInfo(String id) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return null;
        }

        public String getWorkflowIdForExternalId(String extId) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return null;
        }

        public void updateWorkflow(WorkflowJobBean workflow) throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        public int getWorkflowCountWithStatus(String status) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return 0;
        }

        public int getWorkflowCountWithStatusInLastNSeconds(String status, int secs) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return 0;
        }

        public void insertAction(WorkflowActionBean action) throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        public WorkflowActionBean getAction(String id, boolean locking) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return null;
        }

        public void updateAction(WorkflowActionBean action) throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        public void deleteAction(String id) throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        public List<WorkflowActionBean> getActionsForWorkflow(String id, boolean locking) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return null;
        }

        public List<WorkflowActionBean> getPendingActions(long minimumPendingAgeSecs) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return null;
        }

        public List<WorkflowActionBean> getRunningActions(long checkAgeSecs) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return null;
        }

        public WorkflowsInfo getWorkflowsInfo(Map<String, List<String>> filter, int start, int len) throws StoreException {
            // To change body of implemented methods use File | Settings | File Templates.
            return null;
        }

        public void purge(long olderThanDays) throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        public void commit() throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }

        public void close() throws StoreException {
        // To change body of implemented methods use File | Settings | File Templates.
        }
    };
}
Also used : WorkflowStore(org.apache.oozie.store.WorkflowStore) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Map(java.util.Map) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 12 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class TestActionCheckXCommand method _testActionCheckError.

private WorkflowActionBean _testActionCheckError() throws Exception {
    services.get(ActionService.class).registerAndInitExecutor(ErrorCheckActionExecutor.class);
    JPAService jpaService = Services.get().get(JPAService.class);
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    new ActionCheckXCommand(action.getId()).call();
    action = jpaService.execute(wfActionGetCmd);
    return action;
}
Also used : WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) ActionService(org.apache.oozie.service.ActionService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 13 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class TestActionCheckXCommand method testActionCheckTransientDuringMRAction.

public void testActionCheckTransientDuringMRAction() throws Exception {
    // When using YARN, skip this test because it relies on shutting down the job tracker, which isn't used in YARN
    if (createJobConf().get("yarn.resourcemanager.address") != null) {
        return;
    }
    services.destroy();
    // Make the max number of retries lower so the test won't take as long
    final int maxRetries = 2;
    setSystemProperty("oozie.action.retries.max", Integer.toString(maxRetries));
    services = new Services();
    // Disable ActionCheckerService so it doesn't interfere by triggering any extra ActionCheckXCommands
    setClassesToBeExcluded(services.getConf(), new String[] { "org.apache.oozie.service.ActionCheckerService" });
    services.init();
    final JPAService jpaService = Services.get().get(JPAService.class);
    WorkflowJobBean job0 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    final String jobId = job0.getId();
    WorkflowActionBean action0 = this.addRecordToWfActionTable(jobId, "1", WorkflowAction.Status.PREP);
    final String actionId = action0.getId();
    final WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(actionId);
    new ActionStartXCommand(actionId, "map-reduce").call();
    final WorkflowActionBean action1 = jpaService.execute(wfActionGetCmd);
    String originalLauncherId = action1.getExternalId();
    ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(job0, action1, false, false);
    MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
    Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(action1.getConf()));
    String user = conf.get("user.name");
    JobClient jobClient = Services.get().get(HadoopAccessorService.class).createJobClient(user, conf);
    final RunningJob launcherJob = jobClient.getJob(JobID.forName(originalLauncherId));
    waitFor(120 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return launcherJob.isComplete();
        }
    });
    assertTrue(launcherJob.isSuccessful());
    Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
    assertTrue(LauncherHelper.hasIdSwap(actionData));
    new ActionCheckXCommand(action1.getId()).call();
    WorkflowActionBean action2 = jpaService.execute(wfActionGetCmd);
    String originalMapperId = action2.getExternalChildIDs();
    assertFalse(originalLauncherId.equals(originalMapperId));
    // At this point, the launcher job has finished and the map-reduce action has started (but not finished)
    // Now, shutdown the job tracker to pretend it has gone down during the map-reduce job
    executeWhileJobTrackerIsShutdown(new ShutdownJobTrackerExecutable() {

        @Override
        public void execute() throws Exception {
            assertEquals(0, action1.getRetries());
            new ActionCheckXCommand(actionId).call();
            waitFor(30 * 1000, new Predicate() {

                @Override
                public boolean evaluate() throws Exception {
                    WorkflowActionBean action1a = jpaService.execute(wfActionGetCmd);
                    return (action1a.getRetries() > 0);
                }
            });
            waitFor(180 * 1000, new Predicate() {

                @Override
                public boolean evaluate() throws Exception {
                    WorkflowActionBean action1a = jpaService.execute(wfActionGetCmd);
                    return (action1a.getRetries() == 0);
                }
            });
            WorkflowActionBean action1b = jpaService.execute(wfActionGetCmd);
            assertEquals(0, action1b.getRetries());
            assertEquals("START_MANUAL", action1b.getStatusStr());
            WorkflowJobBean job1 = jpaService.execute(new WorkflowJobGetJPAExecutor(jobId));
            assertEquals("SUSPENDED", job1.getStatusStr());
        // At this point, the action has gotten a transient error, even after maxRetries tries so the workflow has been
        // SUSPENDED
        }
    });
    // Now, lets bring the job tracker back up and resume the workflow (which will restart the current action)
    // It should now continue and finish with SUCCEEDED
    new ResumeXCommand(jobId).call();
    WorkflowJobBean job2 = jpaService.execute(new WorkflowJobGetJPAExecutor(jobId));
    assertEquals("RUNNING", job2.getStatusStr());
    sleep(500);
    new ActionCheckXCommand(actionId).call();
    WorkflowActionBean action3 = jpaService.execute(wfActionGetCmd);
    String launcherId = action3.getExternalId();
    assertFalse(originalLauncherId.equals(launcherId));
    final RunningJob launcherJob2 = jobClient.getJob(JobID.forName(launcherId));
    waitFor(120 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return launcherJob2.isComplete();
        }
    });
    assertTrue(launcherJob2.isSuccessful());
    actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
    assertTrue(LauncherHelper.hasIdSwap(actionData));
    new ActionCheckXCommand(actionId).call();
    WorkflowActionBean action4 = jpaService.execute(wfActionGetCmd);
    String mapperId = action4.getExternalChildIDs();
    assertFalse(originalMapperId.equals(mapperId));
    final RunningJob mrJob = jobClient.getJob(JobID.forName(mapperId));
    waitFor(120 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return mrJob.isComplete();
        }
    });
    assertTrue(mrJob.isSuccessful());
    new ActionCheckXCommand(actionId).call();
    WorkflowActionBean action5 = jpaService.execute(wfActionGetCmd);
    assertEquals("SUCCEEDED", action5.getExternalStatus());
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) Configuration(org.apache.hadoop.conf.Configuration) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) JobClient(org.apache.hadoop.mapred.JobClient) HadoopAccessorService(org.apache.oozie.service.HadoopAccessorService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) Services(org.apache.oozie.service.Services) RunningJob(org.apache.hadoop.mapred.RunningJob) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) MapReduceActionExecutor(org.apache.oozie.action.hadoop.MapReduceActionExecutor) JPAService(org.apache.oozie.service.JPAService) ActionExecutorContext(org.apache.oozie.command.wf.ActionXCommand.ActionExecutorContext)

Example 14 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class TestActionCheckXCommand method testActionCheckErrorUserRetry.

public void testActionCheckErrorUserRetry() throws Exception {
    ConfigurationService.set(LiteWorkflowStoreService.CONF_USER_RETRY_ERROR_CODE_EXT, ErrorCheckActionExecutor.ERROR_CODE);
    WorkflowActionBean action = _testActionCheckError();
    assertEquals(WorkflowAction.Status.USER_RETRY, action.getStatus());
}
Also used : WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 15 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class TestActionErrors method testKillNodeErrorMessage.

/**
 * Provides functionality to test kill node message
 *
 * @throws Exception
 */
public void testKillNodeErrorMessage() throws Exception {
    WorkflowActionBean killAction = _testKillNodeErrorMessage("wf-test-kill-node-message.xml");
    assertEquals("E0729", killAction.getErrorCode());
    assertEquals("[end]", killAction.getErrorMessage());
    assertEquals(WorkflowAction.Status.OK, killAction.getStatus());
}
Also used : WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Aggregations

WorkflowActionBean (org.apache.oozie.WorkflowActionBean)249 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)164 XConfiguration (org.apache.oozie.util.XConfiguration)84 JPAService (org.apache.oozie.service.JPAService)79 Configuration (org.apache.hadoop.conf.Configuration)56 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)51 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)51 Path (org.apache.hadoop.fs.Path)48 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)42 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)32 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)32 ArrayList (java.util.ArrayList)30 Date (java.util.Date)29 Element (org.jdom.Element)29 FileSystem (org.apache.hadoop.fs.FileSystem)25 Writer (java.io.Writer)22 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)21 IOException (java.io.IOException)20 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)18