Search in sources :

Example 11 with WorkflowAppService

use of org.apache.oozie.service.WorkflowAppService in project oozie by apache.

the class TestJavaActionExecutor method createWorkflow.

private WorkflowJobBean createWorkflow(WorkflowApp app, Configuration conf, String authToken) throws Exception {
    WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
    Configuration protoActionConf = wps.createProtoActionConf(conf, true);
    WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
    WorkflowInstance wfInstance;
    wfInstance = workflowLib.createInstance(app, conf);
    WorkflowJobBean workflow = new WorkflowJobBean();
    workflow.setId(wfInstance.getId());
    workflow.setAppName(app.getName());
    workflow.setAppPath(conf.get(OozieClient.APP_PATH));
    workflow.setConf(XmlUtils.prettyPrint(conf).toString());
    workflow.setProtoActionConf(XmlUtils.prettyPrint(protoActionConf).toString());
    workflow.setCreatedTime(new Date());
    workflow.setLogToken(conf.get(OozieClient.LOG_TOKEN, ""));
    workflow.setStatus(WorkflowJob.Status.PREP);
    workflow.setRun(0);
    workflow.setUser(conf.get(OozieClient.USER_NAME));
    workflow.setGroup(conf.get(OozieClient.GROUP_NAME));
    workflow.setWorkflowInstance(wfInstance);
    return workflow;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowLib(org.apache.oozie.workflow.WorkflowLib) WorkflowAppService(org.apache.oozie.service.WorkflowAppService) WorkflowStoreService(org.apache.oozie.service.WorkflowStoreService) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date)

Example 12 with WorkflowAppService

use of org.apache.oozie.service.WorkflowAppService in project oozie by apache.

the class TestSubWorkflowActionExecutor method testSubworkflowLib.

public void testSubworkflowLib() throws Exception {
    XConfiguration protoConf = getBaseProtoConf();
    WorkflowJobBean workflow = createBaseWorkflow(protoConf, "W");
    FileSystem fs = getFileSystem();
    Path parentLibJar = new Path(getFsTestCaseDir(), "lib/parentLibrary.jar");
    fs.create(parentLibJar);
    assertTrue(fs.exists(parentLibJar));
    String defaultConf = workflow.getConf();
    XConfiguration newConf = new XConfiguration(new StringReader(defaultConf));
    newConf.set(OozieClient.LIBPATH, parentLibJar.getParent().toString());
    workflow.setConf(newConf.toXmlString());
    Path subWorkflowAppPath = new Path(getFsTestCaseDir().toString(), "subwf");
    Path workflowPath = new Path(subWorkflowAppPath, "workflow.xml");
    Writer writer = new OutputStreamWriter(fs.create(workflowPath));
    writer.write(APP1);
    writer.close();
    Path subwfLibJar = new Path(subWorkflowAppPath, "lib/subwfLibrary.jar");
    fs.create(subwfLibJar);
    assertTrue(fs.exists(subwfLibJar));
    final WorkflowActionBean action = (WorkflowActionBean) workflow.getActions().get(0);
    action.setConf("<sub-workflow xmlns='uri:oozie:workflow:0.1' name='subwf'>" + "      <app-path>" + workflowPath.toString() + "</app-path>" + "</sub-workflow>");
    SubWorkflowActionExecutor subWorkflow = new SubWorkflowActionExecutor();
    subWorkflow.start(new Context(workflow, action), action);
    final OozieClient oozieClient = subWorkflow.getWorkflowClient(new Context(workflow, action), SubWorkflowActionExecutor.LOCAL);
    waitFor(JOB_TIMEOUT, new Predicate() {

        public boolean evaluate() throws Exception {
            return oozieClient.getJobInfo(action.getExternalId()).getStatus() == WorkflowJob.Status.SUCCEEDED;
        }
    });
    assertEquals(WorkflowJob.Status.SUCCEEDED, oozieClient.getJobInfo(action.getExternalId()).getStatus());
    subWorkflow.check(new Context(workflow, action), action);
    assertEquals(WorkflowAction.Status.DONE, action.getStatus());
    subWorkflow.end(new Context(workflow, action), action);
    assertEquals(WorkflowAction.Status.OK, action.getStatus());
    WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
    WorkflowJob wf = oozieClient.getJobInfo(action.getExternalId());
    Configuration childConf = getWorkflowConfig(wf);
    childConf = wps.createProtoActionConf(childConf, true);
    assertEquals(childConf.get(WorkflowAppService.APP_LIB_PATH_LIST), subwfLibJar.toString());
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowAppService(org.apache.oozie.service.WorkflowAppService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) XConfiguration(org.apache.oozie.util.XConfiguration) OozieClient(org.apache.oozie.client.OozieClient) FileSystem(org.apache.hadoop.fs.FileSystem) WorkflowJob(org.apache.oozie.client.WorkflowJob)

Example 13 with WorkflowAppService

use of org.apache.oozie.service.WorkflowAppService in project oozie by apache.

the class TestSubmitMRXCommand method testWFXmlGenerationNewConfigProps.

public void testWFXmlGenerationNewConfigProps() throws Exception {
    try {
        Configuration conf = new Configuration(false);
        conf.set(XOozieClient.NN, "new_NN");
        conf.set(XOozieClient.RM, "new_JT");
        conf.set("mapred.mapper.class", "TestMapper");
        conf.set("mapred.reducer.class", "TestReducer");
        conf.set("mapred.input.dir", "testInput");
        conf.set("mapred.output.dir", "testOutput");
        conf.set(OozieClient.LIBPATH, "libpath");
        conf.set("mapreduce.job.user.name", "test_user");
        SubmitMRXCommand submitMRCmd = new SubmitMRXCommand(conf);
        String xml = submitMRCmd.getWorkflowXml(conf);
        // verifying is a valid WF
        WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
        wps.parseDef(xml, conf);
        Element wfE = XmlUtils.parseXml(xml);
        Namespace ns = wfE.getNamespace();
        Element actionE = wfE.getChild("action", ns).getChild("map-reduce", ns);
        Element nnE = actionE.getChild("name-node", ns);
        assertEquals(nnE.getTextTrim(), "new_NN");
        Element jtE = actionE.getChild("job-tracker", ns);
        assertEquals(jtE.getTextTrim(), "new_JT");
    } catch (Exception e) {
        fail("should have passed");
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) WorkflowAppService(org.apache.oozie.service.WorkflowAppService) Element(org.jdom.Element) Namespace(org.jdom.Namespace)

Example 14 with WorkflowAppService

use of org.apache.oozie.service.WorkflowAppService in project oozie by apache.

the class TestDBWorkflowStore method createWorkflow.

private WorkflowJobBean createWorkflow(WorkflowApp app, Configuration conf, String authToken) throws Exception {
    WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
    Configuration protoActionConf = wps.createProtoActionConf(conf, true);
    WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
    WorkflowInstance wfInstance;
    wfInstance = workflowLib.createInstance(app, conf);
    WorkflowJobBean workflow = new WorkflowJobBean();
    workflow.setId(wfInstance.getId());
    workflow.setAppName(app.getName());
    workflow.setAppPath(conf.get(OozieClient.APP_PATH));
    workflow.setConf(XmlUtils.prettyPrint(conf).toString());
    workflow.setProtoActionConf(XmlUtils.prettyPrint(protoActionConf).toString());
    workflow.setCreatedTime(new Date());
    workflow.setLogToken(conf.get(OozieClient.LOG_TOKEN, ""));
    workflow.setStatus(WorkflowJob.Status.PREP);
    workflow.setRun(0);
    workflow.setUser(conf.get(OozieClient.USER_NAME));
    workflow.setGroup(conf.get(OozieClient.GROUP_NAME));
    workflow.setWorkflowInstance(wfInstance);
    return workflow;
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) WorkflowLib(org.apache.oozie.workflow.WorkflowLib) WorkflowAppService(org.apache.oozie.service.WorkflowAppService) WorkflowStoreService(org.apache.oozie.service.WorkflowStoreService) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date)

Example 15 with WorkflowAppService

use of org.apache.oozie.service.WorkflowAppService in project oozie by apache.

the class TestOozieSharelibCLI method getDistPath.

private Path getDistPath() throws Exception {
    if (dstPath == null) {
        WorkflowAppService lwas = getServices().get(WorkflowAppService.class);
        dstPath = lwas.getSystemLibPath();
    }
    return dstPath;
}
Also used : WorkflowAppService(org.apache.oozie.service.WorkflowAppService)

Aggregations

WorkflowAppService (org.apache.oozie.service.WorkflowAppService)15 Configuration (org.apache.hadoop.conf.Configuration)13 Date (java.util.Date)10 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)9 XConfiguration (org.apache.oozie.util.XConfiguration)9 Path (org.apache.hadoop.fs.Path)7 WorkflowStoreService (org.apache.oozie.service.WorkflowStoreService)7 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)7 WorkflowLib (org.apache.oozie.workflow.WorkflowLib)7 Element (org.jdom.Element)6 URI (java.net.URI)4 FileSystem (org.apache.hadoop.fs.FileSystem)4 LiteWorkflowStoreService (org.apache.oozie.service.LiteWorkflowStoreService)4 IOException (java.io.IOException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Map (java.util.Map)3 CommandException (org.apache.oozie.command.CommandException)3 HadoopAccessorService (org.apache.oozie.service.HadoopAccessorService)3 WorkflowApp (org.apache.oozie.workflow.WorkflowApp)3 WorkflowException (org.apache.oozie.workflow.WorkflowException)3