Package org.apache.oozie.service

Examples of org.apache.oozie.service.JPAService


                CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
        _testGetAction(action.getId());
    }

    private void _testGetAction(String actionId) throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordActionGetJPAExecutor actionGetCmd = new CoordActionGetJPAExecutor(actionId);
        CoordinatorActionBean ret = jpaService.execute(actionGetCmd);
        assertNotNull(ret);
        assertEquals(ret.getId(), actionId);
    }
View Full Code Here


     * @throws Exception
     */
    public void testBundleKill1() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);

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

        new BundleKillXCommand(job.getId()).call();

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

     * @throws Exception
     */
    public void testBundleKill2() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);

        final JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        Configuration jobConf = null;
        try {
            jobConf = new XConfiguration(new StringReader(job.getConf()));
        }
        catch (IOException ioe) {
            log.warn("Configuration parse error. read from DB :" + job.getConf(), ioe);
            throw new CommandException(ErrorCode.E1005, ioe);
        }

        Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
        jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());

        BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf, job.getAuthToken());
        submitCmd.call();

        BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
        job = jpaService.execute(bundleJobGetCmd);
        assertEquals(Job.Status.PREP, job.getStatus());

        new BundleStartXCommand(job.getId()).call();

        job = jpaService.execute(bundleJobGetCmd);
        assertEquals(Job.Status.RUNNING, job.getStatus());

        Thread.sleep(2000);

        BundleActionsGetJPAExecutor bundleActionsGetCmd = new BundleActionsGetJPAExecutor(job.getId());
        List<BundleActionBean> actions = jpaService.execute(bundleActionsGetCmd);

        assertEquals(2, actions.size());
        assertNotNull(actions.get(0).getCoordId());
        assertNotNull(actions.get(1).getCoordId());

        new BundleKillXCommand(job.getId()).call();

        job = jpaService.execute(bundleJobGetCmd);
        assertEquals(Job.Status.KILLED, job.getStatus());

        actions = jpaService.execute(bundleActionsGetCmd);

        assertEquals(true, actions.get(0).isPending());
        assertEquals(true, actions.get(1).isPending());

        final CoordJobGetJPAExecutor coordGetCmd1 = new CoordJobGetJPAExecutor(actions.get(0).getCoordId());
        final CoordJobGetJPAExecutor coordGetCmd2 = new CoordJobGetJPAExecutor(actions.get(1).getCoordId());


        waitFor(200000, new Predicate() {
            public boolean evaluate() throws Exception {
                CoordinatorJobBean job1 = jpaService.execute(coordGetCmd1);
                return job1.getStatus().equals(CoordinatorJobBean.Status.KILLED);
            }
        });

        CoordinatorJobBean job1 = jpaService.execute(coordGetCmd1);
        assertEquals(CoordinatorJobBean.Status.KILLED, job1.getStatus());

        waitFor(200000, new Predicate() {
            public boolean evaluate() throws Exception {
                CoordinatorJobBean job2 = jpaService.execute(coordGetCmd2);
                return job2.getStatus().equals(CoordinatorJobBean.Status.KILLED);
            }
        });

        CoordinatorJobBean job2 = jpaService.execute(coordGetCmd2);
        assertEquals(CoordinatorJobBean.Status.KILLED, job2.getStatus());

    }
View Full Code Here

     * @throws Exception
     */
    public void testBundleKill3() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);

        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        Configuration jobConf = null;
        try {
            jobConf = new XConfiguration(new StringReader(job.getConf()));
        }
        catch (IOException ioe) {
            log.warn("Configuration parse error. read from DB :" + job.getConf(), ioe);
            throw new CommandException(ErrorCode.E1005, ioe);
        }

        Path appPath = new Path(jobConf.get(OozieClient.BUNDLE_APP_PATH), "bundle.xml");
        jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());

        BundleSubmitXCommand submitCmd = new BundleSubmitXCommand(jobConf, job.getAuthToken());
        submitCmd.call();

        BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(submitCmd.getJob().getId());
        job = jpaService.execute(bundleJobGetCmd);
        assertEquals(Job.Status.PREP, job.getStatus());

        new BundleKillXCommand(job.getId()).call();

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

    private void _testGetActionsSubset(String jobId, String actionId, int start, int len, String consoleUrl,
            String errorCode, String errorMessage, String externalId, String externalStatus, String trackerUri,
            Date createdTime, Date nominalTime, String missDeps, int timeout, CoordinatorAction.Status status)
            throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new CoordJobGetActionsSubsetJPAExecutor(jobId,
                Collections.<String> emptyList(), start, len);
        List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
        CoordinatorActionBean action = actions.get(0);

        assertEquals(1, actions.size());
        assertEquals(actionId, action.getId());
        assertEquals(jobId, action.getJobId());
View Full Code Here

        // test for the expected action number
        _testGetActionsSubsetOrderBy(job.getId(), 2, 1, 2);
    }

   private void _testGetActionsSubsetOrderBy(String jobId, int actionNum, int start, int len) throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new CoordJobGetActionsSubsetJPAExecutor(jobId, Collections.<String>emptyList(), start, len);
        List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
        assertEquals(actions.size(), 2);
        // As actions are sorted by nominal time, the first action should be with action number 2
        assertEquals(actions.get(0).getActionNumber(), actionNum);
    }
View Full Code Here

    }

    // Check whether actions are retrieved based on the filter values for status
    private void _testGetActionsSubsetFilter(String jobId, int actionNum, List<String> filterList, int start, int len)
            throws JPAExecutorException {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new CoordJobGetActionsSubsetJPAExecutor(jobId, filterList,
                start, len);
        List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
        // As actions are filtered by RUNNING status, only 1 action should be returned
        assertEquals(actions.size(), 1);
        assertEquals(actions.get(0).getActionNumber(), 1);
    }
View Full Code Here

            Services.get().destroy();
        }
    }

    private void _testGetForInfoAllActions(String jobId, String slaXml, int start, int len) throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new CoordJobGetActionsSubsetJPAExecutor(jobId,
                Collections.<String> emptyList(), start, len);
        List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
        CoordinatorActionBean action = actions.get(0);

        assertEquals(CoordinatorAction.Status.WAITING, action.getStatus());
        assertEquals(slaXml, action.getSlaXml());
        assertEquals(0, action.getPending());
View Full Code Here

        addRecordToWfActionTable(job.getId(), "2", WorkflowAction.Status.PREP);
        _testDeleteWFActionsForJob(job.getId());
    }

    private void _testDeleteWFActionsForJob(String jobId) throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        WorkflowActionsDeleteForPurgeJPAExecutor deleteActionsExecutor = new WorkflowActionsDeleteForPurgeJPAExecutor(jobId);
        int actionsDeleted = jpaService.execute(deleteActionsExecutor);
        assertEquals(2, actionsDeleted);
    }
View Full Code Here

    public void testSucBundlePurgeXCommand() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateUTC("2011-01-01T01:00Z"));
        this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.SUCCEEDED);
        this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.SUCCEEDED);

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

        BundleActionGetJPAExecutor bundleActionGetExecutor1 = new BundleActionGetJPAExecutor(job.getId(), "action1");
        BundleActionBean action1 = jpaService.execute(bundleActionGetExecutor1);
        assertEquals(Job.Status.SUCCEEDED, action1.getStatus());

        BundleActionGetJPAExecutor bundleActionGetExecutor2 = new BundleActionGetJPAExecutor(job.getId(), "action2");
        BundleActionBean action2 = jpaService.execute(bundleActionGetExecutor2);
        assertEquals(Job.Status.SUCCEEDED, action2.getStatus());

        new BundlePurgeXCommand(7, 10).call();

        try {
            job = jpaService.execute(bundleJobGetExecutor);
            fail("Job should be purged. Should fail.");
        }
        catch (JPAExecutorException je) {
            // Job doesn't exist. Exception is expected.
        }

        try {
            jpaService.execute(bundleActionGetExecutor1);
            fail("Action should be purged. Should fail.");
        }
        catch (JPAExecutorException je) {
            // Job doesn't exist. Exception is expected.
        }

        try {
            jpaService.execute(bundleActionGetExecutor2);
            fail("Action should be purged. Should fail.");
        }
        catch (JPAExecutorException je) {
            // Job doesn't exist. Exception is expected.
        }
View Full Code Here

TOP

Related Classes of org.apache.oozie.service.JPAService

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.