use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class CoordActionGetForInputCheckJPAExecutor method execute.
/* (non-Javadoc)
* @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.EntityManager)
*/
@Override
public CoordinatorActionBean execute(EntityManager em) throws JPAExecutorException {
try {
Query q = em.createNamedQuery("GET_COORD_ACTION_FOR_INPUTCHECK");
q.setParameter("id", coordActionId);
Object[] obj = (Object[]) q.getSingleResult();
CoordinatorActionBean caBean = getBeanForRunningCoordAction(obj);
return caBean;
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class CoordActionGetJPAExecutor method execute.
/* (non-Javadoc)
* @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.EntityManager)
*/
@Override
@SuppressWarnings("unchecked")
public CoordinatorActionBean execute(EntityManager em) throws JPAExecutorException {
List<CoordinatorActionBean> caBeans;
try {
Query q = em.createNamedQuery("GET_COORD_ACTION");
q.setParameter("id", coordActionId);
caBeans = q.getResultList();
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
CoordinatorActionBean bean = null;
if (caBeans != null && caBeans.size() > 0) {
bean = caBeans.get(0);
return bean;
} else {
throw new JPAExecutorException(ErrorCode.E0605, coordActionId);
}
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class CoordActionGetForTimeoutJPAExecutor method execute.
/* (non-Javadoc)
* @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.EntityManager)
*/
@Override
public CoordinatorActionBean execute(EntityManager em) throws JPAExecutorException {
try {
Query q = em.createNamedQuery("GET_COORD_ACTION_FOR_TIMEOUT");
q.setParameter("id", coordActionId);
Object[] obj = (Object[]) q.getSingleResult();
CoordinatorActionBean caBean = getBeanForRunningCoordAction(obj);
return caBean;
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class CoordActionQueryExecutor method getIfExist.
@Override
public CoordinatorActionBean getIfExist(CoordActionQuery namedQuery, Object... parameters) throws JPAExecutorException {
JPAService jpaService = Services.get().get(JPAService.class);
EntityManager em = jpaService.getEntityManager();
Query query = getSelectQuery(namedQuery, em, parameters);
Object ret = jpaService.executeGet(namedQuery.name(), query, em);
if (ret == null) {
return null;
}
CoordinatorActionBean bean = constructBean(namedQuery, ret);
return bean;
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class V2JobServlet method ignoreCoordinatorJob.
/**
* Ignore a coordinator job/action
*
* @param request servlet request
* @param response servlet response
* @throws XServletException
*/
@SuppressWarnings("unchecked")
private JSONObject ignoreCoordinatorJob(HttpServletRequest request, HttpServletResponse response) throws XServletException {
JSONObject json = null;
CoordinatorEngine coordEngine = Services.get().get(CoordinatorEngineService.class).getCoordinatorEngine(getUser(request));
String jobId = getResourceName(request);
String type = request.getParameter(RestConstants.JOB_COORD_RANGE_TYPE_PARAM);
String scope = request.getParameter(RestConstants.JOB_COORD_SCOPE_PARAM);
String changeValue = "status=" + CoordinatorAction.Status.IGNORED;
List<CoordinatorActionBean> coordActions = new ArrayList<CoordinatorActionBean>();
try {
if (type != null && !type.equals(RestConstants.JOB_COORD_SCOPE_ACTION)) {
throw new CommandException(ErrorCode.E1024, "Currently ignore only support -action option");
}
CoordinatorActionInfo coordInfo = null;
if (scope == null || scope.isEmpty()) {
coordEngine.change(jobId, changeValue);
} else {
coordInfo = coordEngine.ignore(jobId, type, scope);
}
if (coordInfo != null) {
coordActions = coordInfo.getCoordActions();
json = new JSONObject();
json.put(JsonTags.COORDINATOR_ACTIONS, CoordinatorActionBean.toJSONArray(coordActions, "GMT"));
}
return json;
} catch (CommandException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
} catch (CoordinatorEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
}
Aggregations