public Void call() throws Exception { String oozieUrl = getContextURL(); XOozieClient wc = new XOozieClient(oozieUrl); Properties configuration = wc.createConfiguration(); try { wc.addFile(configuration, null); } catch (IllegalArgumentException e) { assertEquals("file cannot be null", e.getMessage()); } wc.addFile(configuration, "file1"); wc.addFile(configuration, "file2"); assertEquals("file1,file2", configuration.get(XOozieClient.FILES)); // test archive try { wc.addArchive(configuration, null); } catch (IllegalArgumentException e) { assertEquals("file cannot be null", e.getMessage()); } wc.addArchive(configuration, "archive1"); wc.addArchive(configuration, "archive2"); assertEquals("archive1,archive2", configuration.get(XOozieClient.ARCHIVES)); return null; } });
printBulkModifiedJobs(wc.killJobs(filter, jobtype, start, len), timeZoneId, "killed"); printBulkModifiedJobs(wc.suspendJobs(filter, jobtype, start, len), timeZoneId, "suspended"); printBulkModifiedJobs(wc.resumeJobs(filter, jobtype, start, len), timeZoneId, "resumed"); printBulkJobs(wc.getBulkInfo(bulkFilterString, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION)); printJobs(wc.getJobsInfo(filter, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION)); printCoordJobs(wc.getCoordJobsInfo(filter, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION)); printBundleJobs(wc.getBundleJobsInfo(filter, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION));
private void jobsCommand(CommandLine commandLine) throws IOException, OozieCLIException { XOozieClient wc = createXOozieClient(commandLine); String filter = commandLine.getOptionValue(FILTER_OPTION); String s = commandLine.getOptionValue(OFFSET_OPTION); int start = Integer.parseInt((s != null) ? s : "0"); s = commandLine.getOptionValue(LEN_OPTION); String jobtype = commandLine.getOptionValue(JOBTYPE_OPTION); jobtype = (jobtype != null) ? jobtype : "wf"; int len = Integer.parseInt((s != null) ? s : "0"); try { if (jobtype.toLowerCase().contains("wf")) { printJobs(wc.getJobsInfo(filter, start, len), commandLine.hasOption(LOCAL_TIME_OPTION), commandLine .hasOption(VERBOSE_OPTION)); } else if (jobtype.toLowerCase().startsWith("coord")) { printCoordJobs(wc.getCoordJobsInfo(filter, start, len), commandLine.hasOption(LOCAL_TIME_OPTION), commandLine.hasOption(VERBOSE_OPTION)); } else if (jobtype.toLowerCase().startsWith("bundle")) { printBundleJobs(wc.getBundleJobsInfo(filter, start, len), commandLine.hasOption(LOCAL_TIME_OPTION), commandLine.hasOption(VERBOSE_OPTION)); } } catch (OozieClientException ex) { throw new OozieCLIException(ex.toString(), ex); } }
System.out.println(JOB_ID_PREFIX + wc.submit(getConfiguration(wc, commandLine))); wc.start(commandLine.getOptionValue(START_OPTION)); String dryrunStr = wc.dryrun(getConfiguration(wc, commandLine)); if (dryrunStr.equals("OK")) { // workflow System.out.println("OK"); wc.suspend(commandLine.getOptionValue(SUSPEND_OPTION)); wc.resume(commandLine.getOptionValue(RESUME_OPTION)); printCoordActionsStatus(wc.ignore(commandLine.getOptionValue(IGNORE_OPTION), ignoreScope)); printCoordActions(wc.kill(coordJobId, rangeType, scope)); wc.kill(commandLine.getOptionValue(KILL_OPTION)); wc.change(commandLine.getOptionValue(CHANGE_OPTION), getChangeValue(commandLine)); System.out.println(JOB_ID_PREFIX + wc.run(getConfiguration(wc, commandLine))); wc.reRun(commandLine.getOptionValue(RERUN_OPTION), getConfiguration(wc, commandLine)); wc.reRun(commandLine.getOptionValue(RERUN_OPTION), new Properties()); wc.reRunBundle(bundleJobId, coordScope, dateScope, refresh, noCleanup); if (coordScope != null && !coordScope.isEmpty()) { System.out.println("Coordinators [" + coordScope + "] of bundle " + bundleJobId
System.out.println(JOB_ID_PREFIX + wc.submit(getConfiguration(commandLine))); wc.start(commandLine.getOptionValue(START_OPTION)); String[] dryrunStr = wc.dryrun(getConfiguration(commandLine)).split("action for new instance"); int arraysize = dryrunStr.length; System.out.println("***coordJob after parsing: ***"); wc.suspend(commandLine.getOptionValue(SUSPEND_OPTION)); wc.resume(commandLine.getOptionValue(RESUME_OPTION)); wc.kill(commandLine.getOptionValue(KILL_OPTION)); wc.change(commandLine.getOptionValue(CHANGE_OPTION), getChangeValue(commandLine)); System.out.println(JOB_ID_PREFIX + wc.run(getConfiguration(commandLine))); wc.reRun(commandLine.getOptionValue(RERUN_OPTION), getConfiguration(commandLine)); wc.reRunBundle(bundleJobId, coordScope, dateScope, refresh, noCleanup); if (coordScope != null && !coordScope.isEmpty()) { System.out.println("Coordinators [" + coordScope + "] of bundle " + bundleJobId printRerunCoordActions(wc.reRunCoord(coordJobId, rerunType, scope, refresh, noCleanup)); printBundleJob(wc.getBundleJobInfo(commandLine.getOptionValue(INFO_OPTION)), options .contains(LOCAL_TIME_OPTION), options.contains(VERBOSE_OPTION));
public Void call() throws Exception { String oozieUrl = getContextURL(); int wfCount = MockDagEngineService.INIT_WF_COUNT; XOozieClient wc = new XOozieClient(oozieUrl); Properties conf = wc.createConfiguration(); Path libPath = new Path(getFsTestCaseDir(), "lib"); getFileSystem().mkdirs(libPath); conf.setProperty(OozieClient.LIBPATH, libPath.toString()); conf.setProperty(XOozieClient.RM, "localhost:9001"); conf.setProperty(XOozieClient.NN, "hdfs://localhost:9000"); String[] params = new String[]{"INPUT=input.txt"}; String pigScriptFile = getTestCaseDir() + "/test"; BufferedWriter writer = new BufferedWriter(new FileWriter(pigScriptFile)); writer.write("a = load '${INPUT}';\n dump a;"); writer.close(); assertEquals(MockDagEngineService.JOB_ID + wfCount + MockDagEngineService.JOB_ID_END, wc.submitScriptLanguage(conf, pigScriptFile, null, params, "pig")); assertTrue(MockDagEngineService.started.get(wfCount)); return null; } });
public Void call() throws Exception { String oozieUrl = getContextURL(); int wfCount = MockDagEngineService.INIT_WF_COUNT; XOozieClient wc = new XOozieClient(oozieUrl); Properties conf = wc.createConfiguration(); Path libPath = new Path(getFsTestCaseDir(), "lib"); getFileSystem().mkdirs(libPath); System.out.println(libPath.toString()); conf.setProperty(OozieClient.LIBPATH, libPath.toString()); conf.setProperty(XOozieClient.RM, "localhost:9001"); conf.setProperty(XOozieClient.NN, "hdfs://localhost:9000"); assertEquals(MockDagEngineService.JOB_ID + wfCount + MockDagEngineService.JOB_ID_END, wc.submitSqoop(conf, new String[] {"import", "--connect", "jdbc:mysql://localhost:3306/oozie"}, null)); assertTrue(MockDagEngineService.started.get(wfCount)); return null; } });
public Void call() throws Exception { String oozieUrl = getContextURL(); int wfCount = MockDagEngineService.INIT_WF_COUNT; XOozieClient wc = new XOozieClient(oozieUrl); Properties conf = wc.createConfiguration(); Path libPath = new Path(getFsTestCaseDir(), "lib"); getFileSystem().mkdirs(libPath); wc.submitMapReduce(conf); fail("submit client without JT should throw exception"); wc.submitMapReduce(conf); fail("submit client without NN should throw exception"); wc.submitMapReduce(conf); fail("submit client without LIBPATH should throw exception"); conf.setProperty(XOozieClient.NN_2, nn); try { wc.submitMapReduce(conf); fail("submit client without LIBPATH should throw exception"); wc.submitMapReduce(conf); fail("lib path can not be relative"); wc.submitMapReduce(conf));
/** * Create a XOozieClient. * <p/> * It injects any '-Dheader:' as header to the the {@link org.apache.oozie.client.OozieClient}. * * @param commandLine the parsed command line options. * @return a pre configured eXtended workflow client. * @throws OozieCLIException thrown if the XOozieClient could not be configured. */ protected XOozieClient createXOozieClient(CommandLine commandLine) throws OozieCLIException { XOozieClient wc = new XOozieClient(getOozieUrl(commandLine)); addHeader(wc); setDebugMode(wc); return wc; }
System.out.println(JOB_ID_PREFIX + wc.submit(getConfiguration(wc, commandLine))); wc.start(commandLine.getOptionValue(START_OPTION)); String dryrunStr = wc.dryrun(getConfiguration(wc, commandLine)); if (dryrunStr.equals("OK")) { // workflow System.out.println("OK"); wc.suspend(commandLine.getOptionValue(SUSPEND_OPTION)); wc.resume(commandLine.getOptionValue(RESUME_OPTION)); printCoordActionsStatus(wc.ignore(commandLine.getOptionValue(IGNORE_OPTION), ignoreScope)); printCoordActions(wc.kill(coordJobId, rangeType, scope)); wc.kill(commandLine.getOptionValue(KILL_OPTION)); wc.change(commandLine.getOptionValue(CHANGE_OPTION), getChangeValue(commandLine)); System.out.println(JOB_ID_PREFIX + wc.run(getConfiguration(wc, commandLine))); wc.reRun(commandLine.getOptionValue(RERUN_OPTION), getConfiguration(wc, commandLine)); wc.reRun(commandLine.getOptionValue(RERUN_OPTION), new Properties()); wc.reRunBundle(bundleJobId, coordScope, dateScope, refresh, noCleanup); if (coordScope != null && !coordScope.isEmpty()) { System.out.println("Coordinators [" + coordScope + "] of bundle " + bundleJobId
System.out.println(JOB_ID_PREFIX + wc.submit(getConfiguration(commandLine))); wc.start(commandLine.getOptionValue(START_OPTION)); String[] dryrunStr = wc.dryrun(getConfiguration(commandLine)).split("action for new instance"); int arraysize = dryrunStr.length; System.out.println("***coordJob after parsing: ***"); wc.suspend(commandLine.getOptionValue(SUSPEND_OPTION)); wc.resume(commandLine.getOptionValue(RESUME_OPTION)); wc.kill(commandLine.getOptionValue(KILL_OPTION)); wc.change(commandLine.getOptionValue(CHANGE_OPTION), getChangeValue(commandLine)); System.out.println(JOB_ID_PREFIX + wc.run(getConfiguration(commandLine))); wc.reRun(commandLine.getOptionValue(RERUN_OPTION), getConfiguration(commandLine)); wc.reRunBundle(bundleJobId, coordScope, dateScope, refresh, noCleanup); if (coordScope != null && !coordScope.isEmpty()) { System.out.println("Coordinators [" + coordScope + "] of bundle " + bundleJobId printRerunCoordActions(wc.reRunCoord(coordJobId, rerunType, scope, refresh, noCleanup)); printBundleJob(wc.getBundleJobInfo(commandLine.getOptionValue(INFO_OPTION)), options .contains(LOCAL_TIME_OPTION), options.contains(VERBOSE_OPTION));
private void jobsCommand(CommandLine commandLine) throws IOException, OozieCLIException { XOozieClient wc = createXOozieClient(commandLine); String filter = commandLine.getOptionValue(FILTER_OPTION); String s = commandLine.getOptionValue(OFFSET_OPTION); int start = Integer.parseInt((s != null) ? s : "0"); s = commandLine.getOptionValue(LEN_OPTION); String jobtype = commandLine.getOptionValue(JOBTYPE_OPTION); jobtype = (jobtype != null) ? jobtype : "wf"; int len = Integer.parseInt((s != null) ? s : "0"); try { if (jobtype.toLowerCase().contains("wf")) { printJobs(wc.getJobsInfo(filter, start, len), commandLine.hasOption(LOCAL_TIME_OPTION), commandLine .hasOption(VERBOSE_OPTION)); } else if (jobtype.toLowerCase().startsWith("coord")) { printCoordJobs(wc.getCoordJobsInfo(filter, start, len), commandLine.hasOption(LOCAL_TIME_OPTION), commandLine.hasOption(VERBOSE_OPTION)); } else if (jobtype.toLowerCase().startsWith("bundle")) { printBundleJobs(wc.getBundleJobsInfo(filter, start, len), commandLine.hasOption(LOCAL_TIME_OPTION), commandLine.hasOption(VERBOSE_OPTION)); } } catch (OozieClientException ex) { throw new OozieCLIException(ex.toString(), ex); } }
public Void call() throws Exception { String oozieUrl = getContextURL(); int wfCount = MockDagEngineService.INIT_WF_COUNT; XOozieClient wc = new XOozieClient(oozieUrl); Properties conf = wc.createConfiguration(); Path libPath = new Path(getFsTestCaseDir(), "lib"); getFileSystem().mkdirs(libPath); System.out.println(libPath.toString()); conf.setProperty(OozieClient.LIBPATH, libPath.toString()); conf.setProperty(XOozieClient.RM, "localhost:9001"); conf.setProperty(XOozieClient.NN, "hdfs://localhost:9000"); String[] params = new String[]{"NAME=test"}; String hiveScriptFile = getTestCaseDir() + "/test"; System.out.println(hiveScriptFile); BufferedWriter writer = new BufferedWriter(new FileWriter(hiveScriptFile)); writer.write("CREATE EXTERNAL TABLE ${NAME} (a INT);"); writer.close(); assertEquals(MockDagEngineService.JOB_ID + wfCount + MockDagEngineService.JOB_ID_END, wc.submitScriptLanguage(conf, hiveScriptFile, null, params, "hive")); assertTrue(MockDagEngineService.started.get(wfCount)); return null; } });
/** * Create a XOozieClient. * <p/> * It injects any '-Dheader:' as header to the the {@link org.apache.oozie.client.OozieClient}. * * @param commandLine the parsed command line options. * @return a pre configured eXtended workflow client. * @throws OozieCLIException thrown if the XOozieClient could not be configured. */ protected XOozieClient createXOozieClient(CommandLine commandLine) throws OozieCLIException { XOozieClient wc = new XOozieClient(getOozieUrl(commandLine)); addHeader(wc); setDebugMode(wc); return wc; }
printBulkModifiedJobs(wc.killJobs(filter, jobtype, start, len), timeZoneId, "killed"); printBulkModifiedJobs(wc.suspendJobs(filter, jobtype, start, len), timeZoneId, "suspended"); printBulkModifiedJobs(wc.resumeJobs(filter, jobtype, start, len), timeZoneId, "resumed"); printBulkJobs(wc.getBulkInfo(bulkFilterString, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION)); printJobs(wc.getJobsInfo(filter, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION)); printCoordJobs(wc.getCoordJobsInfo(filter, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION)); printBundleJobs(wc.getBundleJobsInfo(filter, start, len), timeZoneId, commandLine.hasOption(VERBOSE_OPTION));