Search in sources :

Example 6 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class TestShareLibService method testConfFileAddedToActionConf.

@Test
public void testConfFileAddedToActionConf() throws Exception {
    try {
        XConfiguration protoConf = new XConfiguration();
        protoConf.set(WorkflowAppService.HADOOP_USER, getTestUser());
        WorkflowJobBean wfj = new WorkflowJobBean();
        protoConf.setBoolean(OozieClient.USE_SYSTEM_LIBPATH, true);
        wfj.setProtoActionConf(XmlUtils.prettyPrint(protoConf).toString());
        wfj.setConf(XmlUtils.prettyPrint(protoConf).toString());
        Context context = new TestJavaActionExecutor().new Context(wfj, new WorkflowActionBean());
        // Test hive-site.xml in sharelib cache
        setupSharelibConf("hive-site.xml", "oozie.hive_conf");
        ShareLibService shareLibService = services.get(ShareLibService.class);
        assertEquals(shareLibService.getShareLibConfigMap().get("hive_conf").values().size(), 1);
        assertEquals(shareLibService.getShareLibConfigMap().get("hive_conf").keySet().toArray(new Path[] {})[0].getName(), "hive-site.xml");
        // Test hive-site.xml not in distributed cache
        setupSharelibConf("hive-site.xml", "oozie.hive_conf");
        String actionXml = "<hive>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<script>test</script>" + "</hive>";
        Element eActionXml = XmlUtils.parseXml(actionXml);
        HiveActionExecutor ae = new HiveActionExecutor();
        Configuration jobConf = ae.createBaseHadoopConf(context, eActionXml);
        Configuration actionConf = ae.createBaseHadoopConf(context, eActionXml);
        jobConf.set("oozie.action.sharelib.for.hive", "hive_conf");
        ae.setLibFilesArchives(context, eActionXml, new Path("hdfs://dummyAppPath"), jobConf);
        URI[] cacheFiles = DistributedCache.getCacheFiles(actionConf);
        String cacheFilesStr = Arrays.toString(cacheFiles);
        assertFalse(cacheFilesStr.contains("hive-site.xml"));
        // Test hive-site.xml property in jobconf with linkname
        jobConf = ae.createBaseHadoopConf(context, eActionXml);
        Properties prop = new Properties();
        actionConf = ae.createBaseHadoopConf(context, eActionXml);
        prop.put("oozie.hive_conf", TEST_HDFS_HOME + SHARELIB_PATH + "hive-site.xml#hive-site.xml");
        setupSharelibConf("hive-site.xml", "oozie.hive_conf", prop);
        jobConf.set("oozie.action.sharelib.for.hive", "hive_conf");
        ae.setLibFilesArchives(context, eActionXml, new Path("hdfs://dummyAppPath"), jobConf);
        assertEquals(jobConf.get("oozie.hive_conf-sharelib-test"), "test");
        // Test hive-site.xml property in jobconf with linkname
        // and with hdfs path
        prop = new Properties();
        jobConf = ae.createBaseHadoopConf(context, eActionXml);
        actionConf = ae.createBaseHadoopConf(context, eActionXml);
        prop.put("oozie.hive_conf", "hdfs://" + TEST_HDFS_HOME + SHARELIB_PATH + "hive-site.xml#hive-site.xml");
        setupSharelibConf("hive-site.xml", "oozie.hive_conf", prop);
        jobConf.set("oozie.action.sharelib.for.hive", "hive_conf");
        ae.setLibFilesArchives(context, eActionXml, new Path("hdfs://dummyAppPath"), jobConf);
        assertEquals(jobConf.get("oozie.hive_conf-sharelib-test"), "test");
        cacheFiles = DistributedCache.getCacheFiles(actionConf);
        cacheFilesStr = Arrays.toString(cacheFiles);
        assertFalse(cacheFilesStr.contains("hive-site.xml"));
        // Test hive-site.xml property in jobconf with non hdfs path
        prop = new Properties();
        jobConf = ae.createBaseHadoopConf(context, eActionXml);
        actionConf = ae.createBaseHadoopConf(context, eActionXml);
        prop.put("oozie.hive_conf", TEST_HDFS_HOME + SHARELIB_PATH + "hive-site.xml");
        setupSharelibConf("hive-site.xml", "oozie.hive_conf", prop);
        jobConf.set("oozie.action.sharelib.for.hive", "hive_conf");
        ae.setLibFilesArchives(context, eActionXml, new Path("hdfs://dummyAppPath"), jobConf);
        assertEquals(jobConf.get("oozie.hive_conf-sharelib-test"), "test");
        cacheFiles = DistributedCache.getCacheFiles(actionConf);
        cacheFilesStr = Arrays.toString(cacheFiles);
        assertFalse(cacheFilesStr.contains("hive-site.xml"));
        // Test hive-site.xml property in jobconf with non hdfs path with
        // link name
        prop = new Properties();
        jobConf = ae.createBaseHadoopConf(context, eActionXml);
        actionConf = ae.createBaseHadoopConf(context, eActionXml);
        prop.put("oozie.hive_conf", TEST_HDFS_HOME + SHARELIB_PATH + "hive-site.xml#hive-site.xml");
        setupSharelibConf("hive-site.xml", "oozie.hive_conf", prop);
        jobConf.set("oozie.action.sharelib.for.hive", "hive_conf");
        ae.setLibFilesArchives(context, eActionXml, new Path("hdfs://dummyAppPath"), jobConf);
        assertEquals(jobConf.get("oozie.hive_conf-sharelib-test"), "test");
        cacheFiles = DistributedCache.getCacheFiles(actionConf);
        cacheFilesStr = Arrays.toString(cacheFiles);
        assertFalse(cacheFilesStr.contains("hive-site.xml"));
    } finally {
        getFileSystem().delete(new Path(SHARELIB_PATH), true);
    }
}
Also used : Context(org.apache.oozie.action.hadoop.ActionExecutorTestCase.Context) Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Element(org.jdom.Element) TestJavaActionExecutor(org.apache.oozie.action.hadoop.TestJavaActionExecutor) Properties(java.util.Properties) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) URI(java.net.URI) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) XConfiguration(org.apache.oozie.util.XConfiguration) HiveActionExecutor(org.apache.oozie.action.hadoop.HiveActionExecutor) Test(org.junit.Test)

Example 7 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class MockCoordinatorEngineService method createDummyCoordWfAction.

private static CoordinatorWfActionBean createDummyCoordWfAction(String name, int id) {
    CoordinatorWfActionBean coordWfAction = null;
    WorkflowActionBean wfAction = new WorkflowActionBean();
    wfAction.setName(name);
    coordWfAction = new CoordinatorWfActionBean(id, wfAction, null);
    return coordWfAction;
}
Also used : WorkflowActionBean(org.apache.oozie.WorkflowActionBean) CoordinatorWfActionBean(org.apache.oozie.CoordinatorWfActionBean)

Example 8 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class MockDagEngineService method createDummyWorkflow.

private static WorkflowJob createDummyWorkflow(int idx, String conf) {
    WorkflowJobBean workflow = new WorkflowJobBean();
    workflow.setId(JOB_ID + idx + JOB_ID_END);
    workflow.setAppPath("hdfs://blah/blah/" + idx + "-blah");
    workflow.setStatus((idx % 2) == 0 ? WorkflowJob.Status.RUNNING : WorkflowJob.Status.SUCCEEDED);
    workflow.setRun(idx);
    workflow.setCreatedTime(new Date());
    workflow.setStartTime(new Date());
    workflow.setEndTime((idx % 2) == 0 ? null : (new Date()));
    workflow.setConf(conf);
    workflow.setAppName("workflow-" + idx);
    workflow.setGroup(GROUP);
    workflow.setUser(USER);
    List<WorkflowActionBean> actions = new ArrayList<WorkflowActionBean>();
    for (int i = 0; i < idx; i++) {
        actions.add(createDummyAction(i));
    }
    workflow.setActions(actions);
    return workflow;
}
Also used : ArrayList(java.util.ArrayList) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 9 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class TestJMSTopicService method testMixedTopic1.

@Test
public void testMixedTopic1() throws Exception {
    services = setupServicesForTopic();
    services.getConf().set(JMSTopicService.TOPIC_NAME, JMSTopicService.JobType.WORKFLOW.getValue() + " = workflow," + JMSTopicService.JobType.COORDINATOR.getValue() + "=coord, default = " + JMSTopicService.TopicType.JOBID.getValue());
    services.init();
    JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
    WorkflowJobBean wfj = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    assertEquals("workflow", jmsTopicService.getTopic(wfj.getId()));
    assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_JOB, wfj.getUser(), wfj.getId(), null));
    WorkflowActionBean wab = addRecordToWfActionTable(wfj.getId(), "1", WorkflowAction.Status.RUNNING);
    assertEquals("workflow", jmsTopicService.getTopic(wab.getId()));
    assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_ACTION, wfj.getUser(), wab.getId(), wab.getWfId()));
    CoordinatorJobBean cjb = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, true, true);
    assertEquals("coord", jmsTopicService.getTopic(cjb.getId()));
    assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_JOB, cjb.getUser(), cjb.getId(), null));
    CoordinatorActionBean cab = addRecordToCoordActionTable(cjb.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-for-action-input-check.xml", 0);
    assertEquals("coord", jmsTopicService.getTopic(cab.getId()));
    assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_ACTION, cjb.getUser(), cab.getId(), cab.getJobId()));
    BundleJobBean bjb = addRecordToBundleJobTable(Job.Status.RUNNING, true);
    assertEquals(bjb.getId(), jmsTopicService.getTopic(bjb.getId()));
    assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_JOB, bjb.getUser(), bjb.getId(), null));
    BundleActionBean bab = addRecordToBundleActionTable(bjb.getId(), "1", 1, Job.Status.RUNNING);
    assertEquals(bjb.getId(), jmsTopicService.getTopic(bab.getBundleActionId()));
    assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_ACTION, bjb.getUser(), bab.getBundleActionId(), bab.getBundleId()));
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleJobBean(org.apache.oozie.BundleJobBean) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) BundleActionBean(org.apache.oozie.BundleActionBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Test(org.junit.Test)

Example 10 with WorkflowActionBean

use of org.apache.oozie.WorkflowActionBean in project oozie by apache.

the class TestJMSTopicService method testMixedTopic2.

@Test
public void testMixedTopic2() throws Exception {
    services = setupServicesForTopic();
    services.getConf().set(JMSTopicService.TOPIC_NAME, JMSTopicService.JobType.WORKFLOW.getValue() + " = workflow," + JMSTopicService.JobType.COORDINATOR.getValue() + "=coord");
    services.init();
    JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
    WorkflowJobBean wfj = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    assertEquals("workflow", jmsTopicService.getTopic(wfj.getId()));
    assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_JOB, wfj.getUser(), wfj.getId(), null));
    WorkflowActionBean wab = addRecordToWfActionTable(wfj.getId(), "1", WorkflowAction.Status.RUNNING);
    assertEquals("workflow", jmsTopicService.getTopic(wab.getId()));
    assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_ACTION, wfj.getUser(), wab.getId(), wab.getWfId()));
    CoordinatorJobBean cjb = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, true, true);
    assertEquals("coord", jmsTopicService.getTopic(cjb.getId()));
    CoordinatorActionBean cab = addRecordToCoordActionTable(cjb.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-for-action-input-check.xml", 0);
    assertEquals("coord", jmsTopicService.getTopic(cab.getId()));
    assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_ACTION, cjb.getUser(), cab.getId(), cab.getJobId()));
    BundleJobBean bjb = addRecordToBundleJobTable(Job.Status.RUNNING, true);
    // As no default is specified, user will be considered as topic
    assertEquals(bjb.getUser(), jmsTopicService.getTopic(bjb.getId()));
    assertEquals(bjb.getUser(), jmsTopicService.getTopic(AppType.BUNDLE_JOB, bjb.getUser(), bjb.getId(), null));
    BundleActionBean bab = addRecordToBundleActionTable(bjb.getId(), "1", 1, Job.Status.RUNNING);
    assertEquals(bjb.getUser(), jmsTopicService.getTopic(bab.getBundleActionId()));
    assertEquals(bjb.getUser(), jmsTopicService.getTopic(AppType.BUNDLE_ACTION, bjb.getUser(), bab.getBundleActionId(), bab.getBundleId()));
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleJobBean(org.apache.oozie.BundleJobBean) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) BundleActionBean(org.apache.oozie.BundleActionBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Test(org.junit.Test)

Aggregations

WorkflowActionBean (org.apache.oozie.WorkflowActionBean)249 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)164 XConfiguration (org.apache.oozie.util.XConfiguration)84 JPAService (org.apache.oozie.service.JPAService)79 Configuration (org.apache.hadoop.conf.Configuration)56 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)51 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)51 Path (org.apache.hadoop.fs.Path)48 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)42 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)32 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)32 ArrayList (java.util.ArrayList)30 Date (java.util.Date)29 Element (org.jdom.Element)29 FileSystem (org.apache.hadoop.fs.FileSystem)25 Writer (java.io.Writer)22 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)21 IOException (java.io.IOException)20 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)18