Revision 47222
Added by Claudio Atzori almost 7 years ago
SubmitOozieJobAction.java | ||
---|---|---|
3 | 3 |
import java.util.Map; |
4 | 4 |
import java.util.Map.Entry; |
5 | 5 |
import java.util.Properties; |
6 |
import java.util.Set; |
|
6 | 7 |
|
8 |
import com.google.common.base.Splitter; |
|
9 |
import com.google.common.collect.Sets; |
|
10 |
import org.apache.commons.lang.StringUtils; |
|
7 | 11 |
import org.apache.commons.logging.Log; |
8 | 12 |
import org.apache.commons.logging.LogFactory; |
9 | 13 |
import org.apache.hadoop.conf.Configuration; |
... | ... | |
21 | 25 |
|
22 | 26 |
private static final Log log = LogFactory.getLog(SubmitOozieJobAction.class); // NOPMD by marko on 11/24/08 5:02 PM |
23 | 27 |
|
28 |
public static final String OOZIE_REPORT_ACTIONS = "oozie.report.actions.csv"; |
|
29 |
|
|
24 | 30 |
@Override |
25 | 31 |
public void submit(final JobCompletion callback, final BlackboardJob bbJob, final String jobName, final JobProfile jobProfile) |
26 | 32 |
throws HadoopServiceException { |
... | ... | |
40 | 46 |
final String jobId = newJobId(clusterName, internalId); |
41 | 47 |
|
42 | 48 |
jobRegistry.registerJob(HadoopJob.newInstance(jobId, clusterName, jobProfile, |
43 |
new OozieJobMonitor(oozieClient, internalId, callback))); |
|
49 |
new OozieJobMonitor(oozieClient, internalId, callback, getWorkflowActions(bbJob))));
|
|
44 | 50 |
|
45 | 51 |
} catch (final OozieClientException e) { |
46 | 52 |
throw new HadoopServiceException("error executing hadoop job: " + jobName, e); |
47 | 53 |
} |
48 | 54 |
} |
49 | 55 |
|
56 |
/** |
|
57 |
* Extracts from the blackboard job params the oozie action names as csv and returns them as a set. |
|
58 |
* @param bbJob |
|
59 |
* @return |
|
60 |
*/ |
|
61 |
private Set<String> getWorkflowActions(final BlackboardJob bbJob) { |
|
62 |
final String actions = bbJob.getParameters().get(OOZIE_REPORT_ACTIONS); |
|
63 |
if (StringUtils.isNotBlank(actions)) { |
|
64 |
return Sets.newHashSet(Splitter.on(",").split(actions)); |
|
65 |
} |
|
66 |
return Sets.newHashSet(); |
|
67 |
} |
|
68 |
|
|
50 | 69 |
private Properties prepareJob(final Configuration configuration, final String jobName, final JobProfile jobProfile, final Map<String, String> parameters) { |
51 | 70 |
|
52 | 71 |
log.info("creating job: " + jobName); |
Also available in: Unified diff
added param declaring the oozie job action names to be reported back to the workflow logger