Search in sources :

Example 66 with CoordinatorActionBean

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);
    }
}
Also used : Query(javax.persistence.Query) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean)

Example 67 with CoordinatorActionBean

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);
    }
}
Also used : Query(javax.persistence.Query) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean)

Example 68 with CoordinatorActionBean

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);
    }
}
Also used : Query(javax.persistence.Query) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean)

Example 69 with CoordinatorActionBean

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;
}
Also used : EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) JPAService(org.apache.oozie.service.JPAService)

Example 70 with CoordinatorActionBean

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);
    }
}
Also used : CoordinatorActionInfo(org.apache.oozie.CoordinatorActionInfo) JSONObject(org.json.simple.JSONObject) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) ArrayList(java.util.ArrayList) CommandException(org.apache.oozie.command.CommandException) CoordinatorEngineException(org.apache.oozie.CoordinatorEngineException) CoordinatorEngineService(org.apache.oozie.service.CoordinatorEngineService)

Aggregations

CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)307 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)148 Date (java.util.Date)117 JPAService (org.apache.oozie.service.JPAService)113 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)102 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)60 CommandException (org.apache.oozie.command.CommandException)55 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 IOException (java.io.IOException)49 XConfiguration (org.apache.oozie.util.XConfiguration)44 Configuration (org.apache.hadoop.conf.Configuration)43 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)42 ArrayList (java.util.ArrayList)40 JDOMException (org.jdom.JDOMException)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 StringReader (java.io.StringReader)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)29 StoreException (org.apache.oozie.store.StoreException)24 Test (org.junit.Test)24 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)22