Package org.apache.oozie.client

Examples of org.apache.oozie.client.CoordinatorJob


    @VisibleForTesting
    void printBulkJobs(List<BulkResponse> jobs, String timeZoneId, boolean verbose) throws IOException {
        if (jobs != null && jobs.size() > 0) {
            for (BulkResponse response : jobs) {
                BundleJob bundle = response.getBundle();
                CoordinatorJob coord = response.getCoordinator();
                CoordinatorAction action = response.getAction();
                if (verbose) {
                    System.out.println();
                    System.out.println("Bundle Name : " + maskIfNull(bundle.getAppName()));

                    System.out.println(RULER);

                    System.out.println("Bundle ID        : " + maskIfNull(bundle.getId()));
                    System.out.println("Coordinator Name : " + maskIfNull(coord.getAppName()));
                    System.out.println("Coord Action ID  : " + maskIfNull(action.getId()));
                    System.out.println("Action Status    : " + action.getStatus());
                    System.out.println("External ID      : " + maskIfNull(action.getExternalId()));
                    System.out.println("Created Time     : " + maskDate(action.getCreatedTime(), timeZoneId, false));
                    System.out.println("User             : " + maskIfNull(bundle.getUser()));
                    System.out.println("Error Message    : " + maskIfNull(action.getErrorMessage()));
                    System.out.println(RULER);
                }
                else {
                    System.out.println(String.format(BULK_RESPONSE_FORMATTER, "Bundle Name", "Bundle ID", "Coord Name",
                            "Coord Action ID", "Status", "External ID", "Created Time", "Error Message"));
                    System.out.println(RULER);
                    System.out
                            .println(String.format(BULK_RESPONSE_FORMATTER, maskIfNull(bundle.getAppName()),
                                    maskIfNull(bundle.getId()), maskIfNull(coord.getAppName()),
                                    maskIfNull(action.getId()), action.getStatus(), maskIfNull(action.getExternalId()),
                                    maskDate(action.getCreatedTime(), timeZoneId, false),
                                    maskIfNull(action.getErrorMessage())));
                    System.out.println(RULER);
                }
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

                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

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

        waitFor(12000, 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(12000, 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) {
            CoordinatorActionBean jsonAction = (CoordinatorActionBean) action;
View Full Code Here

        return jobId;
    }

    private void _testGetJob(String jobId, String appPath) throws Exception {
        CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
        CoordinatorJob job = ce.getCoordJob(jobId);
        assertEquals(jobId, job.getId());
        assertEquals(job.getAppPath(), appPath);
    }
View Full Code Here

    public void _testGetJobs(String jobId) throws Exception {
        CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
        // Test with no job filter specified
        CoordinatorJobInfo jobInfo = ce.getCoordJobs("", 1, 10);
        assertEquals(1, jobInfo.getCoordJobs().size());
        CoordinatorJob job = jobInfo.getCoordJobs().get(0);
        assertEquals(jobId, job.getId());

        // Test specifying the value for unit but leaving out the value for frequency
        try {
            jobInfo = ce.getCoordJobs("unit=minutes", 1, 10);
        }
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.