Search in sources :

Example 1 with StartNodeDef

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

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

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

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

Example 5 with StartNodeDef

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

the class TestDBWorkflowStore method _testPurge.

private void _testPurge() throws Exception {
    store.beginTrx();
    wfBean1.setEndTime(new Date(System.currentTimeMillis() - (31 * 24 * 60 * 60 * 1000l)));
    wfBean2.setEndTime(new Date(System.currentTimeMillis() - (31 * 24 * 60 * 60 * 1000l)));
    WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
    Configuration conf2 = new Configuration();
    conf2.set(OozieClient.APP_PATH, "testPath");
    conf2.set(OozieClient.LOG_TOKEN, "testToken");
    conf2.set(OozieClient.USER_NAME, getTestUser2());
    WorkflowJobBean wfBean3 = createWorkflow(app, conf2, "auth");
    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);
    store.beginTrx();
    store.insertAction(a31);
    store.commitTrx();
    store.beginTrx();
    store.purge(30, 10000);
    store.commitTrx();
/*
 * SqlStatement s = getCount(OozieTable.WF_JOBS); ResultSet rs =
 * s.prepareAndSetValues(conn).executeQuery(); rs.next(); assertEquals(3,
 * rs.getInt(1)); rs.close();
 *
 * s = getCount(OozieTable.WF_ACTIONS); rs =
 * s.prepareAndSetValues(conn).executeQuery(); rs.next(); assertEquals(4,
 * rs.getInt(1)); rs.close();
 *
 * store.purge(30); store.commit();
 *
 * s = getCount(OozieTable.WF_JOBS); rs =
 * s.prepareAndSetValues(conn).executeQuery(); rs.next(); assertEquals(1,
 * rs.getInt(1)); rs.close();
 *
 * WorkflowJobBean tmp = store.getWorkflow(wfBean3.getId(), false);
 * assertEquals(tmp.getId(), wfBean3.getId());
 *
 * s = getCount(OozieTable.WF_ACTIONS); rs =
 * s.prepareAndSetValues(conn).executeQuery(); rs.next(); assertEquals(1,
 * rs.getInt(1)); rs.close();
 *
 * WorkflowActionBean tmpa = store.getAction("31", false); assertEquals("31",
 * tmpa.getId());
 */
}
Also used : WorkflowApp(org.apache.oozie.workflow.WorkflowApp) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) EndNodeDef(org.apache.oozie.workflow.lite.EndNodeDef) Configuration(org.apache.hadoop.conf.Configuration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) StartNodeDef(org.apache.oozie.workflow.lite.StartNodeDef) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Aggregations

EndNodeDef (org.apache.oozie.workflow.lite.EndNodeDef)21 LiteWorkflowApp (org.apache.oozie.workflow.lite.LiteWorkflowApp)21 StartNodeDef (org.apache.oozie.workflow.lite.StartNodeDef)21 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)20 LiteWorkflowStoreService (org.apache.oozie.service.LiteWorkflowStoreService)15 XConfiguration (org.apache.oozie.util.XConfiguration)14 Configuration (org.apache.hadoop.conf.Configuration)13 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)13 WorkflowApp (org.apache.oozie.workflow.WorkflowApp)13 Path (org.apache.hadoop.fs.Path)9 LiteWorkflowInstance (org.apache.oozie.workflow.lite.LiteWorkflowInstance)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)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)4 Date (java.util.Date)3 Test (org.junit.Test)3