use of org.apache.oozie.BulkResponseInfo in project oozie by apache.
the class TestBulkMonitorJPAExecutor method testDefaultStatus.
public void testDefaultStatus() throws Exception {
// adding coordinator action #4 to Coord#3
addRecordToCoordActionTable("Coord3", 1, CoordinatorAction.Status.FAILED, "coord-action-get.xml", 0);
String request = "bundle=" + bundleName + ";";
BulkResponseInfo response = _execQuery(request);
List<BulkResponseImpl> brList = response.getResponses();
// 4 actions satisfy the conditions
assertEquals(4, brList.size());
assertEquals(4, response.getTotal());
List<String> possibleStatus = new ArrayList<String>(Arrays.asList("FAILED", "KILLED"));
List<String> resultStatus = new ArrayList<String>();
resultStatus.add(brList.get(0).getAction().getStatus().toString());
resultStatus.add(brList.get(1).getAction().getStatus().toString());
assertEquals(possibleStatus, resultStatus);
}
use of org.apache.oozie.BulkResponseInfo in project oozie by apache.
the class BulkJobsXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected BulkResponseInfo execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
BulkResponseInfo bulk = null;
if (jpaService != null) {
bulk = jpaService.execute(new BulkJPAExecutor(bulkParams, start, len));
} else {
LOG.error(ErrorCode.E0610);
}
return bulk;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.BulkResponseInfo in project oozie by apache.
the class BulkJPAExecutor method execute.
@Override
public BulkResponseInfo execute(EntityManager em) throws JPAExecutorException {
List<BulkResponseImpl> responseList = new ArrayList<BulkResponseImpl>();
Map<String, Timestamp> actionTimes = new HashMap<String, Timestamp>();
try {
List<String> coords = bulkFilter.get(BulkResponseImpl.BULK_FILTER_COORD);
List<String> statuses = bulkFilter.get(BulkResponseImpl.BULK_FILTER_STATUS);
List<String> params = new ArrayList<String>();
// Lightweight Query 1 on Bundle level to fetch the bundle job(s)
// corresponding to names or ids
List<BundleJobBean> bundleBeans = bundleQuery(em);
// Join query between coordinator job and coordinator action tables
// to get entries for specific bundleId only
String conditions = actionQuery(coords, params, statuses, em, bundleBeans, actionTimes, responseList);
// Query to get the count of records
long total = countQuery(statuses, params, conditions, em, bundleBeans, actionTimes);
BulkResponseInfo bulk = new BulkResponseInfo(responseList, start, len, total);
return bulk;
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
}
use of org.apache.oozie.BulkResponseInfo in project oozie by apache.
the class V1JobsServlet method getBulkJobs.
@SuppressWarnings("unchecked")
private JSONObject getBulkJobs(HttpServletRequest request) throws XServletException, IOException {
JSONObject json = new JSONObject();
try {
// REST API
String bulkFilter = request.getParameter(RestConstants.JOBS_BULK_PARAM);
String startStr = request.getParameter(RestConstants.OFFSET_PARAM);
String lenStr = request.getParameter(RestConstants.LEN_PARAM);
String timeZoneId = request.getParameter(RestConstants.TIME_ZONE_PARAM) == null ? "GMT" : request.getParameter(RestConstants.TIME_ZONE_PARAM);
int start = (startStr != null) ? Integer.parseInt(startStr) : 1;
start = (start < 1) ? 1 : start;
int len = (lenStr != null) ? Integer.parseInt(lenStr) : 50;
len = (len < 1) ? 50 : len;
BundleEngine bundleEngine = Services.get().get(BundleEngineService.class).getBundleEngine(getUser(request));
BulkResponseInfo bulkResponse = bundleEngine.getBulkJobs(bulkFilter, start, len);
List<BulkResponseImpl> responsesToJson = bulkResponse.getResponses();
json.put(JsonTags.BULK_RESPONSES, BulkResponseImpl.toJSONArray(responsesToJson, timeZoneId));
json.put(JsonTags.BULK_RESPONSE_TOTAL, bulkResponse.getTotal());
json.put(JsonTags.BULK_RESPONSE_OFFSET, bulkResponse.getStart());
json.put(JsonTags.BULK_RESPONSE_LEN, bulkResponse.getLen());
} catch (BaseEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
return json;
}
use of org.apache.oozie.BulkResponseInfo in project oozie by apache.
the class TestBulkMonitorJPAExecutor method testBundleIdWithCoordId.
public void testBundleIdWithCoordId() throws Exception {
// fetching coord Ids
JPAService jpaService = Services.get().get(JPAService.class);
List<String> coordIds = jpaService.execute(new CoordJobsGetFromParentIdJPAExecutor(bundleId, 10));
// there are 3 coordinators but giving range as only two of them
String coordIdsStr = coordIds.get(0) + "," + coordIds.get(1);
String request = "bundle=" + bundleId + ";coordinators=" + coordIdsStr + ";actionstatus=KILLED";
BulkResponseInfo response = _execQuery(request);
List<BulkResponseImpl> brList = response.getResponses();
// 2 actions satisfy the conditions
assertEquals(2, brList.size());
assertEquals(2, response.getTotal());
assertEquals(brList.get(0).getAction().getId(), "Coord1@2");
assertEquals(brList.get(1).getAction().getId(), "Coord2@1");
}
Aggregations