Search in sources :

Example 21 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.

the class OozieCLI method printCoordActions.

private void printCoordActions(List<CoordinatorAction> actions) {
    if (actions != null && actions.size() > 0) {
        System.out.println("Action ID" + VERBOSE_DELIMITER + "Nominal Time");
        System.out.println(RULER);
        for (CoordinatorAction action : actions) {
            System.out.println(maskIfNull(action.getId()) + VERBOSE_DELIMITER + maskDate(action.getNominalTime(), null, false));
        }
    } else {
        System.out.println("No Actions match your criteria!");
    }
}
Also used : CoordinatorAction(org.apache.oozie.client.CoordinatorAction)

Example 22 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.

the class TestOozieCLIMethods method createBulkResponse.

private static BulkResponse createBulkResponse(DataObject dtObject) {
    BulkResponse bulkResponse = mock(BulkResponse.class);
    BundleJob bundleJob = createBundleJob(dtObject);
    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;
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) BulkResponse(org.apache.oozie.client.BulkResponse) BundleJob(org.apache.oozie.client.BundleJob)

Example 23 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.

the class CoordStatusTransitXCommand method loadState.

@Override
protected void loadState() throws CommandException {
    try {
        coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
        List<CoordinatorActionBean> coordActionStatusList = CoordActionQueryExecutor.getInstance().getList(CoordActionQuery.GET_COORD_ACTIONS_STATUS_UNIGNORED, jobId);
        long count = (Long) CoordActionQueryExecutor.getInstance().getSingleValue(CoordActionQuery.GET_COORD_ACTIONS_PENDING_COUNT, jobId);
        if (count > 0) {
            isPending = true;
        }
        for (CoordinatorAction coordAction : coordActionStatusList) {
            int counter = 0;
            if (coordActionStatus.containsKey(coordAction.getStatus())) {
                counter = getStatusCount(coordAction.getStatus()) + 1;
            } else {
                ++counter;
            }
            coordActionStatus.put(coordAction.getStatus(), counter);
        }
        coordActionCount = coordActionStatusList.size();
    } catch (JPAExecutorException jpae) {
        throw new CommandException(ErrorCode.E1025, jpae);
    }
    LogUtils.setLogInfo(this.coordJob);
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) CommandException(org.apache.oozie.command.CommandException)

Example 24 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.

the class TestCoordinatorEngine method testDoneFlag.

/**
 * Test Missing Dependencies with No Done Flag in Schema
 *
 * @throws Exception
 */
public void testDoneFlag() throws Exception {
    Configuration conf = new XConfiguration();
    String appPath = getTestCaseFileUri("coordinator.xml");
    String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=" + "\"2009-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"local_a\" frequency=\"${coord:days(1)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${DAY}") + "</uri-template> " + "</dataset>" + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"local_a\"> <instance>${coord:current(0)}</instance> </data-in>  " + "</input-events> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows2/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
    writeToFile(appXml, appPath);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
    conf.set(OozieClient.USER_NAME, getTestUser());
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    final String jobId = ce.submitJob(conf, true);
    waitFor(5000, new Predicate() {

        public boolean evaluate() throws Exception {
            try {
                List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
                for (CoordinatorAction action : actions) {
                    CoordinatorAction.Status actionStatus = action.getStatus();
                    if (actionStatus == CoordinatorAction.Status.WAITING) {
                        return true;
                    }
                }
            } catch (Exception ex) {
                return false;
            }
            return false;
        }
    });
    List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
    assertTrue(actions.size() > 0);
    CoordinatorAction action = actions.get(0);
    String missingDeps = action.getMissingDependencies();
    System.out.println("Missing deps=" + missingDeps);
    // done flag is not added to the missing dependency list
    assertEquals(getTestCaseFileUri("workflows/2009/01/_SUCCESS"), missingDeps);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) List(java.util.List) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Example 25 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.

the class TestCoordinatorEngine method testDoneFlagCreation.

/**
 * Test Missing Dependencies with Done Flag in Schema
 *
 * @throws Exception
 */
public void testDoneFlagCreation() throws Exception {
    Configuration conf = new XConfiguration();
    String appPath = getTestCaseFileUri("coordinator.xml");
    String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=" + "\"2009-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"local_a\" frequency=\"${coord:days(1)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${MONTH}/${DAY}") + "</uri-template> " + "<done-flag>consume_me</done-flag> </dataset>" + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"local_a\"> <instance>${coord:current(0)}</instance> </data-in>  " + "</input-events> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows2/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
    writeToFile(appXml, appPath);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
    conf.set(OozieClient.USER_NAME, getTestUser());
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    final String jobId = ce.submitJob(conf, true);
    // create done flag
    new File(getTestCaseDir(), "workflows/2009/02/01/consume_me").mkdirs();
    waitFor(10000, new Predicate() {

        public boolean evaluate() throws Exception {
            try {
                List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
                for (CoordinatorAction action : actions) {
                    CoordinatorAction.Status actionStatus = action.getStatus();
                    if (actionStatus == CoordinatorAction.Status.SUBMITTED) {
                        return true;
                    }
                }
            } catch (Exception ex) {
                return false;
            }
            return false;
        }
    });
    List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
    assertTrue(actions.size() > 0);
    CoordinatorAction action = actions.get(0);
    System.out.println("status=" + action.getStatus());
    String missingDeps = action.getMissingDependencies();
    System.out.println("..Missing deps=" + missingDeps);
    if (!(missingDeps == null || missingDeps.equals(""))) {
        fail();
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) List(java.util.List) File(java.io.File) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Aggregations

CoordinatorAction (org.apache.oozie.client.CoordinatorAction)28 IOException (java.io.IOException)11 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)11 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)9 XConfiguration (org.apache.oozie.util.XConfiguration)8 Configuration (org.apache.hadoop.conf.Configuration)7 List (java.util.List)6 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)6 CommandException (org.apache.oozie.command.CommandException)6 StoreException (org.apache.oozie.store.StoreException)6 CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)4 CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)4 File (java.io.File)3 BundleJob (org.apache.oozie.client.BundleJob)3 JDOMException (org.jdom.JDOMException)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 URI (java.net.URI)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2 BulkResponse (org.apache.oozie.client.BulkResponse)2 OozieClientException (org.apache.oozie.client.OozieClientException)2