use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class TestSLARegistrationGetJPAExecutor method testSLARegistrationBulkConfigMap.
public void testSLARegistrationBulkConfigMap() throws Exception {
Date current = new Date();
String jobId = "0000000-" + current.getTime() + "-TestSLARegGetJPAExecutor-C@1";
List<String> jobIds = new ArrayList<String>();
jobIds.add(jobId);
_addRecordToSLARegistrationTable(jobId, AppType.COORDINATOR_ACTION, current, new Date(), "END_MISS", "alert@example.com");
jobId = "0000000-" + current.getTime() + "-TestSLARegGetJPAExecutor-C@2";
jobIds.add(jobId);
_addRecordToSLARegistrationTable(jobId, AppType.COORDINATOR_ACTION, current, new Date(), "END_MISS", "alert@example.com");
List<SLARegistrationBean> bean = SLARegistrationQueryExecutor.getInstance().getList(SLARegQuery.GET_SLA_CONFIGS, jobIds);
assertEquals(bean.size(), 2);
}
use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class TestSLARegistrationGetJPAExecutor method _addRecordToSLARegistrationTable.
private void _addRecordToSLARegistrationTable(String jobId, AppType appType, Date start, Date end, String alertEvent, String alertContact) throws Exception {
SLARegistrationBean reg = new SLARegistrationBean();
reg.setId(jobId);
reg.setAppType(appType);
reg.setExpectedStart(start);
reg.setExpectedEnd(end);
reg.setAlertEvents(alertEvent);
reg.setAlertContact(alertContact);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
List<JsonBean> insert = new ArrayList<JsonBean>();
insert.add(reg);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insert, null, null);
} catch (JPAExecutorException je) {
fail("Unable to insert the test sla registration record to table");
throw je;
}
}
use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class TestSLARegistrationGetJPAExecutor method testSlaConfigStringToMap.
public void testSlaConfigStringToMap() {
String slaConfig = "{alert_contact=hadoopqa@oozie.com},{alert_events=START_MISS,DURATION_MISS,END_MISS},";
SLARegistrationBean bean = new SLARegistrationBean();
bean.setSlaConfig(slaConfig);
assertEquals(bean.getSLAConfigMap().size(), 2);
assertEquals(bean.getAlertEvents(), "START_MISS,DURATION_MISS,END_MISS");
assertEquals(bean.getAlertContact(), "hadoopqa@oozie.com");
}
use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class XDataTestCase method addRecordToSLARegistrationTable.
/**
* Insert sla registration for test
* @param appName application name
* @param status sla status
* @return
* @throws Exception
*/
protected SLARegistrationBean addRecordToSLARegistrationTable(String appName, SLAStatus status) throws Exception {
SLARegistrationBean sla = new SLARegistrationBean();
Date today = new Date();
sla.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.COORDINATOR));
sla.setAppName(appName);
sla.setAppType(AppType.COORDINATOR_JOB);
sla.setExpectedDuration(100);
sla.setExpectedEnd(today);
sla.setExpectedStart(today);
sla.setJobData("test-job-data");
sla.setCreatedTime(today);
sla.setNominalTime(today);
sla.setNotificationMsg("test-sla-notification-msg");
sla.setParentId(Services.get().get(UUIDService.class).generateId(ApplicationType.BUNDLE));
sla.setSlaConfig("alert-events");
sla.setUpstreamApps("test-upstream-apps");
sla.setUser("oozie");
try {
SLARegistrationQueryExecutor.getInstance().insert(sla);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test sla registration record to table");
throw je;
}
return sla;
}
use of org.apache.oozie.sla.SLARegistrationBean in project oozie by apache.
the class TestSLARegistrationQueryExecutor method testGetUpdateQuery.
public void testGetUpdateQuery() throws Exception {
EntityManager em = jpaService.getEntityManager();
SLARegistrationBean bean = addRecordToSLARegistrationTable("test-application", SLAStatus.MET);
// UPDATE_SLA_REG_ALL
Query query = SLARegistrationQueryExecutor.getInstance().getUpdateQuery(SLARegQuery.UPDATE_SLA_REG_ALL, bean, em);
assertEquals(query.getParameterValue("jobId"), bean.getId());
assertEquals(query.getParameterValue("nominalTime"), bean.getNominalTimestamp());
assertEquals(query.getParameterValue("expectedStartTime"), bean.getExpectedStartTimestamp());
assertEquals(query.getParameterValue("expectedEndTime"), bean.getExpectedEndTimestamp());
assertEquals(query.getParameterValue("expectedDuration"), bean.getExpectedDuration());
assertEquals(query.getParameterValue("slaConfig"), bean.getSlaConfig());
assertEquals(query.getParameterValue("notificationMsg"), bean.getNotificationMsg());
assertEquals(query.getParameterValue("upstreamApps"), bean.getUpstreamApps());
assertEquals(query.getParameterValue("appType"), bean.getAppType().toString());
assertEquals(query.getParameterValue("appName"), bean.getAppName());
assertEquals(query.getParameterValue("user"), bean.getUser());
assertEquals(query.getParameterValue("parentId"), bean.getParentId());
assertEquals(query.getParameterValue("jobData"), bean.getJobData());
em.close();
}
Aggregations