本文整理汇总了Java中org.apache.oozie.client.OozieClient.getCoordJobInfo方法的典型用法代码示例。如果您正苦于以下问题:Java OozieClient.getCoordJobInfo方法的具体用法?Java OozieClient.getCoordJobInfo怎么用?Java OozieClient.getCoordJobInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.oozie.client.OozieClient
的用法示例。
在下文中一共展示了OozieClient.getCoordJobInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSubmitCoordinator
import org.apache.oozie.client.OozieClient; //导入方法依赖的package包/类
@Test
public void testSubmitCoordinator() throws Exception {
LOG.info("OOZIE: Test Submit Coordinator Start");
FileSystem hdfsFs = hdfsLocalCluster.getHdfsFileSystemHandle();
OozieClient oozie = oozieLocalServer.getOozieCoordClient();
Path appPath = new Path(hdfsFs.getHomeDirectory(), "testApp");
hdfsFs.mkdirs(new Path(appPath, "lib"));
Path workflow = new Path(appPath, "workflow.xml");
Path coordinator = new Path(appPath, "coordinator.xml");
//write workflow.xml
String wfApp =
"<workflow-app xmlns='uri:oozie:workflow:0.1' name='test-wf'>" +
" <start to='end'/>" +
" <end name='end'/>" +
"</workflow-app>";
String coordApp =
"<coordinator-app timezone='UTC' end='2016-07-26T02:26Z' start='2016-07-26T01:26Z' frequency='${coord:hours(1)}' name='test-coordinator' xmlns='uri:oozie:coordinator:0.4'>" +
" <action>" +
" <workflow>" +
" <app-path>" + workflow.toString() + "</app-path>" +
" </workflow>" +
" </action>" +
"</coordinator-app>";
Writer writer = new OutputStreamWriter(hdfsFs.create(workflow));
writer.write(wfApp);
writer.close();
Writer coordWriter = new OutputStreamWriter(hdfsFs.create(coordinator));
coordWriter.write(coordApp);
coordWriter.close();
//write job.properties
Properties conf = oozie.createConfiguration();
conf.setProperty(OozieClient.COORDINATOR_APP_PATH, coordinator.toString());
conf.setProperty(OozieClient.USER_NAME, UserGroupInformation.getCurrentUser().getUserName());
//submit and check
final String jobId = oozie.submit(conf);
CoordinatorJob coord = oozie.getCoordJobInfo(jobId);
assertNotNull(coord);
assertEquals(Job.Status.PREP, coord.getStatus());
LOG.info("OOZIE: Coordinator: {}", coord.toString());
hdfsFs.close();
}
示例2: submitCoordJob
import org.apache.oozie.client.OozieClient; //导入方法依赖的package包/类
private void submitCoordJob(String workFlowRoot)
throws OozieClientException, InterruptedException {
// OozieClient client = LocalOozie.getCoordClient();
String oozieURL = System.getProperty("oozie.base.url");
LOG.debug("Oozie BaseURL is: {} ", oozieURL);
OozieClient client = new OozieClient(oozieURL);
Properties conf = client.createConfiguration();
conf.setProperty(OozieClient.COORDINATOR_APP_PATH, workFlowRoot
+ "/coord-app-hive-add-partition.xml");
conf.setProperty("nameNode", hadoopClusterService.getHDFSUri());
conf.setProperty("jobTracker", hadoopClusterService.getJobTRackerUri());
conf.setProperty("workflowRoot", workFlowRoot);
Date nowMinusOneMin = new DateTime().minusMinutes(1).toDate();
Date now = new DateTime().toDate();
conf.setProperty("jobStart",
DateUtils.formatDateOozieTZ(nowMinusOneMin));
conf.setProperty("jobEnd", DateUtils.formatDateOozieTZ(new DateTime()
.plusHours(2).toDate()));
conf.setProperty("initialDataset", DateUtils.formatDateOozieTZ(now));
conf.setProperty("tzOffset", "2");
// submit and start the workflow job
String jobId = client.submit(conf);
LOG.debug("Workflow job submitted");
// wait until the workflow job finishes printing the status every 10
// seconds
int retries = 2;
for (int i = 1; i <= retries; i++) {
// Sleep 60 sec./ 3 mins
Thread.sleep(60 * 1000);
CoordinatorJob coordJobInfo = client.getCoordJobInfo(jobId);
LOG.debug("Workflow job running ...");
LOG.debug("coordJobInfo Try: {}", i);
LOG.debug("coordJobInfo StartTime: {}", coordJobInfo.getStartTime());
LOG.debug("coordJobInfo NextMaterizedTime: {}",
coordJobInfo.getNextMaterializedTime());
LOG.debug("coordJobInfo EndTime: {}", coordJobInfo.getEndTime());
LOG.debug("coordJobInfo Frequency: {}", coordJobInfo.getFrequency());
LOG.debug("coordJobInfo ConsoleURL: {}",
coordJobInfo.getConsoleUrl());
LOG.debug("coordJobInfo Status: {}", coordJobInfo.getStatus());
for (CoordinatorAction action : coordJobInfo.getActions()) {
LOG.debug("coordJobInfo Action Id: {}", action.getId());
LOG.debug("coordJobInfo Action NominalTimeL: {}",
action.getNominalTime());
LOG.debug("coordJobInfo Action Runconf: {}",
action.getRunConf());
LOG.debug("coordJobInfo Action Status: {}", action.getStatus());
LOG.debug("coordJobInfo ActionConsoleURL: {}",
action.getConsoleUrl());
LOG.debug("coordJobInfo ActionErrorMessage: {}",
action.getErrorMessage());
}
if (coordJobInfo.getStatus() == Job.Status.RUNNING) {
// Wait three times to see the running state is stable..then it
// is fine.
// Job will keep running even if hive action fails.
if (i == retries) {
LOG.info("Coord Job in running state!");
break;
} else {
continue;
}
} else if (coordJobInfo.getStatus() == Job.Status.PREMATER
|| coordJobInfo.getStatus() == Job.Status.PREP) {
// still preparing.
continue;
} else {
throw new RuntimeException(
"Error occured while running coord job!");
}
}
}