Package org.apache.oozie

Examples of org.apache.oozie.BundleJobBean


     */
    public void testBundleRerunInSuspendedWithError() throws Exception {
        Services.get().destroy();
        setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
        new Services().init();
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.SUSPENDEDWITHERROR, false);
        this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.SUSPENDED);
        this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.SUSPENDEDWITHERROR);
        addRecordToCoordJobTable("action1", CoordinatorJob.Status.SUSPENDED, false, false);
        addRecordToCoordJobTable("action2", CoordinatorJob.Status.SUSPENDEDWITHERROR, false, false);

        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
        job = jpaService.execute(bundleJobGetExecutor);
        assertEquals(Job.Status.SUSPENDEDWITHERROR, job.getStatus());

        new BundleRerunXCommand(job.getId(), "action2", null, false, true).call();

        job = jpaService.execute(bundleJobGetExecutor);
        assertEquals(Job.Status.RUNNINGWITHERROR, job.getStatus());
    }
View Full Code Here


        assertEquals(Job.Status.RUNNINGWITHERROR, job.getStatus());
    }


    protected BundleJobBean addRecordToBundleJobTableWithPausedTime(Job.Status jobStatus, boolean pending, Date pausedTime) throws Exception {
        BundleJobBean bundle = createBundleJob(jobStatus, pending);
        bundle.setPauseTime(pausedTime);
        try {
            JPAService jpaService = Services.get().get(JPAService.class);
            assertNotNull(jpaService);
            BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundle);
            jpaService.execute(bundleInsertjpa);
View Full Code Here

        Map<String, Timestamp> actionTimes = new HashMap<String, Timestamp>();

        try {
            // Lightweight Query 1 on Bundle level to fetch the bundle job
            // corresponding to name
            BundleJobBean bundleBean = bundleQuery(em);

            // Join query between coordinator job and coordinator action tables
            // to get entries for specific bundleId only
            String conditions = actionQuery(em, bundleBean, actionTimes, responseList);
View Full Code Here

        }
    }

    @SuppressWarnings("unchecked")
    private BundleJobBean bundleQuery(EntityManager em) throws JPAExecutorException {
        BundleJobBean bundleBean = new BundleJobBean();
        String bundleName = bulkFilter.get(BulkResponseImpl.BULK_FILTER_BUNDLE_NAME).get(0);
        Query q = em.createNamedQuery("BULK_MONITOR_BUNDLE_QUERY");
        q.setParameter("appName", bundleName);
        List<Object[]> bundles = (List<Object[]>) q.getResultList();
        if (bundles.isEmpty()) {
View Full Code Here

        bean.setAction(actionBean);
        return bean;
    }

    private BundleJobBean getBeanForBundleJob(Object[] barr, String name) throws JPAExecutorException {
        BundleJobBean bean = new BundleJobBean();
        if (barr[0] != null) {
            bean.setId((String) barr[0]);
        }
        else {
            throw new JPAExecutorException(ErrorCode.E0603,
                    "bundleId returned by query is null - cannot retrieve bulk results");
        }
        bean.setAppName(name);
        if (barr[1] != null) {
            bean.setStatus(BundleJob.Status.valueOf((String) barr[1]));
        }
        return bean;
    }
View Full Code Here

                for (BundleActionBean action : actionList) {
                    bundleIds.add(action.getBundleId());
                }
                pendingJobCheckList = new ArrayList<BundleJobBean>();
                for (String bundleId : bundleIds.toArray(new String[bundleIds.size()])) {
                    BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
                    // Running bundle job might have pending false
                    if (bundle.isPending() || bundle.getStatus().equals(Job.Status.RUNNING)
                            || bundle.getStatus().equals(Job.Status.RUNNINGWITHERROR)
                            || bundle.getStatus().equals(Job.Status.PAUSED)
                            || bundle.getStatus().equals(Job.Status.PAUSEDWITHERROR)) {
                        pendingJobCheckList.add(bundle);
                    }
                }
            }
            aggregateBundleJobsStatus(pendingJobCheckList);
View Full Code Here

     * Basic coordinator submit test with bundleId
     *
     * @throws Exception
     */
    public void testBasicSubmitWithBundleId() throws Exception {
        BundleJobBean coordJob = addRecordToBundleJobTable(Job.Status.PREP, false);
        Configuration conf = new XConfiguration();
        String appPath = "file://" + getTestCaseDir() + File.separator + "coordinator.xml";
        String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" "
                + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> <concurrency>2</concurrency> "
                + "<execution>LIFO</execution> </controls> <datasets> "
                + "<dataset name=\"a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
                + "timezone=\"UTC\"> <uri-template>file:///tmp/coord/workflows/${YEAR}/${DAY}</uri-template> </dataset> "
                + "<dataset name=\"local_a\" frequency=\"${coord:days(7)}\" initial-instance=\"2009-02-01T01:00Z\" "
                + "timezone=\"UTC\"> <uri-template>file:///tmp/coord/workflows/${YEAR}/${DAY}</uri-template> </dataset> "
                + "</datasets> <input-events> "
                + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in>  "
                + "</input-events> "
                + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> "
                + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> "
                + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> "
                + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> "
                + "</property></configuration> </workflow> </action> </coordinator-app>";
        writeToFile(appXml, appPath);
        conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
        conf.set(OozieClient.USER_NAME, getTestUser());

        this.addRecordToBundleActionTable(coordJob.getId(), "COORD-NAME", 0, Job.Status.PREP);

        CoordSubmitXCommand sc = new CoordSubmitXCommand(conf, "UNIT_TESTING", coordJob.getId(), "COORD-NAME");
        String jobId = sc.call();

        assertEquals(jobId.substring(jobId.length() - 2), "-C");
        CoordinatorJobBean job = checkCoordJobs(jobId);
        if (job != null) {
            assertEquals(coordJob.getId(), job.getBundleId());
            assertEquals("COORD-NAME", job.getAppName());
            assertEquals("uri:oozie:coordinator:0.2", job.getAppNamespace());
        } else {
            fail();
        }
View Full Code Here

     * Test : Pause a PREP bundle, then delay its pausetime to unpause it.
     *
     * @throws Exception
     */
    public void testPauseUnpause1() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
        final JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        job.setPauseTime(new Date(new Date().getTime() - 30 * 1000));
        job.setKickoffTime(new Date(new Date().getTime() + 3600 * 1000));
        jpaService.execute(new BundleJobUpdateJPAExecutor(job));

        Runnable pauseStartRunnable = new PauseTransitRunnable();
        pauseStartRunnable.run();

        final String jobId = job.getId();
        waitFor(10 * 1000, new Predicate() {
            public boolean evaluate() throws Exception {
                BundleJobBean job1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
                return job1.getStatus() == Job.Status.PREPPAUSED;
            }
        });

        job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
        assertEquals(Job.Status.PREPPAUSED, job.getStatus());

        job.setPauseTime(new Date(new Date().getTime() + 3600 * 1000));
        jpaService.execute(new BundleJobUpdateJPAExecutor(job));

        pauseStartRunnable.run();

        waitFor(10 * 1000, new Predicate() {
            public boolean evaluate() throws Exception {
                BundleJobBean job1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
                return job1.getStatus() == Job.Status.PREP;
            }
        });

        job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
        assertEquals(Job.Status.PREP, job.getStatus());
View Full Code Here

     * Test : Pause a PREP bundle, then reset its pausetime to null to unpause it.
     *
     * @throws Exception
     */
    public void testPauseUnpause2() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
        final JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        job.setPauseTime(new Date(new Date().getTime() - 30 * 1000));
        job.setKickoffTime(new Date(new Date().getTime() + 3600 * 1000));
        jpaService.execute(new BundleJobUpdateJPAExecutor(job));

        Runnable pauseStartRunnable = new PauseTransitRunnable();
        pauseStartRunnable.run();

        final String jobId = job.getId();
        waitFor(10 * 1000, new Predicate() {
            public boolean evaluate() throws Exception {
                BundleJobBean job1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
                return job1.getStatus() == Job.Status.PREPPAUSED;
            }
        });

        job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
        assertEquals(Job.Status.PREPPAUSED, job.getStatus());

        job.setPauseTime(null);
        jpaService.execute(new BundleJobUpdateJPAExecutor(job));

        pauseStartRunnable.run();

        waitFor(10 * 1000, new Predicate() {
            public boolean evaluate() throws Exception {
                BundleJobBean job1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
                return job1.getStatus() == Job.Status.PREP;
            }
        });

        job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
        assertEquals(Job.Status.PREP, job.getStatus());
View Full Code Here

     * Test : Pause a RUNNING bundle, then check bundle action has been updated to PAUSED by BundleStatusUpdateXCommand
     *
     * @throws Exception
     */
    public void testPauseBundleAndCoordinator() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
        final JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        Date pauseTime = new Date(new Date().getTime() - 30 * 1000);
        job.setPauseTime(pauseTime);
        jpaService.execute(new BundleJobUpdateJPAExecutor(job));

        BundleActionBean bundleAction1 = this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.RUNNING);
        BundleActionBean bundleAction2 = this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.RUNNING);

        String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
        Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
        Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);

        CoordinatorJobBean coordJob1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.RUNNING, start, end, false);
        CoordinatorJobBean coordJob2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.RUNNING, start, end, false);

        coordJob1.setPauseTime(pauseTime);
        coordJob1.setBundleId(job.getId());
        jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob1));
        coordJob2.setPauseTime(pauseTime);
        coordJob2.setBundleId(job.getId());
        jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob2));

        BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
        job = jpaService.execute(bundleJobGetExecutor);
        assertEquals(Job.Status.RUNNING, job.getStatus());

        Runnable pauseStartRunnable = new PauseTransitRunnable();
        pauseStartRunnable.run();

        final String jobId = job.getId();
        waitFor(10 * 1000, new Predicate() {
            public boolean evaluate() throws Exception {
                BundleJobBean bJob1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
                return bJob1.getStatus() == Job.Status.PAUSED;
            }
        });

        final String coordJobId1 = coordJob1.getId();
        final String coordJobId2 = coordJob2.getId();
View Full Code Here

TOP

Related Classes of org.apache.oozie.BundleJobBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.