Search in sources :

Example 51 with BundleJobBean

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

the class XDataTestCase method createBundleJobNegative.

/**
 * Create bundle job that contains bad coordinator jobs
 *
 * @param jobStatus
 * @return bundle job bean
 * @throws Exception
 */
protected BundleJobBean createBundleJobNegative(Job.Status jobStatus) throws Exception {
    Path coordPath1 = new Path(getFsTestCaseDir(), "coord1");
    Path coordPath2 = new Path(getFsTestCaseDir(), "coord2");
    writeCoordXml(coordPath1, "coord-job-bundle-negative.xml");
    writeCoordXml(coordPath2, "coord-job-bundle-negative.xml");
    Path bundleAppPath = new Path(getFsTestCaseDir(), "bundle");
    String bundleAppXml = getBundleXml("bundle-submit-job.xml");
    bundleAppXml = bundleAppXml.replaceAll("#app_path1", new Path(coordPath1.toString(), "coordinator.xml").toString());
    bundleAppXml = bundleAppXml.replaceAll("#app_path2", new Path(coordPath1.toString(), "coordinator.xml").toString());
    writeToFile(bundleAppXml, bundleAppPath, "bundle.xml");
    Configuration conf = new XConfiguration();
    conf.set(OozieClient.BUNDLE_APP_PATH, bundleAppPath.toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set("jobTracker", getJobTrackerUri());
    conf.set("nameNode", getNameNodeUri());
    conf.set("coordName1", "coord1");
    conf.set("coordName2", "coord2");
    conf.set("coord1.starttime", "2009-02-01T00:00Z");
    conf.set("isEnabled", "true");
    BundleJobBean bundle = new BundleJobBean();
    bundle.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.BUNDLE));
    bundle.setAppName("BUNDLE-TEST");
    bundle.setAppPath(bundleAppPath.toString());
    bundle.setConf(XmlUtils.prettyPrint(conf).toString());
    bundle.setConsoleUrl("consoleUrl");
    bundle.setCreatedTime(new Date());
    bundle.setJobXml(bundleAppXml);
    bundle.setLastModifiedTime(new Date());
    bundle.setOrigJobXml(bundleAppXml);
    bundle.resetPending();
    bundle.setStatus(jobStatus);
    bundle.setUser(conf.get(OozieClient.USER_NAME));
    bundle.setGroup(conf.get(OozieClient.GROUP_NAME));
    return bundle;
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) BundleJobBean(org.apache.oozie.BundleJobBean) Date(java.util.Date)

Example 52 with BundleJobBean

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

the class TestBulkMonitorJPAExecutor method testMultipleBundleIdsForName.

public void testMultipleBundleIdsForName() throws Exception {
    // Adding another bundle having same name
    BundleJobBean bundle = new BundleJobBean();
    bundle.setId("00002-12345-B");
    bundle.setAppName(bundleName);
    bundle.setStatus(BundleJob.Status.RUNNING);
    bundle.setStartTime(new Date());
    BundleJobInsertJPAExecutor bundleInsert = new BundleJobInsertJPAExecutor(bundle);
    jpaService.execute(bundleInsert);
    String request = "bundle=" + bundleName;
    BulkJPAExecutor bulkjpa = new BulkJPAExecutor(BundleEngine.parseBulkFilter(request), 1, 10);
    try {
        jpaService.execute(bulkjpa);
    } catch (JPAExecutorException jex) {
        // should not throw exception as this case is now supported
        fail();
    }
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) Date(java.util.Date)

Example 53 with BundleJobBean

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

the class TestBundleActionQueryExecutor method testExecuteUpdate.

public void testExecuteUpdate() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleActionBean bean = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
    bean.setStatus(Job.Status.RUNNING);
    BundleActionQueryExecutor.getInstance().executeUpdate(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME, bean);
    BundleActionBean retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, bean.getBundleActionId());
    assertEquals(retBean.getStatus(), Job.Status.RUNNING);
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 54 with BundleJobBean

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

the class TestBundleActionQueryExecutor method testGetUpdateQuery.

public void testGetUpdateQuery() throws Exception {
    EntityManager em = jpaService.getEntityManager();
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleActionBean bundleAction = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
    // UPDATE_BUNDLE_ACTION_PENDING_MODTIME
    Query query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_PENDING_MODTIME, bundleAction, em);
    assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bundleAction.getPending());
    assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
    // UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME:
    query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction, em);
    assertEquals(query.getParameterValue("status"), bundleAction.getStatus().toString());
    assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bundleAction.getPending());
    assertEquals(query.getParameterValue("coordId"), bundleAction.getCoordId());
    assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
    // UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID
    query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction, em);
    assertEquals(query.getParameterValue("status"), bundleAction.getStatus().toString());
    assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bundleAction.isPending() ? 1 : 0);
    assertEquals(query.getParameterValue("coordId"), bundleAction.getCoordId());
    assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
    em.close();
}
Also used : EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 55 with BundleJobBean

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

the class TestBundleActionQueryExecutor method testGet.

public void testGet() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleActionBean bundleAction = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
    // GET_UNIGNORED_BUNDLE_ACTION_STATUS_PENDING_FOR_BUNDLE
    BundleActionBean retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_UNIGNORED_ACTION_STATUS_PENDING_FOR_BUNDLE, bundleAction.getBundleId());
    assertEquals(bundleAction.getCoordId(), retBean.getCoordId());
    assertEquals(bundleAction.getStatusStr(), retBean.getStatusStr());
    assertEquals(bundleAction.getPending(), retBean.getPending());
    // GET_BUNDLE_ACTION
    retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, bundleAction.getBundleActionId());
    assertEquals(bundleAction.getStatus(), retBean.getStatus());
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean)

Aggregations

BundleJobBean (org.apache.oozie.BundleJobBean)159 JPAService (org.apache.oozie.service.JPAService)78 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)69 BundleActionBean (org.apache.oozie.BundleActionBean)58 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)46 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)44 Date (java.util.Date)35 ArrayList (java.util.ArrayList)24 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)24 List (java.util.List)21 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)21 HashMap (java.util.HashMap)20 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)20 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)18 IOException (java.io.IOException)16 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)16 XConfiguration (org.apache.oozie.util.XConfiguration)16 Query (javax.persistence.Query)14 CommandException (org.apache.oozie.command.CommandException)14