private void checkCoordActions(String jobId, int number, CoordinatorJob.Status status) {
    try {
      JPAService jpaService = Services.get().get(JPAService.class);
      List<CoordinatorActionBean> actions =
          jpaService.execute(new CoordJobGetActionsJPAExecutor(jobId));
      if (actions.size() != number) {
        fail(
            "Should have "
                + number
                + " actions created for job "
                + jobId
                + ", but jave "
                + actions.size()
                + " 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();
      fail("Job ID " + jobId + " was not stored properly in db");
    }
  }
예제 #2
0
  /**
   * Run recipe with different frequencies. Submission should go through. Check frequency of the
   * launched oozie job
   */
  @Test(dataProvider = "frequencyGenerator")
  public void differentRecipeFrequenciesTest(String frequency) throws Exception {
    setUp(RecipeExecLocation.SourceCluster);
    LOGGER.info("Testing with frequency: " + frequency);
    String tblName = "myTable";
    recipeMerlin
        .withSourceDb(DB_NAME)
        .withSourceTable(tblName)
        .withFrequency(new Frequency(frequency));
    runSql(connection, "create table " + tblName + "(comment string)");
    final List<String> command = recipeMerlin.getSubmissionCommand();
    Assert.assertEquals(Bundle.runFalconCLI(command), 0, "Recipe submission failed.");
    LOGGER.info("Submission went through.");

    InstanceUtil.waitTillInstanceReachState(
        clusterOC, recipeMerlin.getName(), 1, CoordinatorAction.Status.RUNNING, EntityType.PROCESS);
    String filter = "name=FALCON_PROCESS_" + recipeMerlin.getName();
    List<BundleJob> bundleJobs = OozieUtil.getBundles(clusterOC, filter, 0, 10);
    List<String> bundleIds = OozieUtil.getBundleIds(bundleJobs);
    String bundleId = OozieUtil.getMaxId(bundleIds);
    List<CoordinatorJob> coords = clusterOC.getBundleJobInfo(bundleId).getCoordinators();
    List<String> cIds = new ArrayList<String>();
    for (CoordinatorJob coord : coords) {
      cIds.add(coord.getId());
    }
    String coordId = OozieUtil.getMinId(cIds);
    CoordinatorJob job = clusterOC.getCoordJobInfo(coordId);
    CoordinatorJob.Timeunit timeUnit = job.getTimeUnit();
    String freq = job.getFrequency();
    LOGGER.info("Frequency of running job: " + timeUnit + " " + freq);
    Assert.assertTrue(
        frequency.contains(timeUnit.name().toLowerCase().replace("_", ""))
            && frequency.contains(freq),
        "Running job has different frequency.");
  }
예제 #3
0
 private CoordinatorActionBean createCoordinatorActionBean(CoordinatorJob job) throws IOException {
   CoordinatorActionBean actionBean = new CoordinatorActionBean();
   String actionId = Services.get().get(UUIDService.class).generateChildId(job.getId(), "1");
   actionBean.setJobId(job.getId());
   actionBean.setId(actionId);
   Configuration jobConf = new XConfiguration(new StringReader(job.getConf()));
   actionBean.setRunConf(XmlUtils.prettyPrint(jobConf).toString());
   return actionBean;
 }
 /*
  * Retrieves replication coordinator instances.
  * @param client target oozie client
  * @param fName feed name
  */
 private List<CoordinatorAction> getReplicationInstances(OozieClient client, String fName)
     throws OozieClientException {
   String filter = "name=FALCON_FEED_" + fName;
   List<BundleJob> bundleJobs = OozieUtil.getBundles(client, filter, 0, 10);
   Assert.assertNotEquals(bundleJobs.size(), 0, "Could not retrieve bundles");
   List<String> bundleIds = OozieUtil.getBundleIds(bundleJobs);
   String bundleId = OozieUtil.getMaxId(bundleIds);
   LOGGER.info(String.format("Using bundle %s", bundleId));
   List<CoordinatorJob> coords = client.getBundleJobInfo(bundleId).getCoordinators();
   String coordId = null;
   for (CoordinatorJob coord : coords) {
     if (coord.getAppName().contains("FEED_REPLICATION")) {
       coordId = coord.getId();
       break;
     }
   }
   LOGGER.info(String.format("Using coordinator id: %s", coordId));
   Assert.assertNotNull(coordId, "Replication coordinator not found.");
   CoordinatorJob coordinatorJob = client.getCoordJobInfo(coordId);
   return coordinatorJob.getActions();
 }