Package org.apache.oozie.service

Examples of org.apache.oozie.service.JPAService


        assertNotNull(ret);
        assertEquals(ret.getCoordJobs().size(), 2);
    }

    private void _testGetJobInfoForFrequency() throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        Map<String, List<String>> filter = new HashMap<String, List<String>>();
        List<String> frequencyList = new ArrayList<String>();
        frequencyList.add("1");
        filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);

        CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
        CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
        assertNotNull(ret);
        assertEquals(ret.getCoordJobs().size(), 3);
    }
View Full Code Here


     */
    public void testBundleChange3() throws Exception {
        BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
        String dateStr = "2099-01-01T01:00Z";

        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(job.getId());
        job = jpaService.execute(bundleJobGetCmd);
        assertEquals(job.getEndTime(), null);

        new BundleJobChangeXCommand(job.getId(), "endtime=" + dateStr).call();

        job = jpaService.execute(bundleJobGetCmd);
        assertEquals(job.getEndTime(), DateUtils.parseDateUTC(dateStr));
    }
View Full Code Here

        assertNotNull(ret);
        assertEquals(ret.getCoordJobs().size(), 3);
    }

    private void _testGetJobInfoForId(String jobId) throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        Map<String, List<String>> filter = new HashMap<String, List<String>>();
        List<String> jobIdList = new ArrayList<String>();
        jobIdList.add(jobId);
        filter.put(OozieClient.FILTER_ID, jobIdList);

        CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
        CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
        assertNotNull(ret);
        assertEquals(ret.getCoordJobs().size(), 1);
    }
View Full Code Here

     * Test to verify various combinations of frequency and time unit filters for jobs
     *
     * @throws Exception
     */
    private void _testGetJobInfoForFrequencyAndUnit() throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        // Test specifying frequency value as 1 minute
        Map<String, List<String>> filter = new HashMap<String, List<String>>();
        List<String> unitList = new ArrayList<String>();
        List<String> frequencyList = new ArrayList<String>();
        unitList.add("MINUTE");
        filter.put(OozieClient.FILTER_UNIT, unitList);
        frequencyList = new ArrayList<String>();
        frequencyList.add("1");
        filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);
        CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
        CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
        assertNotNull(ret);
        assertEquals(ret.getCoordJobs().size(), 0);
        frequencyList.remove(0);
        unitList.remove(0);

        // Test specifying frequency value as 3 days
        unitList.add("DAY");
        filter.put(OozieClient.FILTER_UNIT, unitList);
        frequencyList.add("3");
        filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);
        coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
        ret = jpaService.execute(coordInfoGetCmd);
        assertNotNull(ret);
        assertEquals(ret.getCoordJobs().size(), 0);
        frequencyList.remove(0);
        unitList.remove(0);

        // Test specifying frequency value as 1 day
        unitList.add("DAY");
        filter.put(OozieClient.FILTER_UNIT, unitList);
        frequencyList.add("1");
        filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);
        coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
        ret = jpaService.execute(coordInfoGetCmd);
        assertNotNull(ret);
        assertEquals(ret.getCoordJobs().size(), 3);
    }
View Full Code Here

    }

    // test sql projection operator
    private void _testCoordActionsForCorrectColumnValues(String jobId, String actionId, CoordinatorAction.Status status,
            int pending) throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        // Call JPAExecutor to get actions which are suspended
        CoordJobGetActionsSuspendedJPAExecutor actionGetCmd = new CoordJobGetActionsSuspendedJPAExecutor(jobId);
        List<CoordinatorActionBean> actionList = jpaService.execute(actionGetCmd);
        // check for expected column values
        CoordinatorActionBean action = actionList.get(0);
        assertEquals(action.getId(), actionId);
        assertEquals(action.getStatus(), status);
        assertEquals(action.getPending(), pending);
View Full Code Here

    }


    // test sql selection operator
    private void _testCoordActionsSuspendedSize(String jobId, int expectedSize) throws Exception {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        // Call JPAExecutor to get actions which are suspended
        CoordJobGetActionsSuspendedJPAExecutor actionGetCmd = new CoordJobGetActionsSuspendedJPAExecutor(jobId);
        List<CoordinatorActionBean> actionList = jpaService.execute(actionGetCmd);
        // As two actions are suspended, expected result set is of size 2
        assertEquals(actionList.size(), expectedSize);

    }
View Full Code Here

        }
    }

    private void checkCoordActionsTimeout(String actionId, int expected) {
        try {
            JPAService jpaService = Services.get().get(JPAService.class);
            CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
            assertEquals(action.getTimeOut(), expected);
        }
        catch (JPAExecutorException se) {
            se.printStackTrace();
            fail("Action ID " + actionId + " was not stored properly in db");
View Full Code Here

                coordAction.setStatus(CoordinatorAction.Status.RUNNING);
                coordAction.setExternalId(wfId);
                coordAction.incrementAndGetPending();

                //store.updateCoordinatorAction(coordAction);
                JPAService jpaService = Services.get().get(JPAService.class);
                if (jpaService != null) {
                    log.debug("Updating WF record for WFID :" + wfId + " with parent id: " + actionId);
                    WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(wfId));
                    wfJob.setParentId(actionId);
                    jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
                    jpaService.execute(new org.apache.oozie.executor.jpa.CoordActionUpdateForStartJPAExecutor(coordAction));
                }
                else {
                    log.error(ErrorCode.E0610);
                }

                makeFail = false;
            }
            catch (DagEngineException dee) {
                errMsg = dee.getMessage();
                errCode = "E1005";
                log.warn("can not create DagEngine for submitting jobs", dee);
            }
            catch (CommandException ce) {
                errMsg = ce.getMessage();
                errCode = ce.getErrorCode().toString();
                log.warn("command exception occured ", ce);
            }
            catch (java.io.IOException ioe) {
                errMsg = ioe.getMessage();
                errCode = "E1005";
                log.warn("Configuration parse error. read from DB :" + coordAction.getRunConf(), ioe);
            }
            catch (Exception ex) {
                errMsg = ex.getMessage();
                errCode = "E1005";
                log.warn("can not create DagEngine for submitting jobs", ex);
            }
            finally {
                if (makeFail == true) { // No DB exception occurs
                    log.warn("Failing the action " + coordAction.getId() + ". Because " + errCode + " : " + errMsg);
                    coordAction.setStatus(CoordinatorAction.Status.FAILED);
                    if (errMsg.length() > 254) { // Because table column size is 255
                        errMsg = errMsg.substring(0, 255);
                    }
                    coordAction.setErrorMessage(errMsg);
                    coordAction.setErrorCode(errCode);

                    JPAService jpaService = Services.get().get(JPAService.class);
                    if (jpaService != null) {
                        try {
                            jpaService.execute(new org.apache.oozie.executor.jpa.CoordActionUpdateForStartJPAExecutor(coordAction));
                        }
                        catch (JPAExecutorException je) {
                            throw new CommandException(je);
                        }
                    }
View Full Code Here

            writeSLARegistration(jobSlaXml, workflow.getId(), workflow.getUser(), workflow.getGroup(), LOG);
            workflow.setSlaXml(jobSlaXml);
            // System.out.println("SlaXml :"+ slaXml);

            //store.insertWorkflow(workflow);
            JPAService jpaService = Services.get().get(JPAService.class);
            if (jpaService != null) {
                jpaService.execute(new WorkflowJobInsertJPAExecutor(workflow));
            }
            else {
                LOG.error(ErrorCode.E0610);
                return null;
            }
View Full Code Here

        _testGetActionForCheck(action.getId(), job.getId(), CoordinatorAction.Status.WAITING, 0, action.getId() + "_E", XDataTestCase.slaXml);
    }

    private void _testGetActionForCheck(String actionId, String jobId, CoordinatorAction.Status status, int pending, String extId, String slaXml) throws Exception {
        try {
            JPAService jpaService = Services.get().get(JPAService.class);
            assertNotNull(jpaService);
            CoordActionGetForCheckJPAExecutor actionGetCmd = new CoordActionGetForCheckJPAExecutor(actionId);
            CoordinatorActionBean action = jpaService.execute(actionGetCmd);
            assertNotNull(action);
            assertEquals(actionId, action.getId());
            assertEquals(status, action.getStatus());
            assertEquals(pending, action.getPending());
            assertEquals(extId, action.getExternalId());
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.