Package org.apache.oozie.client

Examples of org.apache.oozie.client.CoordinatorJob


        String jobId = client.run(conf);
        client.suspend(jobId);
        client.resume(jobId);
        client.kill(jobId);

        CoordinatorJob job = client.getCoordJobInfo(jobId);
        String appName = job.getAppName();
        assertEquals("NAME", appName);

        List<CoordinatorJob> list = client.getCoordJobsInfo("", 1, 5);
        assertEquals(2, list.size());
    }
View Full Code Here


                this.appName = "testCoordinatorJobApp";
                this.appPath = "testCoordinatorJobAppPath";
            }
        };

        CoordinatorJob coordJob = createCoordinatorJob(dtObject);

        assertPrintCoordJobOutput(readCoordJobOutput(coordJob, true), dtObject);
        assertPrintCoordJobOutput(readCoordJobOutput(coordJob, false), dtObject);
    }
View Full Code Here

        when(bundleJobMock.getId()).thenReturn(dtObject.deamonName);
        when(bundleJobMock.getAppName()).thenReturn(dtObject.appName);
        when(bundleJobMock.getAppPath()).thenReturn(dtObject.appPath);
        when(bundleJobMock.getStatus()).thenReturn(org.apache.oozie.client.Job.Status.RUNNING);

        CoordinatorJob coordinatorJobMock = createCoordinatorJob(dtObject);
        when(bundleJobMock.getCoordinators()).thenReturn(ImmutableList.of(coordinatorJobMock));
        return bundleJobMock;
    }
View Full Code Here

        when(bundleJobMock.getCoordinators()).thenReturn(ImmutableList.of(coordinatorJobMock));
        return bundleJobMock;
    }

    private static CoordinatorJob createCoordinatorJob(DataObject dtObject) {
        CoordinatorJob coordinatorJobMock = mock(CoordinatorJob.class);
        when(coordinatorJobMock.getId()).thenReturn(dtObject.deamonName);
        when(coordinatorJobMock.getAppName()).thenReturn(dtObject.appName);
        when(coordinatorJobMock.getAppPath()).thenReturn(dtObject.appPath);
        when(coordinatorJobMock.getConcurrency()).thenReturn(15);
        when(coordinatorJobMock.getStatus()).thenReturn(CoordinatorJob.Status.RUNNING);
        when(coordinatorJobMock.getUser()).thenReturn("test");
        when(coordinatorJobMock.getGroup()).thenReturn("test-group");

        ImmutableList.Builder<CoordinatorAction> builder = ImmutableList.builder();

        for (final String id : Arrays.asList("1", "2"))
            builder.add(createCoordinatorAction(new DataObject() {
                {
                    this.deamonName = id;
                    this.appName = "testCoordinatorAction";
                }
            }));

        when(coordinatorJobMock.getActions()).thenReturn(builder.build());
        return coordinatorJobMock;
    }
View Full Code Here

        when(bulkResponse.getBundle()).thenReturn(bundleJob);

        CoordinatorAction coordinatorAction = createCoordinatorAction(dtObject);
        when(bulkResponse.getAction()).thenReturn(coordinatorAction);

        CoordinatorJob coordinatorJob = createCoordinatorJob(dtObject);
        when(bulkResponse.getCoordinator()).thenReturn(coordinatorJob);
        return bulkResponse;
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    public void testParseCoordinatorJob() {
        JSONObject json = createJsonCoordinatorJob();
        CoordinatorJob job = JsonToBean.createCoordinatorJob(json);
        assertEquals("a", job.getAppPath());
        assertEquals("b", job.getAppName());
        assertEquals("c", job.getId());
        assertEquals("d", job.getConf());
        assertEquals(CoordinatorJob.Status.RUNNING, job.getStatus());
        assertEquals(CoordinatorJob.Execution.FIFO, job.getExecutionOrder());
        assertEquals("1", job.getFrequency());
        assertEquals(CoordinatorJob.Timeunit.DAY, job.getTimeUnit());
        assertEquals("e", job.getTimeZone());
        assertEquals(2, job.getConcurrency());
        assertEquals(3, job.getTimeout());
        assertEquals(JsonUtils.parseDateRfc822(LAST_ACTION), job.getLastActionTime());
        assertEquals(JsonUtils.parseDateRfc822(NEXT_MATERIALIZED), job.getNextMaterializedTime());
        assertEquals(JsonUtils.parseDateRfc822(START_TIME), job.getStartTime());
        assertEquals(JsonUtils.parseDateRfc822(END_TIME), job.getEndTime());
        assertEquals(JsonUtils.parseDateRfc822(PAUSE_TIME), job.getPauseTime());
        assertEquals("f", job.getUser());
        assertEquals("g", job.getGroup());
        assertEquals("h", job.getConsoleUrl());
        assertEquals(2, job.getActions().size());
        assertEquals("ca1", job.getActions().get(0).getId());
        assertEquals("ca2", job.getActions().get(1).getId());

        // Test backward compatibility with 3.x. 3.x will not be forward compatible with 4.x though.
        // i.e 4.1 client can be used with 3.x server. But 3.x client cannot be used with 4.x server.
        // Frequency was a int in 3.x but was changed to String in 4.x for cron support
        json.put(JsonTags.COORDINATOR_JOB_FREQUENCY, 1L);
        CoordinatorJob oozie3xjob = JsonToBean.createCoordinatorJob(json);
        assertEquals("1", oozie3xjob.getFrequency());
    }
View Full Code Here

    public void testParseBulkResponse() {
        JSONObject json = createJsonBulkResponse();

        BundleJob bulkBundle = JsonToBean.createBundleJob((JSONObject) json.get(JsonTags.BULK_RESPONSE_BUNDLE));
        CoordinatorJob bulkCoord = JsonToBean.createCoordinatorJob((JSONObject) json.get(JsonTags.BULK_RESPONSE_COORDINATOR));
        CoordinatorAction bulkAction = JsonToBean.createCoordinatorAction((JSONObject) json.get(JsonTags.BULK_RESPONSE_ACTION));

        assertNotNull(bulkBundle);
        assertNotNull(bulkCoord);
        assertNotNull(bulkAction);
        assertEquals("bundle-app", bulkBundle.getAppName());
        assertEquals("bundle-id", bulkBundle.getId());
        assertEquals(BundleJob.Status.RUNNING, bulkBundle.getStatus());
        assertEquals("coord-app", bulkCoord.getAppName());
        assertEquals(CoordinatorJob.Status.SUSPENDED, bulkCoord.getStatus());
        assertEquals("action-id", bulkAction.getId());
        assertEquals("coord-id", bulkAction.getJobId());
        assertEquals(1, bulkAction.getActionNumber());
        assertEquals("action-externalId", bulkAction.getExternalId());
        assertEquals(CoordinatorAction.Status.FAILED, bulkAction.getStatus());
View Full Code Here

        actionBean = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
        return actionBean;
    }

    private CoordinatorJob.Status getStatus(String jobId){
        CoordinatorJob job = null;
        try {
            JPAService jpaService = Services.get().get(JPAService.class);
            job = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
        }
        catch (JPAExecutorException se) {
            se.printStackTrace();
        }
        return job.getStatus();
    }
View Full Code Here

            if (actionsSize != number) {
                fail("Should have " + number + " actions created for job " + jobId + ", but has " + actionsSize + " actions.");
            }

            if (status != null) {
                CoordinatorJob job = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
                if (job.getStatus() != status) {
                    fail("Job status " + job.getStatus() + " should be " + status);
                }
            }
        }
        catch (JPAExecutorException se) {
            se.printStackTrace();
View Full Code Here

    private void _testTimeout(final String jobId) throws Exception {
        final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());

        waitFor(6000, new Predicate() {
            public boolean evaluate() throws Exception {
                CoordinatorJob job = ce.getCoordJob(jobId);
                return !(job.getStatus().equals(CoordinatorJob.Status.PREP));
            }
        });

        CoordinatorJob job = ce.getCoordJob(jobId);
        assertTrue(!(job.getStatus().equals(CoordinatorJob.Status.PREP)));

        waitFor(6000, new Predicate() {
            public boolean evaluate() throws Exception {
                CoordinatorJob job = ce.getCoordJob(jobId);
                List<CoordinatorAction> actions = job.getActions();
                return actions.size() > 0;
            }
        });

        job = ce.getCoordJob(jobId);
        List<CoordinatorAction> actions = job.getActions();
        assertTrue(actions.size() > 0);

        for (CoordinatorAction action : actions) {
            JsonCoordinatorAction json = (JsonCoordinatorAction) action;
            assertEquals(10, json.getTimeOut());
View Full Code Here

TOP

Related Classes of org.apache.oozie.client.CoordinatorJob

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.