use of org.apache.oozie.CoordinatorWfActionBean in project oozie by apache.
the class MockCoordinatorEngineService method createDummyCoordWfAction.
private static CoordinatorWfActionBean createDummyCoordWfAction(String name, int id) {
CoordinatorWfActionBean coordWfAction = null;
WorkflowActionBean wfAction = new WorkflowActionBean();
wfAction.setName(name);
coordWfAction = new CoordinatorWfActionBean(id, wfAction, null);
return coordWfAction;
}
use of org.apache.oozie.CoordinatorWfActionBean in project oozie by apache.
the class TestCoordWfActionInfoXCommand method testWorkflowInstanceMissing.
public void testWorkflowInstanceMissing() throws CommandException {
List<CoordinatorWfActionBean> coordWfActions = new CoordWfActionInfoXCommand(coordJob.getId(), "aa", 2, 4).call();
assertEquals(4, coordWfActions.size());
CoordinatorWfActionBean coordWfAction = coordWfActions.get(3);
assertEquals(5, coordWfAction.getActionNumber());
assertEquals(null, coordWfAction.getAction());
String expectNullReason = CoordinatorWfAction.NullReason.PARENT_NULL.getNullReason();
assertEquals(expectNullReason, coordWfAction.getNullReason());
}
use of org.apache.oozie.CoordinatorWfActionBean in project oozie by apache.
the class CoordWfActionInfoXCommand method execute.
@Override
protected List<CoordinatorWfActionBean> execute() throws CommandException {
List<CoordinatorWfActionBean> coordWfActions = new ArrayList<CoordinatorWfActionBean>();
for (CoordinatorActionBean coordAction : coordActions) {
String wfId = coordAction.getExternalId();
String nullReason = null;
WorkflowActionBean wfAction = null;
if (wfId != null) {
String wfActionId = wfId + "@" + actionName;
try {
wfAction = jpaService.execute(new WorkflowActionGetJPAExecutor(wfActionId, true));
if (wfAction == null) {
nullReason = CoordinatorWfAction.NullReason.ACTION_NULL.getNullReason(actionName, wfId);
}
} catch (JPAExecutorException ex) {
throw new CommandException(ex);
}
} else {
nullReason = CoordinatorWfAction.NullReason.PARENT_NULL.getNullReason();
LOG.warn(nullReason);
wfAction = null;
}
int actionNumber = coordAction.getActionNumber();
CoordinatorWfActionBean coordWfAction = new CoordinatorWfActionBean(actionNumber, wfAction, nullReason);
coordWfActions.add(coordWfAction);
}
return coordWfActions;
}
use of org.apache.oozie.CoordinatorWfActionBean in project oozie by apache.
the class V2JobServlet method getWfActionByJobIdAndName.
@Override
protected JSONObject getWfActionByJobIdAndName(HttpServletRequest request, HttpServletResponse response) throws XServletException, IOException {
CoordinatorEngine coordEngine = Services.get().get(CoordinatorEngineService.class).getCoordinatorEngine(getUser(request));
String jobId = getResourceName(request);
String action = request.getParameter(RestConstants.ACTION_NAME_PARAM);
String startStr = request.getParameter(RestConstants.OFFSET_PARAM);
String lenStr = request.getParameter(RestConstants.LEN_PARAM);
String timeZoneId = request.getParameter(RestConstants.TIME_ZONE_PARAM);
timeZoneId = (timeZoneId == null) ? "GMT" : timeZoneId;
if (action == null) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0305, RestConstants.ACTION_NAME_PARAM);
}
int offset = (startStr != null) ? Integer.parseInt(startStr) : 1;
offset = (offset < 1) ? 1 : offset;
/**
* set default number of wf actions to be retrieved to
* default number of coordinator actions to be retrieved
*/
int defaultLen = ConfigurationService.getInt(COORD_ACTIONS_DEFAULT_LENGTH);
int len = (lenStr != null) ? Integer.parseInt(lenStr) : 0;
len = getCoordinatorJobLength(defaultLen, len);
try {
JSONObject json = new JSONObject();
List<CoordinatorWfActionBean> coordWfActions = coordEngine.getWfActionByJobIdAndName(jobId, action, offset, len);
JSONArray array = new JSONArray();
for (CoordinatorWfActionBean coordWfAction : coordWfActions) {
array.add(coordWfAction.toJSONObject(timeZoneId));
}
json.put(JsonTags.COORDINATOR_JOB_ID, jobId);
json.put(JsonTags.COORDINATOR_WF_ACTIONS, array);
return json;
} catch (CoordinatorEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
}
use of org.apache.oozie.CoordinatorWfActionBean in project oozie by apache.
the class TestCoordWfActionInfoXCommand method testNormalCase.
public void testNormalCase() throws Exception {
int offset = 2, len = 2;
List<CoordinatorWfActionBean> coordWfActions = new CoordWfActionInfoXCommand(coordJob.getId(), "aa", offset, len).call();
assertEquals(2, coordWfActions.size());
List<String> wfIds = Arrays.asList(wfJobs.get(1).getId(), wfJobs.get(2).getId());
for (int i = 0; i < coordWfActions.size(); i++) {
CoordinatorWfActionBean coordWfAction = coordWfActions.get(i);
WorkflowActionBean wfAction = coordWfAction.getAction();
assertEquals(i + offset, coordWfActions.get(i).getActionNumber());
assertEquals(wfIds.get(i), wfAction.getWfId());
assertEquals(null, coordWfAction.getNullReason());
}
}
Aggregations