Search in sources :

Example 6 with TaskDTO

use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.

the class JobResource method listTasksForJob.

@GET
@Path("/listTasksForJob")
@Produces(MediaType.APPLICATION_JSON)
public String listTasksForJob(@NotNull @QueryParam("jobId") long jobId) {
    Map<String, Object> filters = new HashMap<>();
    filters.put("jobId", jobId);
    List<TaskDTO> taskDTOs = taskDao.findByParams(filters);
    ObjectNode rootNode = JsonResponseUtil.buildResponseJSON(taskDTOs);
    return rootNode.toString();
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) HashMap(java.util.HashMap) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 7 with TaskDTO

use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.

the class TaskManagerImpl method findByStatusOrderByCreateTime.

@Override
public List<TaskDTO> findByStatusOrderByCreateTime(TaskStatus status, int fetchSize, boolean asc) {
    Map<String, Object> parameterMap = new HashMap<>();
    parameterMap.put("status", status.toString());
    List<TaskBean> list;
    String queryClause = (asc) ? FIND_BY_STATUS_ORDER_BY_CREATE_TIME_ASC : FIND_BY_STATUS_ORDER_BY_CREATE_TIME_DESC;
    list = genericPojoDao.executeParameterizedSQL(queryClause, parameterMap, TaskBean.class);
    List<TaskDTO> result = new ArrayList<>();
    for (TaskBean bean : list) {
        result.add((TaskDTO) MODEL_MAPPER.map(bean, TaskDTO.class));
    }
    return result;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TaskBean(com.linkedin.thirdeye.datalayer.pojo.TaskBean) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO)

Example 8 with TaskDTO

use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.

the class GenericResultSetMapper method main.

public static void main(String[] args) throws Exception {
    ModelMapper mapper = new ModelMapper();
    Map<String, Object> result = new HashMap<>();
    //[{jobName=Test_Anomaly_Task, jobId=1, workerId=1, taskType=MONITOR, id=1, taskInfo=clob2: '{"jobExecutionId":1,"monitorType":"UPDATE","expireDaysAgo":0}', lastModified=2016-08-24 17:25:53.258, version=0, taskStartTime=1470356753227, status=RUNNING, taskEndTime=1471220753227}]
    result.put("jobName", "Test_Anomaly_Task");
    result.put("jobId", 1L);
    result.put("taskType", "MONITOR");
    result.put("id", 1L);
    result.put("taskInfo", "clob2: '{\"jobExecutionId\":1,\"monitorType\":\"UPDATE\",\"expireDaysAgo\":0}'");
    result.put("taskType", "MONITOR");
    result.put("lastModified", "2016-08-24 17:25:53.258");
    result.put("status", "RUNNING");
    result.put("lastModified", "2016-08-24 17:25:53.258");
    TaskDTO taskSpec1 = mapper.map(result, TaskDTO.class);
    System.out.println(taskSpec1);
    //INPUT 2
    ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("/tmp/map.out.1472093046128")));
    Map<String, Object> inputMap = (Map<String, Object>) ois.readObject();
    TaskDTO taskSpec2 = mapper.map(inputMap, TaskDTO.class);
    System.out.println(taskSpec2);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) File(java.io.File) BiMap(com.google.common.collect.BiMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) FileInputStream(java.io.FileInputStream) ModelMapper(org.modelmapper.ModelMapper) ObjectInputStream(java.io.ObjectInputStream)

Example 9 with TaskDTO

use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.

the class TestAnomalyTaskManager method testUpdateStatusAndTaskEndTime.

@Test(dependsOnMethods = { "testFindByStatusOrderByCreationTimeAsc" })
public void testUpdateStatusAndTaskEndTime() {
    TaskStatus oldStatus = TaskStatus.RUNNING;
    TaskStatus newStatus = TaskStatus.COMPLETED;
    long taskEndTime = System.currentTimeMillis();
    taskDAO.updateStatusAndTaskEndTime(anomalyTaskId1, oldStatus, newStatus, taskEndTime);
    TaskDTO anomalyTask = taskDAO.findById(anomalyTaskId1);
    Assert.assertEquals(anomalyTask.getStatus(), newStatus);
    Assert.assertEquals(anomalyTask.getEndTime(), taskEndTime);
}
Also used : TaskStatus(com.linkedin.thirdeye.anomaly.task.TaskConstants.TaskStatus) TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) Test(org.testng.annotations.Test)

Example 10 with TaskDTO

use of com.linkedin.thirdeye.datalayer.dto.TaskDTO in project pinot by linkedin.

the class TestAnomalyTaskManager method getTestTaskSpec.

TaskDTO getTestTaskSpec(JobDTO anomalyJobSpec) throws JsonProcessingException {
    TaskDTO jobSpec = new TaskDTO();
    jobSpec.setJobName("Test_Anomaly_Task");
    jobSpec.setStatus(TaskStatus.WAITING);
    jobSpec.setTaskType(TaskType.ANOMALY_DETECTION);
    jobSpec.setStartTime(new DateTime().minusDays(20).getMillis());
    jobSpec.setEndTime(new DateTime().minusDays(10).getMillis());
    jobSpec.setTaskInfo(new ObjectMapper().writeValueAsString(getTestDetectionTaskInfo()));
    jobSpec.setJobId(anomalyJobSpec.getId());
    return jobSpec;
}
Also used : TaskDTO(com.linkedin.thirdeye.datalayer.dto.TaskDTO) DateTime(org.joda.time.DateTime) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

TaskDTO (com.linkedin.thirdeye.datalayer.dto.TaskDTO)22 ArrayList (java.util.ArrayList)10 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)5 Test (org.testng.annotations.Test)4 TaskStatus (com.linkedin.thirdeye.anomaly.task.TaskConstants.TaskStatus)3 TaskBean (com.linkedin.thirdeye.datalayer.pojo.TaskBean)3 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)3 HashMap (java.util.HashMap)3 JobDTO (com.linkedin.thirdeye.datalayer.dto.JobDTO)2 JobExecutionException (org.quartz.JobExecutionException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BiMap (com.google.common.collect.BiMap)1 Transactional (com.google.inject.persist.Transactional)1 AlertTaskInfo (com.linkedin.thirdeye.anomaly.alert.AlertTaskInfo)1 TaskType (com.linkedin.thirdeye.anomaly.task.TaskConstants.TaskType)1 DataCompletenessTaskInfo (com.linkedin.thirdeye.completeness.checker.DataCompletenessTaskInfo)1 JobManager (com.linkedin.thirdeye.datalayer.bao.JobManager)1 TaskManager (com.linkedin.thirdeye.datalayer.bao.TaskManager)1 MergedAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO)1 RawAnomalyResultDTO (com.linkedin.thirdeye.datalayer.dto.RawAnomalyResultDTO)1