use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class TestJMSTopicService method testMixedTopic1.
@Test
public void testMixedTopic1() throws Exception {
services = setupServicesForTopic();
services.getConf().set(JMSTopicService.TOPIC_NAME, JMSTopicService.JobType.WORKFLOW.getValue() + " = workflow," + JMSTopicService.JobType.COORDINATOR.getValue() + "=coord, default = " + JMSTopicService.TopicType.JOBID.getValue());
services.init();
JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
WorkflowJobBean wfj = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
assertEquals("workflow", jmsTopicService.getTopic(wfj.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_JOB, wfj.getUser(), wfj.getId(), null));
WorkflowActionBean wab = addRecordToWfActionTable(wfj.getId(), "1", WorkflowAction.Status.RUNNING);
assertEquals("workflow", jmsTopicService.getTopic(wab.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_ACTION, wfj.getUser(), wab.getId(), wab.getWfId()));
CoordinatorJobBean cjb = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, true, true);
assertEquals("coord", jmsTopicService.getTopic(cjb.getId()));
assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_JOB, cjb.getUser(), cjb.getId(), null));
CoordinatorActionBean cab = addRecordToCoordActionTable(cjb.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-for-action-input-check.xml", 0);
assertEquals("coord", jmsTopicService.getTopic(cab.getId()));
assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_ACTION, cjb.getUser(), cab.getId(), cab.getJobId()));
BundleJobBean bjb = addRecordToBundleJobTable(Job.Status.RUNNING, true);
assertEquals(bjb.getId(), jmsTopicService.getTopic(bjb.getId()));
assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_JOB, bjb.getUser(), bjb.getId(), null));
BundleActionBean bab = addRecordToBundleActionTable(bjb.getId(), "1", 1, Job.Status.RUNNING);
assertEquals(bjb.getId(), jmsTopicService.getTopic(bab.getBundleActionId()));
assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_ACTION, bjb.getUser(), bab.getBundleActionId(), bab.getBundleId()));
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class TestJMSTopicService method testMixedTopic2.
@Test
public void testMixedTopic2() throws Exception {
services = setupServicesForTopic();
services.getConf().set(JMSTopicService.TOPIC_NAME, JMSTopicService.JobType.WORKFLOW.getValue() + " = workflow," + JMSTopicService.JobType.COORDINATOR.getValue() + "=coord");
services.init();
JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
WorkflowJobBean wfj = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
assertEquals("workflow", jmsTopicService.getTopic(wfj.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_JOB, wfj.getUser(), wfj.getId(), null));
WorkflowActionBean wab = addRecordToWfActionTable(wfj.getId(), "1", WorkflowAction.Status.RUNNING);
assertEquals("workflow", jmsTopicService.getTopic(wab.getId()));
assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_ACTION, wfj.getUser(), wab.getId(), wab.getWfId()));
CoordinatorJobBean cjb = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, true, true);
assertEquals("coord", jmsTopicService.getTopic(cjb.getId()));
CoordinatorActionBean cab = addRecordToCoordActionTable(cjb.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-for-action-input-check.xml", 0);
assertEquals("coord", jmsTopicService.getTopic(cab.getId()));
assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_ACTION, cjb.getUser(), cab.getId(), cab.getJobId()));
BundleJobBean bjb = addRecordToBundleJobTable(Job.Status.RUNNING, true);
// As no default is specified, user will be considered as topic
assertEquals(bjb.getUser(), jmsTopicService.getTopic(bjb.getId()));
assertEquals(bjb.getUser(), jmsTopicService.getTopic(AppType.BUNDLE_JOB, bjb.getUser(), bjb.getId(), null));
BundleActionBean bab = addRecordToBundleActionTable(bjb.getId(), "1", 1, Job.Status.RUNNING);
assertEquals(bjb.getUser(), jmsTopicService.getTopic(bab.getBundleActionId()));
assertEquals(bjb.getUser(), jmsTopicService.getTopic(AppType.BUNDLE_ACTION, bjb.getUser(), bab.getBundleActionId(), bab.getBundleId()));
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class ForTestWorkflowStoreService method create.
public WorkflowStore create() throws StoreException {
final WorkflowStore wfs = super.create();
return new WorkflowStore() {
public void insertWorkflow(WorkflowJobBean workflow) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
public WorkflowJobBean getWorkflow(String id, boolean locking) throws StoreException {
WorkflowJobBean wf = new WorkflowJobBean();
wf.setId(id);
wf.setUser("u");
wf.setGroup("g");
return wf;
}
public WorkflowJobBean getWorkflowInfo(String id) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return null;
}
public String getWorkflowIdForExternalId(String extId) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return null;
}
public void updateWorkflow(WorkflowJobBean workflow) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
public int getWorkflowCountWithStatus(String status) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return 0;
}
public int getWorkflowCountWithStatusInLastNSeconds(String status, int secs) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return 0;
}
public void insertAction(WorkflowActionBean action) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
public WorkflowActionBean getAction(String id, boolean locking) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return null;
}
public void updateAction(WorkflowActionBean action) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
public void deleteAction(String id) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
public List<WorkflowActionBean> getActionsForWorkflow(String id, boolean locking) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return null;
}
public List<WorkflowActionBean> getPendingActions(long minimumPendingAgeSecs) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return null;
}
public List<WorkflowActionBean> getRunningActions(long checkAgeSecs) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return null;
}
public WorkflowsInfo getWorkflowsInfo(Map<String, List<String>> filter, int start, int len) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
return null;
}
public void purge(long olderThanDays) throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
public void commit() throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
public void close() throws StoreException {
// To change body of implemented methods use File | Settings | File Templates.
}
};
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class JavaActionExecutor method getCredProperties.
@SuppressWarnings("unchecked")
protected CredentialsProperties getCredProperties(Context context, String credName) throws Exception {
CredentialsProperties credProp = null;
String workflowXml = ((WorkflowJobBean) context.getWorkflow()).getWorkflowInstance().getApp().getDefinition();
XConfiguration wfjobConf = getWorkflowConf(context);
Element elementJob = XmlUtils.parseXml(workflowXml);
Element credentials = elementJob.getChild("credentials", elementJob.getNamespace());
if (credentials != null) {
for (Element credential : (List<Element>) credentials.getChildren("credential", credentials.getNamespace())) {
String name = credential.getAttributeValue("name");
String type = credential.getAttributeValue("type");
LOG.debug("getCredProperties: Name: " + name + ", Type: " + type);
if (name.equalsIgnoreCase(credName)) {
credProp = new CredentialsProperties(name, type);
for (Element property : (List<Element>) credential.getChildren("property", credential.getNamespace())) {
String propertyName = property.getChildText("name", property.getNamespace());
String propertyValue = property.getChildText("value", property.getNamespace());
ELEvaluator eval = new ELEvaluator();
for (Map.Entry<String, String> entry : wfjobConf) {
eval.setVariable(entry.getKey(), entry.getValue().trim());
}
propertyName = eval.evaluate(propertyName, String.class);
propertyValue = eval.evaluate(propertyValue, String.class);
credProp.getProperties().put(propertyName, propertyValue);
LOG.debug("getCredProperties: Properties name :'" + propertyName + "', Value : '" + propertyValue + "'");
}
}
}
if (credProp == null && credName != null) {
throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, "JA021", "Could not load credentials with name [{0}]].", credName);
}
} else {
LOG.debug("credentials is null for the action");
}
return credProp;
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class SubWorkflowActionExecutor method getWorkflowClient.
protected OozieClient getWorkflowClient(Context context, String oozieUri) {
OozieClient oozieClient;
if (oozieUri.equals(LOCAL)) {
WorkflowJobBean workflow = (WorkflowJobBean) context.getWorkflow();
String user = workflow.getUser();
String group = workflow.getGroup();
DagEngine dagEngine = Services.get().get(DagEngineService.class).getDagEngine(user);
oozieClient = new LocalOozieClient(dagEngine);
} else {
// TODO we need to add authToken to the WC for the remote case
oozieClient = new OozieClient(oozieUri);
}
return oozieClient;
}
Aggregations