Search in sources :

Example 1 with SLAEventsGetForSeqIdJPAExecutor

use of org.apache.oozie.executor.jpa.SLAEventsGetForSeqIdJPAExecutor in project oozie by apache.

the class SLAStore method getSLAEventListNewerSeqLimited.

/**
 * Get a list of SLA Events newer than a specific sequence with limit
 * clause.
 *
 * @param seqId sequence id
 * @return List of SLA Events
 * @throws StoreException
 */
public List<SLAEventBean> getSLAEventListNewerSeqLimited(final long seqId, final int limitLen, long[] lastSeqId) throws StoreException {
    ParamChecker.notNull(seqId, "SLAEventListNewerSeqLimited");
    ParamChecker.checkGTZero(limitLen, "SLAEventListNewerSeqLimited");
    lastSeqId[0] = seqId;
    List<SLAEventBean> seBeans = (List<SLAEventBean>) doOperation("getSLAEventListNewerSeqLimited", new Callable<List<SLAEventBean>>() {

        public List<SLAEventBean> call() throws StoreException, JPAExecutorException {
            List<SLAEventBean> seBeans;
            try {
                JPAService jpaService = Services.get().get(JPAService.class);
                List<SLAEventBean> slaEventList = null;
                long[] lastSeqId = new long[1];
                if (jpaService != null) {
                    seBeans = jpaService.execute(new SLAEventsGetForSeqIdJPAExecutor(seqId, limitLen, lastSeqId));
                } else {
                    throw new StoreException(ErrorCode.E0610);
                }
            } catch (IllegalStateException e) {
                throw new StoreException(ErrorCode.E0601, e.getMessage(), e);
            } catch (JPAExecutorException e) {
                throw new JPAExecutorException(ErrorCode.E0610, e.getMessage(), e);
            }
            return seBeans;
        }
    });
    List<SLAEventBean> eventList = new ArrayList<SLAEventBean>();
    for (SLAEventBean j : seBeans) {
        lastSeqId[0] = Math.max(lastSeqId[0], j.getEvent_id());
        eventList.add(j);
    }
    return eventList;
}
Also used : SLAEventsGetForSeqIdJPAExecutor(org.apache.oozie.executor.jpa.SLAEventsGetForSeqIdJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean) Callable(java.util.concurrent.Callable)

Example 2 with SLAEventsGetForSeqIdJPAExecutor

use of org.apache.oozie.executor.jpa.SLAEventsGetForSeqIdJPAExecutor in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method checkCoordAction.

private CoordinatorActionBean checkCoordAction(String actionId) throws JPAExecutorException {
    long[] lastSeqId = new long[1];
    JPAService jpaService = Services.get().get(JPAService.class);
    List<SLAEventBean> slaEventList = jpaService.execute(new SLAEventsGetForSeqIdJPAExecutor(-1, 10, lastSeqId));
    if (slaEventList.size() == 0) {
        fail("Unable to GET any record of sequence id greater than 0");
    }
    CoordinatorActionBean actionBean;
    actionBean = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
    return actionBean;
}
Also used : SLAEventsGetForSeqIdJPAExecutor(org.apache.oozie.executor.jpa.SLAEventsGetForSeqIdJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean)

Aggregations

SLAEventBean (org.apache.oozie.SLAEventBean)2 SLAEventsGetForSeqIdJPAExecutor (org.apache.oozie.executor.jpa.SLAEventsGetForSeqIdJPAExecutor)2 JPAService (org.apache.oozie.service.JPAService)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)1 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1