Search in sources :

Example 16 with WorkflowApp

use of org.apache.oozie.workflow.WorkflowApp in project oozie by apache.

the class TestWorkflowJobsGetForPurgeJPAExecutor method addRecordToWfJobTable.

@Override
protected WorkflowJobBean addRecordToWfJobTable(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);
    Timestamp startTS = new Timestamp(System.currentTimeMillis() - (3 * DAY_IN_MS));
    Timestamp endTS = new Timestamp(System.currentTimeMillis() - (2 * DAY_IN_MS));
    wfBean.setStartTime(DateUtils.toDate(startTS));
    wfBean.setEndTime(DateUtils.toDate(endTS));
    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 : LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) WorkflowApp(org.apache.oozie.workflow.WorkflowApp) EndNodeDef(org.apache.oozie.workflow.lite.EndNodeDef) Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Timestamp(java.sql.Timestamp) StartNodeDef(org.apache.oozie.workflow.lite.StartNodeDef) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) JPAService(org.apache.oozie.service.JPAService)

Example 17 with WorkflowApp

use of org.apache.oozie.workflow.WorkflowApp in project oozie by apache.

the class TestLiteWorkflowAppService method testSchema.

public void testSchema() throws Exception {
    Services services = new Services();
    try {
        services.init();
        Reader reader = IOUtils.getResourceAsReader("wf-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());
        WorkflowApp app = wps.parseDef(jobConf);
        assertNotNull(app);
        assertEquals("test-wf", app.getName());
        reader = IOUtils.getResourceAsReader("wf-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 : LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) WorkflowApp(org.apache.oozie.workflow.WorkflowApp) XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) 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)

Aggregations

WorkflowApp (org.apache.oozie.workflow.WorkflowApp)17 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)14 LiteWorkflowApp (org.apache.oozie.workflow.lite.LiteWorkflowApp)14 Configuration (org.apache.hadoop.conf.Configuration)13 EndNodeDef (org.apache.oozie.workflow.lite.EndNodeDef)13 StartNodeDef (org.apache.oozie.workflow.lite.StartNodeDef)13 LiteWorkflowStoreService (org.apache.oozie.service.LiteWorkflowStoreService)11 XConfiguration (org.apache.oozie.util.XConfiguration)10 Path (org.apache.hadoop.fs.Path)9 JPAService (org.apache.oozie.service.JPAService)8 WorkflowJobInsertJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobInsertJPAExecutor)7 Date (java.util.Date)6 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)6 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)5 WorkflowStoreService (org.apache.oozie.service.WorkflowStoreService)4 WorkflowException (org.apache.oozie.workflow.WorkflowException)4 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)4 WorkflowLib (org.apache.oozie.workflow.WorkflowLib)4 URI (java.net.URI)3 Map (java.util.Map)3