Search in sources :

Example 21 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestActionStartXCommand method testActionReuseWfJobAppPath.

public void testActionReuseWfJobAppPath() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    WorkflowJobBean job = this.addRecordToWfJobTableWithCustomAppPath(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTableWithAppPathConfig(job.getId(), "1", WorkflowAction.Status.PREP);
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    new ActionStartXCommand(action.getId(), "map-reduce").call();
    action = jpaService.execute(wfActionGetCmd);
    assertNotNull(action.getExternalId());
    Element actionXml = XmlUtils.parseXml(action.getConf());
    Namespace ns = actionXml.getNamespace();
    Element configElem = actionXml.getChild("configuration", ns);
    String strConf = XmlUtils.prettyPrint(configElem).toString();
    XConfiguration inlineConf = new XConfiguration(new StringReader(strConf));
    String workDir = inlineConf.get("work.dir", null);
    assertNotNull(workDir);
    assertFalse(workDir.contains("workflow.xml"));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom.Element) StringReader(java.io.StringReader) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Namespace(org.jdom.Namespace)

Example 22 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestActionStartXCommand method addRecordToWfActionTableWithAppPathConfig.

/**
 * Create workflow action with custom action configuration
 *
 * @param wfId workflow id
 * @param actionName action name
 * @param status workflow action status
 * @return workflow action bean
 * @throws Exception thrown if failed to create workflow action
 */
protected WorkflowActionBean addRecordToWfActionTableWithAppPathConfig(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
    WorkflowActionBean action = createWorkflowActionWithAppPathConfig(wfId, status);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
        jpaService.execute(actionInsertCmd);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test wf action record to table");
        throw ce;
    }
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 23 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestActionStartXCommand method addRecordToWfJobTableWithCustomAppPath.

/**
 * Create workflow job with custom application path
 *
 * @param jobStatus workflow job status
 * @param instanceStatus workflow instance status
 * @return workflow job bean
 * @throws Exception thrown if failed to create workflow job
 */
protected WorkflowJobBean addRecordToWfJobTableWithCustomAppPath(WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
    WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
    Configuration conf = new Configuration();
    Path appUri = getAppPath();
    conf.set(OozieClient.APP_PATH, appUri.toString());
    conf.set(OozieClient.LOG_TOKEN, "testToken");
    conf.set(OozieClient.USER_NAME, getTestUser());
    WorkflowJobBean wfBean = createWorkflow(app, conf, jobStatus, instanceStatus);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowJobInsertJPAExecutor wfInsertCmd = new WorkflowJobInsertJPAExecutor(wfBean);
        jpaService.execute(wfInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test wf job record to table");
        throw je;
    }
    return wfBean;
}
Also used : WorkflowApp(org.apache.oozie.workflow.WorkflowApp) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) EndNodeDef(org.apache.oozie.workflow.lite.EndNodeDef) Path(org.apache.hadoop.fs.Path) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) WorkflowJobInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) StartNodeDef(org.apache.oozie.workflow.lite.StartNodeDef)

Example 24 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestActionStartXCommand method addRecordToWfActionTableWithFS.

private WorkflowActionBean addRecordToWfActionTableWithFS(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
    WorkflowActionBean action = createWorkflowActionForFS(wfId, status);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
        jpaService.execute(actionInsertCmd);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test wf action record to table");
        throw ce;
    }
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 25 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestActionStartXCommand method addRecordToWfJobTableWithEscapedStringAndCDATA.

/**
 * Create workflow job with action configuration with CDATA section and escaped string as value in parameter.
 *
 * @param jobStatus workflow job status
 * @param instanceStatus workflow instance status
 * @return workflow job bean
 * @throws Exception thrown if failed to create workflow job
 */
private WorkflowJobBean addRecordToWfJobTableWithEscapedStringAndCDATA(WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
    WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
    Configuration conf = new Configuration();
    Path appUri = new Path(getAppPath(), "workflow.xml");
    conf.set(OozieClient.APP_PATH, appUri.toString());
    conf.set(OozieClient.LOG_TOKEN, "testToken");
    conf.set(OozieClient.USER_NAME, getTestUser());
    // The properties should not be escaped here. It will be escaped when set to configuration.
    conf.set("testAmpSign", "http://test.apache.com/a-webservices?urlSigner=signUrl&namespace=nova.proxy");
    conf.set("testCDATA", "<![CDATA[?redirect=http%3A%2F%2Ftest.apache.com%2Fa-webservices%2Fv1%2FurlSigner%2FsignUrl&amp;namespace" + "=nova.proxy&amp;keyDBHash=Vsy6n_C7K6NG0z4R2eBlKg--]]>");
    WorkflowJobBean wfBean = createWorkflow(app, conf, jobStatus, instanceStatus);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowJobInsertJPAExecutor wfInsertCmd = new WorkflowJobInsertJPAExecutor(wfBean);
        jpaService.execute(wfInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test wf job record to table");
    }
    return wfBean;
}
Also used : WorkflowApp(org.apache.oozie.workflow.WorkflowApp) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) EndNodeDef(org.apache.oozie.workflow.lite.EndNodeDef) Path(org.apache.hadoop.fs.Path) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) WorkflowJobInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) StartNodeDef(org.apache.oozie.workflow.lite.StartNodeDef)

Aggregations

JPAService (org.apache.oozie.service.JPAService)449 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)156 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)152 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)113 Date (java.util.Date)95 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)94 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)84 BundleJobBean (org.apache.oozie.BundleJobBean)78 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)78 ArrayList (java.util.ArrayList)76 CommandException (org.apache.oozie.command.CommandException)66 List (java.util.List)59 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)54 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)54 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)49 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)47 HashMap (java.util.HashMap)41 BundleActionBean (org.apache.oozie.BundleActionBean)35 Configuration (org.apache.hadoop.conf.Configuration)32 EntityManager (javax.persistence.EntityManager)31