Search in sources :

Example 96 with WorkflowActionBean

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

the class TestJavaActionExecutor method createContext.

protected Context createContext(String actionXml, String group) throws Exception {
    JavaActionExecutor ae = new JavaActionExecutor();
    Path appJarPath = new Path("lib/test.jar");
    File jarFile = IOUtils.createJar(new File(getTestCaseDir()), "test.jar", LauncherMainTester.class);
    InputStream is = new FileInputStream(jarFile);
    OutputStream os = getFileSystem().create(new Path(getAppPath(), "lib/test.jar"));
    IOUtils.copyStream(is, os);
    Path appSoPath = new Path("lib/test.so");
    getFileSystem().create(new Path(getAppPath(), appSoPath)).close();
    XConfiguration protoConf = new XConfiguration();
    protoConf.set(WorkflowAppService.HADOOP_USER, getTestUser());
    protoConf.setStrings(WorkflowAppService.APP_LIB_PATH_LIST, appJarPath.toString(), appSoPath.toString());
    WorkflowJobBean wf = createBaseWorkflow(protoConf, "action");
    if (group != null) {
        wf.setGroup(group);
    }
    WorkflowActionBean action = (WorkflowActionBean) wf.getActions().get(0);
    action.setType(ae.getType());
    action.setConf(actionXml);
    return new Context(wf, action);
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) FileInputStream(java.io.FileInputStream) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 97 with WorkflowActionBean

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

the class TestJavaActionExecutor method addRecordToWfJobTable.

private WorkflowJobBean addRecordToWfJobTable(String wfId, String wfxml, Map<String, String> otherProps) throws Exception {
    WorkflowApp app = new LiteWorkflowApp("testApp", wfxml, new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "start")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
    Configuration conf = getHadoopAccessorService().createConfiguration(new URI(getNameNodeUri()).getAuthority());
    conf.set(OozieClient.APP_PATH, getNameNodeUri() + "/testPath");
    conf.set(OozieClient.LOG_TOKEN, "testToken");
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set("property3", "prop3");
    conf.set("value3", "val3");
    if (otherProps != null) {
        for (Map.Entry<String, String> ent : otherProps.entrySet()) {
            conf.set(ent.getKey(), ent.getValue());
        }
    }
    WorkflowJobBean wfBean = createWorkflow(app, conf, "auth");
    wfBean.setId(wfId);
    wfBean.setStatus(WorkflowJob.Status.SUCCEEDED);
    WorkflowActionBean action = new WorkflowActionBean();
    action.setName("test");
    action.setId(Services.get().get(UUIDService.class).generateChildId(wfBean.getId(), "test"));
    wfBean.getActions().add(action);
    return wfBean;
}
Also used : WorkflowApp(org.apache.oozie.workflow.WorkflowApp) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) EndNodeDef(org.apache.oozie.workflow.lite.EndNodeDef) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) LiteWorkflowApp(org.apache.oozie.workflow.lite.LiteWorkflowApp) URI(java.net.URI) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) StartNodeDef(org.apache.oozie.workflow.lite.StartNodeDef) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) LiteWorkflowStoreService(org.apache.oozie.service.LiteWorkflowStoreService) Map(java.util.Map)

Example 98 with WorkflowActionBean

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

the class TestJavaActionExecutor method testCredentialsModule.

public void testCredentialsModule() throws Exception {
    String actionXml = "<workflow-app xmlns='uri:oozie:workflow:0.2.5' name='pig-wf'>" + "<credentials>" + "<credential name='abcname' type='abc'>" + "<property>" + "<name>property1</name>" + "<value>value1</value>" + "</property>" + "<property>" + "<name>property2</name>" + "<value>value2</value>" + "</property>" + "<property>" + "<name>${property3}</name>" + "<value>${value3}</value>" + "</property>" + "</credential>" + "</credentials>" + "<start to='pig1' />" + "<action name='pig1' cred='abcname'>" + "<pig>" + "</pig>" + "<ok to='end' />" + "<error to='fail' />" + "</action>" + "<kill name='fail'>" + "<message>Pig failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>" + "</kill>" + "<end name='end' />" + "</workflow-app>";
    JavaActionExecutor ae = new JavaActionExecutor();
    WorkflowJobBean wfBean = addRecordToWfJobTable("test1", actionXml);
    WorkflowActionBean action = (WorkflowActionBean) wfBean.getActions().get(0);
    action.setType(ae.getType());
    action.setCred("abcname");
    String actionxml = "<pig>" + "<job-tracker>${jobTracker}</job-tracker>" + "<name-node>${nameNode}</name-node>" + "<prepare>" + "<delete path='outputdir' />" + "</prepare>" + "<configuration>" + "<property>" + "<name>mapred.compress.map.output</name>" + "<value>true</value>" + "</property>" + "<property>" + "<name>mapred.job.queue.name</name>" + "<value>${queueName}</value>" + "</property>" + "</configuration>" + "<script>org/apache/oozie/examples/pig/id.pig</script>" + "<param>INPUT=${inputDir}</param>" + "<param>OUTPUT=${outputDir}/pig-output</param>" + "</pig>";
    action.setConf(actionxml);
    Context context = new Context(wfBean, action);
    Element actionXmlconf = XmlUtils.parseXml(action.getConf());
    // action job configuration
    Configuration actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
    // Setting the credential properties in launcher conf
    Map<String, CredentialsProperties> credProperties = ae.setCredentialPropertyToActionConf(context, action, actionConf);
    assertNotNull(credProperties);
    CredentialsProperties prop = credProperties.get("abcname");
    assertEquals("value1", prop.getProperties().get("property1"));
    assertEquals("value2", prop.getProperties().get("property2"));
    assertEquals("val3", prop.getProperties().get("prop3"));
    // Try to load the token without it being defined in oozie-site; should get an exception
    CredentialsProviderFactory.destroy();
    JobConf credentialsConf = new JobConf();
    Credentials credentials = new Credentials();
    Configuration launcherConf = ae.createBaseHadoopConf(context, actionXmlconf);
    XConfiguration.copy(launcherConf, credentialsConf);
    try {
        ae.setCredentialTokens(credentials, credentialsConf, context, action, credProperties);
        fail("Should have gotten an exception but did not");
    } catch (ActionExecutorException aee) {
        assertEquals("JA020", aee.getErrorCode());
        assertTrue(aee.getMessage().contains("type [abc]"));
        assertTrue(aee.getMessage().contains("name [abcname]"));
    }
    CredentialsProviderFactory.destroy();
    // Define 'abc' token type in oozie-site
    ConfigurationService.set("oozie.credentials.credentialclasses", "abc=org.apache.oozie.action.hadoop.InsertTestToken");
    // Try to load the token after being defined in oozie-site; should work correctly
    credentialsConf = new JobConf();
    credentials = new Credentials();
    launcherConf = ae.createBaseHadoopConf(context, actionXmlconf);
    XConfiguration.copy(launcherConf, credentialsConf);
    ae.setCredentialTokens(credentials, credentialsConf, context, action, credProperties);
    Token<? extends TokenIdentifier> tk = credentials.getToken(new Text("ABC Token"));
    assertNotNull(tk);
    byte[] secKey = credentials.getSecretKey(new Text(InsertTestToken.DUMMY_SECRET_KEY));
    assertNotNull(secKey);
    assertEquals(InsertTestToken.DUMMY_SECRET_KEY, new String(secKey, "UTF-8"));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) Text(org.apache.hadoop.io.Text) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) JobConf(org.apache.hadoop.mapred.JobConf) Credentials(org.apache.hadoop.security.Credentials)

Example 99 with WorkflowActionBean

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

the class TestJavaActionExecutor method testJavaOpts.

public void testJavaOpts() throws Exception {
    String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>oozie.launcher.a</name><value>LA</value></property>" + "<property><name>a</name><value>AA</value></property>" + "<property><name>b</name><value>BB</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "<java-opts>JAVA-OPT1 JAVA-OPT2</java-opts>" + "<arg>A1</arg>" + "<arg>A2</arg>" + "<file>f.jar</file>" + "<archive>a.tar</archive>" + "</java>";
    JavaActionExecutor ae = new JavaActionExecutor();
    WorkflowJobBean wfBean = addRecordToWfJobTable("test1", actionXml);
    WorkflowActionBean action = (WorkflowActionBean) wfBean.getActions().get(0);
    action.setType(ae.getType());
    action.setConf(actionXml);
    Context context = new Context(wfBean, action);
    Element actionXmlconf = XmlUtils.parseXml(action.getConf());
    Configuration actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
    Configuration conf = ae.createLauncherConf(getFileSystem(), context, action, actionXmlconf, actionConf);
    assertEquals("-Xmx200m JAVA-OPT1 JAVA-OPT2", conf.get(MAPRED_CHILD_JAVA_OPTS));
    assertEquals("-Xmx200m JAVA-OPT1 JAVA-OPT2", conf.get(MAPREDUCE_MAP_JAVA_OPTS));
    actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>oozie.launcher.a</name><value>LA</value></property>" + "<property><name>a</name><value>AA</value></property>" + "<property><name>b</name><value>BB</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "<java-opt>JAVA-OPT1</java-opt>" + "<java-opt>JAVA-OPT2</java-opt>" + "<arg>A1</arg>" + "<arg>A2</arg>" + "<file>f.jar</file>" + "<archive>a.tar</archive>" + "</java>";
    wfBean = addRecordToWfJobTable("test1", actionXml);
    action = (WorkflowActionBean) wfBean.getActions().get(0);
    action.setType(ae.getType());
    action.setConf(actionXml);
    context = new Context(wfBean, action);
    actionXmlconf = XmlUtils.parseXml(action.getConf());
    actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXmlconf, actionConf);
    assertEquals("-Xmx200m JAVA-OPT1 JAVA-OPT2", conf.get(MAPRED_CHILD_JAVA_OPTS));
    assertEquals("-Xmx200m JAVA-OPT1 JAVA-OPT2", conf.get(MAPREDUCE_MAP_JAVA_OPTS));
    actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>oozie.launcher.a</name><value>LA</value></property>" + "<property><name>a</name><value>AA</value></property>" + "<property><name>b</name><value>BB</value></property>" + "<property><name>oozie.launcher.mapred.child.java.opts</name><value>JAVA-OPT3</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "<java-opt>JAVA-OPT1</java-opt>" + "<java-opt>JAVA-OPT2</java-opt>" + "<arg>A1</arg>" + "<arg>A2</arg>" + "<file>f.jar</file>" + "<archive>a.tar</archive>" + "</java>";
    wfBean = addRecordToWfJobTable("test1", actionXml);
    action = (WorkflowActionBean) wfBean.getActions().get(0);
    action.setType(ae.getType());
    action.setConf(actionXml);
    context = new Context(wfBean, action);
    actionXmlconf = XmlUtils.parseXml(action.getConf());
    actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXmlconf, actionConf);
    assertEquals("JAVA-OPT3 JAVA-OPT1 JAVA-OPT2", conf.get(MAPRED_CHILD_JAVA_OPTS));
    assertEquals("JAVA-OPT3 JAVA-OPT1 JAVA-OPT2", conf.get(MAPREDUCE_MAP_JAVA_OPTS));
    actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>oozie.launcher.a</name><value>LA</value></property>" + "<property><name>a</name><value>AA</value></property>" + "<property><name>b</name><value>BB</value></property>" + "<property><name>oozie.launcher.mapreduce.map.java.opts</name><value>JAVA-OPT3</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "<java-opt>JAVA-OPT1</java-opt>" + "<java-opt>JAVA-OPT2</java-opt>" + "<arg>A1</arg>" + "<arg>A2</arg>" + "<file>f.jar</file>" + "<archive>a.tar</archive>" + "</java>";
    wfBean = addRecordToWfJobTable("test1", actionXml);
    action = (WorkflowActionBean) wfBean.getActions().get(0);
    action.setType(ae.getType());
    action.setConf(actionXml);
    context = new Context(wfBean, action);
    actionXmlconf = XmlUtils.parseXml(action.getConf());
    actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXmlconf, actionConf);
    assertEquals("-Xmx200m JAVA-OPT3 JAVA-OPT1 JAVA-OPT2", conf.get(MAPRED_CHILD_JAVA_OPTS));
    assertEquals("-Xmx200m JAVA-OPT3 JAVA-OPT1 JAVA-OPT2", conf.get(MAPREDUCE_MAP_JAVA_OPTS));
    actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>oozie.launcher.a</name><value>LA</value></property>" + "<property><name>a</name><value>AA</value></property>" + "<property><name>b</name><value>BB</value></property>" + "<property><name>oozie.launcher.mapred.child.java.opts</name><value>JAVA-OPT3</value></property>" + "<property><name>oozie.launcher.mapreduce.map.java.opts</name><value>JAVA-OPT4</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "<java-opt>JAVA-OPT1</java-opt>" + "<java-opt>JAVA-OPT2</java-opt>" + "<arg>A1</arg>" + "<arg>A2</arg>" + "<file>f.jar</file>" + "<archive>a.tar</archive>" + "</java>";
    wfBean = addRecordToWfJobTable("test1", actionXml);
    action = (WorkflowActionBean) wfBean.getActions().get(0);
    action.setType(ae.getType());
    action.setConf(actionXml);
    context = new Context(wfBean, action);
    actionXmlconf = XmlUtils.parseXml(action.getConf());
    actionConf = ae.createBaseHadoopConf(context, actionXmlconf);
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXmlconf, actionConf);
    assertEquals("JAVA-OPT3 JAVA-OPT4 JAVA-OPT1 JAVA-OPT2", conf.get(MAPRED_CHILD_JAVA_OPTS));
    assertEquals("JAVA-OPT3 JAVA-OPT4 JAVA-OPT1 JAVA-OPT2", conf.get(MAPREDUCE_MAP_JAVA_OPTS));
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom.Element) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 100 with WorkflowActionBean

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

the class TestJavaActionExecutor method testSetupMethods.

public void testSetupMethods() throws Exception {
    JavaActionExecutor ae = new JavaActionExecutor();
    assertEquals(Arrays.asList(JavaMain.class), ae.getLauncherClasses());
    Configuration conf = new XConfiguration();
    conf.set("user.name", "a");
    try {
        JavaActionExecutor.checkForDisallowedProps(conf, "x");
        fail();
    } catch (ActionExecutorException ex) {
    }
    conf = new XConfiguration();
    conf.set(YARN_RESOURCEMANAGER_ADDRESS, "a");
    try {
        JavaActionExecutor.checkForDisallowedProps(conf, "x");
        fail();
    } catch (ActionExecutorException ex) {
    }
    conf = new XConfiguration();
    conf.set("fs.default.name", "a");
    try {
        JavaActionExecutor.checkForDisallowedProps(conf, "x");
        fail();
    } catch (ActionExecutorException ex) {
    }
    conf = new XConfiguration();
    conf.set("a", "a");
    try {
        JavaActionExecutor.checkForDisallowedProps(conf, "x");
    } catch (ActionExecutorException ex) {
        fail();
    }
    Element actionXml = XmlUtils.parseXml("<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<job-xml>job.xml</job-xml>" + "<job-xml>job2.xml</job-xml>" + "<configuration>" + "<property><name>oozie.launcher.a</name><value>LA</value></property>" + "<property><name>a</name><value>AA</value></property>" + "<property><name>b</name><value>BB</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "<java-opts>JAVA-OPTS</java-opts>" + "<arg>A1</arg>" + "<arg>A2</arg>" + "<file>f.jar</file>" + "<archive>a.tar</archive>" + "</java>");
    Path appPath = new Path(getFsTestCaseDir(), "wf");
    Path appJarPath = new Path("lib/a.jar");
    getFileSystem().create(new Path(appPath, appJarPath)).close();
    Path appSoPath = new Path("lib/a.so");
    getFileSystem().create(new Path(appPath, appSoPath)).close();
    Path appSo1Path = new Path("lib/a.so.1");
    String expectedSo1Path = "lib/a.so.1#a.so.1";
    getFileSystem().create(new Path(appPath, appSo1Path)).close();
    Path filePath = new Path("f.jar");
    getFileSystem().create(new Path(appPath, filePath)).close();
    Path archivePath = new Path("a.tar");
    getFileSystem().create(new Path(appPath, archivePath)).close();
    XConfiguration protoConf = new XConfiguration();
    protoConf.set(WorkflowAppService.HADOOP_USER, getTestUser());
    protoConf.setStrings(WorkflowAppService.APP_LIB_PATH_LIST, appJarPath.toString(), appSoPath.toString());
    WorkflowJobBean wf = createBaseWorkflow(protoConf, "action");
    WorkflowActionBean action = (WorkflowActionBean) wf.getActions().get(0);
    action.setType(ae.getType());
    Context context = new Context(wf, action);
    conf = new XConfiguration();
    conf.set("c", "C");
    conf.set("oozie.launcher.d", "D");
    OutputStream os = getFileSystem().create(new Path(getFsTestCaseDir(), "job.xml"));
    conf.writeXml(os);
    os.close();
    os = getFileSystem().create(new Path(getFsTestCaseDir(), new Path("app", "job.xml")));
    conf.writeXml(os);
    os.close();
    conf = new XConfiguration();
    conf.set("e", "E");
    conf.set("oozie.launcher.f", "F");
    os = getFileSystem().create(new Path(getFsTestCaseDir(), "job2.xml"));
    conf.writeXml(os);
    os.close();
    os = getFileSystem().create(new Path(getFsTestCaseDir(), new Path("app", "job2.xml")));
    conf.writeXml(os);
    os.close();
    conf = ae.createBaseHadoopConf(context, actionXml);
    assertEquals(protoConf.get(WorkflowAppService.HADOOP_USER), conf.get(WorkflowAppService.HADOOP_USER));
    assertEquals(getJobTrackerUri(), conf.get(YARN_RESOURCEMANAGER_ADDRESS));
    assertEquals(getNameNodeUri(), conf.get("fs.default.name"));
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupLauncherConf(conf, actionXml, getFsTestCaseDir(), context);
    assertEquals("LA", conf.get("oozie.launcher.a"));
    assertEquals("LA", conf.get("a"));
    assertNull(conf.get("b"));
    assertEquals("D", conf.get("oozie.launcher.d"));
    assertEquals("D", conf.get("d"));
    assertEquals("F", conf.get("oozie.launcher.f"));
    assertEquals("F", conf.get("f"));
    assertNull(conf.get("action.foo"));
    assertEquals("action.barbar", conf.get("action.foofoo"));
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    assertEquals("LA", conf.get("oozie.launcher.a"));
    assertEquals("AA", conf.get("a"));
    assertEquals("BB", conf.get("b"));
    assertEquals("C", conf.get("c"));
    assertEquals("D", conf.get("oozie.launcher.d"));
    assertNull(conf.get("d"));
    assertEquals("E", conf.get("e"));
    assertEquals("F", conf.get("oozie.launcher.f"));
    assertNull(conf.get("f"));
    assertEquals("action.bar", conf.get("action.foo"));
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupLauncherConf(conf, actionXml, getFsTestCaseDir(), context);
    ae.addToCache(conf, appPath, appJarPath.toString(), false);
    assertTrue(conf.get("mapred.job.classpath.files").contains(appJarPath.toUri().getPath()));
    ae.addToCache(conf, appPath, appSoPath.toString(), false);
    assertTrue(conf.get("mapred.cache.files").contains(appSoPath.toUri().getPath()));
    ae.addToCache(conf, appPath, appSo1Path.toString(), false);
    assertTrue(conf.get("mapred.cache.files").contains(expectedSo1Path));
    assertFalse(getFileSystem().exists(context.getActionDir()));
    ae.prepareActionDir(getFileSystem(), context);
    assertTrue(getFileSystem().exists(context.getActionDir()));
    ae.cleanUpActionDir(getFileSystem(), context);
    assertFalse(getFileSystem().exists(context.getActionDir()));
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupLauncherConf(conf, actionXml, getFsTestCaseDir(), context);
    ae.setLibFilesArchives(context, actionXml, appPath, conf);
    assertTrue(conf.get("mapred.cache.files").contains(filePath.toUri().getPath()));
    assertTrue(conf.get("mapred.cache.archives").contains(archivePath.toUri().getPath()));
    conf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(conf, context, actionXml, getFsTestCaseDir());
    ae.setLibFilesArchives(context, actionXml, appPath, conf);
    assertTrue(conf.get("mapred.cache.files").contains(filePath.toUri().getPath()));
    assertTrue(conf.get("mapred.cache.archives").contains(archivePath.toUri().getPath()));
    Configuration actionConf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(actionConf, context, actionXml, getFsTestCaseDir());
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXml, actionConf);
    ae.setupLauncherConf(conf, actionXml, getFsTestCaseDir(), context);
    assertEquals("MAIN-CLASS", actionConf.get("oozie.action.java.main", "null"));
    assertEquals("org.apache.oozie.action.hadoop.JavaMain", ae.getLauncherMain(conf, actionXml));
    assertTrue(conf.get(MAPRED_CHILD_JAVA_OPTS).contains("JAVA-OPTS"));
    assertTrue(conf.get(MAPREDUCE_MAP_JAVA_OPTS).contains("JAVA-OPTS"));
    assertEquals(Arrays.asList("A1", "A2"), Arrays.asList(LauncherAMUtils.getMainArguments(conf)));
    actionXml = XmlUtils.parseXml("<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node> <configuration>" + "<property><name>mapred.job.queue.name</name><value>AQ</value></property>" + "<property><name>oozie.action.sharelib.for.java</name><value>sharelib-java</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "</java>");
    actionConf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(actionConf, context, actionXml, appPath);
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXml, actionConf);
    assertEquals("AQ", conf.get("mapred.job.queue.name"));
    assertEquals("AQ", actionConf.get("mapred.job.queue.name"));
    assertEquals("sharelib-java", actionConf.get("oozie.action.sharelib.for.java"));
    actionXml = XmlUtils.parseXml("<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node> <configuration>" + "<property><name>oozie.launcher.mapred.job.queue.name</name><value>LQ</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "</java>");
    actionConf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(actionConf, context, actionXml, appPath);
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXml, actionConf);
    assertEquals("LQ", conf.get("mapred.job.queue.name"));
    actionXml = XmlUtils.parseXml("<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node> <configuration>" + "<property><name>oozie.launcher.mapred.job.queue.name</name><value>LQ</value></property>" + "<property><name>mapred.job.queue.name</name><value>AQ</value></property>" + "</configuration>" + "<main-class>MAIN-CLASS</main-class>" + "</java>");
    actionConf = ae.createBaseHadoopConf(context, actionXml);
    ae.setupActionConf(actionConf, context, actionXml, appPath);
    conf = ae.createLauncherConf(getFileSystem(), context, action, actionXml, actionConf);
    assertEquals("LQ", conf.get("mapred.job.queue.name"));
    assertEquals("AQ", actionConf.get("mapred.job.queue.name"));
    assertEquals(true, conf.getBoolean("mapreduce.job.complete.cancel.delegation.tokens", false));
    assertEquals(false, actionConf.getBoolean("mapreduce.job.complete.cancel.delegation.tokens", true));
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) Element(org.jdom.Element) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

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