Search in sources :

Example 1 with LiteWorkflowApp

use of org.apache.oozie.workflow.lite.LiteWorkflowApp in project oozie by apache.

the class TestStatusTransitService method addRecordToWfJobTable.

protected WorkflowJobBean addRecordToWfJobTable(String wfId, 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());
    WorkflowJobBean wfBean = createWorkflow(app, conf, jobStatus, instanceStatus);
    wfBean.setId(wfId);
    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) Configuration(org.apache.hadoop.conf.Configuration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) WorkflowJobInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobInsertJPAExecutor) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) StartNodeDef(org.apache.oozie.workflow.lite.StartNodeDef)

Example 2 with LiteWorkflowApp

use of org.apache.oozie.workflow.lite.LiteWorkflowApp in project oozie by apache.

the class TestLiteWorkflowAppService method testExtSchema.

public void testExtSchema() throws Exception {
    setSystemProperty(SchemaService.WF_CONF_EXT_SCHEMAS, "wf-ext-schema.xsd");
    setSystemProperty("oozie.service.ActionService.executor.ext.classes", TestActionExecutor.class.getName());
    Services services = new Services();
    try {
        services.init();
        Reader reader = IOUtils.getResourceAsReader("wf-ext-schema-valid.xml", -1);
        Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        WorkflowAppService wps = services.get(WorkflowAppService.class);
        Configuration jobConf = new XConfiguration();
        jobConf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
        jobConf.set(OozieClient.USER_NAME, getTestUser());
        LiteWorkflowApp app = (LiteWorkflowApp) wps.parseDef(jobConf);
        assertNotNull(app);
        assertEquals("test-wf", app.getName());
        reader = IOUtils.getResourceAsReader("wf-ext-schema-invalid.xml", -1);
        writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
        IOUtils.copyCharStream(reader, writer);
        try {
            wps.parseDef(jobConf);
            fail();
        } catch (WorkflowException ex) {
        // nop
        }
    } finally {
        services.destroy();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) FileWriter(java.io.FileWriter) WorkflowException(org.apache.oozie.workflow.WorkflowException) Reader(java.io.Reader) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 3 with LiteWorkflowApp

use of org.apache.oozie.workflow.lite.LiteWorkflowApp 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 4 with LiteWorkflowApp

use of org.apache.oozie.workflow.lite.LiteWorkflowApp 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)

Example 5 with LiteWorkflowApp

use of org.apache.oozie.workflow.lite.LiteWorkflowApp in project oozie by apache.

the class TestCoordActionsKillXCommand method createDBRecords.

private String[] createDBRecords() throws Exception {
    JPAService jpaService = services.get(JPAService.class);
    Date startTime = DateUtils.parseDateOozieTZ("2013-08-01T23:59Z");
    Date endTime = DateUtils.parseDateOozieTZ("2013-08-02T23:59Z");
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, true, 0);
    CoordinatorActionBean action1 = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
    CoordinatorActionBean action2 = addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
    action2.setNominalTime(DateUtils.parseDateOozieTZ("2009-12-15T02:00Z"));
    action2.setExternalId(null);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action2);
    WorkflowJobBean wf = new WorkflowJobBean();
    WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
    wf.setId(action1.getExternalId());
    wf.setStatus(WorkflowJob.Status.RUNNING);
    WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
    WorkflowInstance wfInstance = workflowLib.createInstance(app, new XConfiguration());
    ((LiteWorkflowInstance) wfInstance).setStatus(WorkflowInstance.Status.RUNNING);
    wf.setWorkflowInstance(wfInstance);
    jpaService.execute(new WorkflowJobInsertJPAExecutor(wf));
    return new String[] { job.getId(), action1.getId(), action2.getId(), wf.getId() };
}
Also used : WorkflowApp(org.apache.oozie.workflow.WorkflowApp) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) EndNodeDef(org.apache.oozie.workflow.lite.EndNodeDef) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) WorkflowLib(org.apache.oozie.workflow.WorkflowLib) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) WorkflowStoreService(org.apache.oozie.service.WorkflowStoreService) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) LiteWorkflowInstance(org.apache.oozie.workflow.lite.LiteWorkflowInstance) WorkflowJobInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobInsertJPAExecutor) LiteWorkflowInstance(org.apache.oozie.workflow.lite.LiteWorkflowInstance) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) StartNodeDef(org.apache.oozie.workflow.lite.StartNodeDef) XConfiguration(org.apache.oozie.util.XConfiguration) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) JPAService(org.apache.oozie.service.JPAService)

Aggregations

LiteWorkflowApp (org.apache.oozie.workflow.lite.LiteWorkflowApp)25 EndNodeDef (org.apache.oozie.workflow.lite.EndNodeDef)21 StartNodeDef (org.apache.oozie.workflow.lite.StartNodeDef)21 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)20 XConfiguration (org.apache.oozie.util.XConfiguration)17 Configuration (org.apache.hadoop.conf.Configuration)16 LiteWorkflowStoreService (org.apache.oozie.service.LiteWorkflowStoreService)15 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)13 WorkflowApp (org.apache.oozie.workflow.WorkflowApp)13 LiteWorkflowInstance (org.apache.oozie.workflow.lite.LiteWorkflowInstance)10 Path (org.apache.hadoop.fs.Path)9 WorkflowJobInsertJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobInsertJPAExecutor)7 ELService (org.apache.oozie.service.ELService)7 ELEvaluator (org.apache.oozie.util.ELEvaluator)7 JPAService (org.apache.oozie.service.JPAService)6 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Reader (java.io.Reader)4 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)4 File (java.io.File)3