Search in sources :

Example 36 with SLAEventBean

use of org.apache.oozie.SLAEventBean in project oozie by apache.

the class TestSLAEventsGetForFilterJPAExecutor method testGetSLAEventsForCoordActionId.

public void testGetSLAEventsForCoordActionId() throws Exception {
    Map<String, List<String>> filterListAction1 = createFilterList("jobid", coordActionId1);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    // Use -1 instead of 0 because HSQLDB starts the event_id generator at 0 instead of 1
    SLAEventsGetForFilterJPAExecutor slaEventsGetCmd = new SLAEventsGetForFilterJPAExecutor(-1, 100, filterListAction1, new long[1]);
    List<SLAEventBean> list = jpaService.execute(slaEventsGetCmd);
    assertNotNull(list);
    assertEquals(3, list.size());
}
Also used : List(java.util.List) JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean)

Example 37 with SLAEventBean

use of org.apache.oozie.SLAEventBean in project oozie by apache.

the class TestSLAEventsGetForSeqIdJPAExecutor method _testGetSLAEventsForSeqId.

private void _testGetSLAEventsForSeqId(String jobId, Date current) throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    SLAEventsGetJPAExecutor slaEventsGetAllCmd = new SLAEventsGetJPAExecutor();
    List<SLAEventBean> fullList = jpaService.execute(slaEventsGetAllCmd);
    assertNotNull(fullList);
    long lastId = fullList.get(0).getEvent_id();
    SLAEventsGetForSeqIdJPAExecutor slaEventsGetCmd = new SLAEventsGetForSeqIdJPAExecutor(lastId, 10, new long[1]);
    List<SLAEventBean> list = jpaService.execute(slaEventsGetCmd);
    assertNotNull(list);
    assertEquals(2, list.size());
    SLAEventBean seBean = list.get(0);
    assertEquals(seBean.getSlaId(), jobId);
    assertEquals(seBean.getUser(), getTestUser());
    assertEquals(seBean.getGroupName(), getTestGroup());
    assertEquals(seBean.getJobStatus(), Status.STARTED);
    assertEquals(seBean.getStatusTimestamp().getTime(), current.getTime());
}
Also used : JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean)

Example 38 with SLAEventBean

use of org.apache.oozie.SLAEventBean in project oozie by apache.

the class TestSLAEventsGetJPAExecutor method _testGetSLAEventsForSeqId.

private void _testGetSLAEventsForSeqId(String jobId) throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    SLAEventsGetJPAExecutor slaEventsGetAllCmd = new SLAEventsGetJPAExecutor();
    List<SLAEventBean> list = jpaService.execute(slaEventsGetAllCmd);
    assertNotNull(list);
    assertEquals(3, list.size());
}
Also used : JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean)

Example 39 with SLAEventBean

use of org.apache.oozie.SLAEventBean in project oozie by apache.

the class XDataTestCase method addRecordToSLAEventTable.

/**
 * Insert sla event for testing.
 *
 * @param slaId sla id
 * @param slaId app name
 * @param status sla status
 * @throws Exception thrown if unable to create sla bean
 */
@Deprecated
protected void addRecordToSLAEventTable(String slaId, String appName, SLAEvent.Status status, Date today) throws Exception {
    SLAEventBean sla = new SLAEventBean();
    sla.setSlaId(slaId);
    sla.setAppName(appName);
    sla.setParentClientId("parent-client-id");
    sla.setParentSlaId("parent-sla-id");
    sla.setExpectedStart(today);
    sla.setExpectedEnd(today);
    sla.setNotificationMsg("notification-msg");
    sla.setAlertContact("alert-contact");
    sla.setDevContact("dev-contact");
    sla.setQaContact("qa-contact");
    sla.setSeContact("se-contact");
    sla.setAlertFrequency("alert-frequency");
    sla.setAlertPercentage("alert-percentage");
    sla.setUpstreamApps("upstream-apps");
    sla.setAppType(SLAEvent.SlaAppType.WORKFLOW_JOB);
    sla.setUser(getTestUser());
    sla.setGroupName(getTestGroup());
    sla.setJobStatus(status);
    sla.setStatusTimestamp(today);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        SLAEventInsertJPAExecutor slaInsertCmd = new SLAEventInsertJPAExecutor(sla);
        jpaService.execute(slaInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test sla event record to table");
        throw je;
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) SLAEventInsertJPAExecutor(org.apache.oozie.executor.jpa.SLAEventInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean)

Example 40 with SLAEventBean

use of org.apache.oozie.SLAEventBean in project oozie by apache.

the class TestSLADbXOperations method testCreateSlaRegistrationEventMinReqFields.

@SuppressWarnings("deprecation")
public void testCreateSlaRegistrationEventMinReqFields() throws Exception {
    Date nomDate = DateUtils.parseDateOozieTZ("2014-01-01T01:01Z");
    String slaXML = " <sla:info xmlns:sla='uri:oozie:sla:0.2'>" + " <sla:nominal-time>" + DateUtils.formatDateOozieTZ(nomDate) + "</sla:nominal-time>" + " <sla:should-end>5</sla:should-end>" + "</sla:info>";
    Element eSla = XmlUtils.parseXml(slaXML);
    SLAEventBean regEvent = SLADbXOperations.createSlaRegistrationEvent(eSla, "id1", SLAEvent.SlaAppType.WORKFLOW_JOB, "user1", "group1");
    assertEquals(SLAEvent.SlaAppType.WORKFLOW_JOB, regEvent.getAppType());
    assertEquals(new Date(nomDate.getTime() + 5 * 60 * 1000), regEvent.getExpectedEnd());
    assertEquals("group1", regEvent.getGroupName());
    assertEquals("id1", regEvent.getSlaId());
    assertEquals("user1", regEvent.getUser());
}
Also used : Element(org.jdom.Element) Date(java.util.Date) SLAEventBean(org.apache.oozie.SLAEventBean)

Aggregations

SLAEventBean (org.apache.oozie.SLAEventBean)42 Date (java.util.Date)15 JPAService (org.apache.oozie.service.JPAService)14 CommandException (org.apache.oozie.command.CommandException)13 List (java.util.List)12 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)10 Element (org.jdom.Element)7 XException (org.apache.oozie.XException)6 WorkflowActionQuery (org.apache.oozie.executor.jpa.WorkflowActionQueryExecutor.WorkflowActionQuery)6 ArrayList (java.util.ArrayList)5 UpdateEntry (org.apache.oozie.executor.jpa.BatchQueryExecutor.UpdateEntry)5 WorkflowJobQuery (org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery)5 IOException (java.io.IOException)4 Configuration (org.apache.hadoop.conf.Configuration)4 ControlNodeActionExecutor (org.apache.oozie.action.control.ControlNodeActionExecutor)4 Status (org.apache.oozie.client.SLAEvent.Status)4 PreconditionException (org.apache.oozie.command.PreconditionException)4 Query (javax.persistence.Query)3 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)3 CoordActionQuery (org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery)3