本文整理汇总了Java中org.apache.oozie.client.Job类的典型用法代码示例。如果您正苦于以下问题:Java Job类的具体用法?Java Job怎么用?Java Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Job类属于org.apache.oozie.client包,在下文中一共展示了Job类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testProcessEndtimeUpdate
import org.apache.oozie.client.Job; //导入依赖的package包/类
@Test
public void testProcessEndtimeUpdate() throws Exception {
scheduleProcess();
waitForBundleStart(Job.Status.RUNNING);
ClientResponse response = this.service.path("api/entities/definition/process/" + processName).header("Remote-User", REMOTE_USER)
.accept(MediaType.TEXT_XML).get(ClientResponse.class);
Process process = (Process) EntityType.PROCESS.getUnmarshaller()
.unmarshal(new StringReader(response.getEntity(String.class)));
Validity processValidity = process.getClusters().getClusters().get(0).getValidity();
processValidity.setEnd(new Date(new Date().getTime() + 60 * 60 * 1000));
File tmpFile = getTempFile();
EntityType.PROCESS.getMarshaller().marshal(process, tmpFile);
response = this.service.path("api/entities/update/process/" + processName).header("Remote-User", REMOTE_USER).accept(MediaType.TEXT_XML)
.post(ClientResponse.class, getServletInputStream(tmpFile.getAbsolutePath()));
assertSuccessful(response);
//Assert that update does not create new bundle
List<BundleJob> bundles = getBundles();
Assert.assertEquals(bundles.size(), 1);
}
示例2: testProcessEndtimeUpdate
import org.apache.oozie.client.Job; //导入依赖的package包/类
@Test
public void testProcessEndtimeUpdate() throws Exception {
scheduleProcess();
waitForBundleStart(Job.Status.RUNNING);
ClientResponse response = this.service.path("api/entities/definition/process/" + processName).header(
"Remote-User", REMOTE_USER)
.accept(MediaType.TEXT_XML).get(ClientResponse.class);
Process process = (Process) EntityType.PROCESS.getUnmarshaller()
.unmarshal(new StringReader(response.getEntity(String.class)));
Validity processValidity = process.getClusters().getClusters().get(0).getValidity();
processValidity.setEnd(new Date(new Date().getTime() + 60 * 60 * 1000));
File tmpFile = getTempFile();
EntityType.PROCESS.getMarshaller().marshal(process, tmpFile);
response = this.service.path("api/entities/update/process/" + processName).header("Remote-User",
REMOTE_USER).accept(MediaType.TEXT_XML)
.post(ClientResponse.class, getServletInputStream(tmpFile.getAbsolutePath()));
assertSuccessful(response);
//Assert that update does not create new bundle
List<BundleJob> bundles = getBundles();
Assert.assertEquals(bundles.size(), 1);
}
示例3: testProcessInputUpdate
import org.apache.oozie.client.Job; //导入依赖的package包/类
@Test
public void testProcessInputUpdate() throws Exception {
scheduleProcess();
waitForBundleStart(Job.Status.RUNNING);
ClientResponse response = this.service.path("api/entities/definition/process/" + processName).header("Remote-User", REMOTE_USER)
.accept(MediaType.TEXT_XML).get(ClientResponse.class);
Process process = (Process) EntityType.PROCESS.getUnmarshaller()
.unmarshal(new StringReader(response.getEntity(String.class)));
String feed3 = "f3" + System.currentTimeMillis();
Map<String, String> overlay = new HashMap<String, String>();
overlay.put("inputFeedName", feed3);
overlay.put("cluster", clusterName);
response = submitToIvory(FEED_TEMPLATE1, overlay, EntityType.FEED);
assertSuccessful(response);
Input input = new Input();
input.setFeed(feed3);
input.setName("inputData2");
input.setStart("today(20,0)");
input.setEnd("today(20,20)");
process.getInputs().getInputs().add(input);
Validity processValidity = process.getClusters().getClusters().get(0).getValidity();
processValidity.setEnd(new Date(new Date().getTime() + 2 * 24 * 60 * 60 * 1000));
File tmpFile = getTempFile();
EntityType.PROCESS.getMarshaller().marshal(process, tmpFile);
response = this.service.path("api/entities/update/process/" + processName).header("Remote-User", REMOTE_USER).accept(MediaType.TEXT_XML)
.post(ClientResponse.class, getServletInputStream(tmpFile.getAbsolutePath()));
assertSuccessful(response);
//Assert that update creates new bundle
List<BundleJob> bundles = getBundles();
Assert.assertEquals(bundles.size(), 2);
}
示例4: getRunningJobs
import org.apache.oozie.client.Job; //导入依赖的package包/类
private List<WorkflowJob> getRunningJobs(String entityName) throws Exception {
OozieClient ozClient = OozieClientFactory.get((Cluster) ConfigurationStore.get().get(EntityType.CLUSTER, clusterName));
StringBuilder builder = new StringBuilder();
builder.append(OozieClient.FILTER_STATUS).append('=').append(Job.Status.RUNNING).append(';');
builder.append(OozieClient.FILTER_NAME).append('=').append("IVORY_PROCESS_DEFAULT_").append(entityName);
return ozClient.getJobsInfo(builder.toString());
}
示例5: testProcessInputUpdate
import org.apache.oozie.client.Job; //导入依赖的package包/类
@Test
public void testProcessInputUpdate() throws Exception {
scheduleProcess();
waitForBundleStart(Job.Status.RUNNING);
ClientResponse response = this.service.path("api/entities/definition/process/" + processName).header(
"Remote-User", REMOTE_USER)
.accept(MediaType.TEXT_XML).get(ClientResponse.class);
Process process = (Process) EntityType.PROCESS.getUnmarshaller()
.unmarshal(new StringReader(response.getEntity(String.class)));
String feed3 = "f3" + System.currentTimeMillis();
Map<String, String> overlay = new HashMap<String, String>();
overlay.put("inputFeedName", feed3);
overlay.put("cluster", clusterName);
response = submitToFalcon(FEED_TEMPLATE1, overlay, EntityType.FEED);
assertSuccessful(response);
Input input = new Input();
input.setFeed(feed3);
input.setName("inputData2");
input.setStart("today(20,0)");
input.setEnd("today(20,20)");
process.getInputs().getInputs().add(input);
Validity processValidity = process.getClusters().getClusters().get(0).getValidity();
processValidity.setEnd(new Date(new Date().getTime() + 2 * 24 * 60 * 60 * 1000));
File tmpFile = getTempFile();
EntityType.PROCESS.getMarshaller().marshal(process, tmpFile);
response = this.service.path("api/entities/update/process/" + processName).header("Remote-User",
REMOTE_USER).accept(MediaType.TEXT_XML)
.post(ClientResponse.class, getServletInputStream(tmpFile.getAbsolutePath()));
assertSuccessful(response);
//Assert that update creates new bundle
List<BundleJob> bundles = getBundles();
Assert.assertEquals(bundles.size(), 2);
}
示例6: testSubmitCoordinator
import org.apache.oozie.client.Job; //导入依赖的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();
}
示例7: submitCoordJob
import org.apache.oozie.client.Job; //导入依赖的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!");
}
}
}
示例8: processCallback
import org.apache.oozie.client.Job; //导入依赖的package包/类
/**
* Processes a callback from Oozie which update the download status.
*/
@Override
public void processCallback(String jobId, String status) {
Preconditions.checkNotNull(Strings.isNullOrEmpty(jobId), "<jobId> may not be null or empty");
Preconditions.checkNotNull(Strings.isNullOrEmpty(status), "<status> may not be null or empty");
Optional<Job.Status> opStatus = Enums.getIfPresent(Job.Status.class, status.toUpperCase());
Preconditions.checkArgument(opStatus.isPresent(), "<status> the requested status is not valid");
String downloadId = DownloadUtils.workflowToDownloadId(jobId);
LOG.debug("Processing callback for jobId [{}] with status [{}]", jobId, status);
Download download = occurrenceDownloadService.get(downloadId);
if (download == null) {
// Download can be null if the oozie reports status before the download is persisted
LOG.info(String.format("Download [%s] not found [Oozie may be issuing callback before download persisted]", downloadId));
return;
}
Download.Status newStatus = STATUSES_MAP.get(opStatus.get());
switch (newStatus) {
case KILLED:
// Keep a manually cancelled download status as opposed to a killed one
if (download.getStatus() == Download.Status.CANCELLED) {
CANCELLED_DOWNLOADS.inc();
return;
}
case FAILED:
LOG.error(NOTIFY_ADMIN, "Got callback for failed query. JobId [{}], Status [{}]", jobId, status);
updateDownloadStatus(download, newStatus);
downloadEmailUtils.sendErrorNotificationMail(download);
FAILED_DOWNLOADS.inc();
break;
case SUCCEEDED:
SUCCESSFUL_DOWNLOADS.inc();
updateDownloadStatus(download, newStatus);
// notify about download
if (download.getRequest().getSendNotification()) {
downloadEmailUtils.sendSuccessNotificationMail(download);
}
break;
default:
updateDownloadStatus(download, newStatus);
break;
}
}
示例9: testStatusMapCompleteness
import org.apache.oozie.client.Job; //导入依赖的package包/类
@Test
public void testStatusMapCompleteness() throws Exception {
for (Job.Status st : Job.Status.values()) {
assertTrue(DownloadRequestServiceImpl.STATUSES_MAP.containsKey(st));
}
}