public JobCountResponse getHistoryJobCountGroupByDuration(List<JobExecutionAPIEntity> jobDurations, String timeList) { JobCountResponse response = new JobCountResponse(); List<UnitJobCount> jobCounts = new ArrayList<>(); Set<String> jobTypes = new HashSet<>(); List<Long> times = ResourceUtils.parseDistributionList(timeList); for (int i = 0; i < times.size(); i++) { jobCounts.add(new UnitJobCount(times.get(i))); } for (JobExecutionAPIEntity job : jobDurations) { int jobIndex = ResourceUtils.getDistributionPosition(times, job.getDurationTime() / DateTimeUtil.ONESECOND); UnitJobCount counter = jobCounts.get(jobIndex); String jobType = job.getTags().get(MRJobTagName.JOB_TYPE.toString()); jobTypes.add(jobType); countJob(counter, jobType); } response.jobCounts = jobCounts; response.jobTypes = jobTypes; return response; }
metrics.add(metricWrapper(timeStamp, Constants.JOB_EXECUTION_TIME, new double[]{entity.getDurationTime()}, tags));
@Override public void jobEntityCreated(JobBaseAPIEntity entity) throws Exception { if (entity instanceof TaskExecutionAPIEntity) { info.getTasksMap().put(entity.getTags().get(TASK_ID.toString()), (TaskExecutionAPIEntity) entity); } else if (entity instanceof TaskAttemptExecutionAPIEntity) { info.getCompletedTaskAttemptsMap().put(entity.getTags().get(TASK_ATTEMPT_ID.toString()), (TaskAttemptExecutionAPIEntity) entity); } else if (entity instanceof JobExecutionAPIEntity) { JobExecutionAPIEntity jobExecutionAPIEntity = (JobExecutionAPIEntity) entity; info.setCurrentState(jobExecutionAPIEntity.getCurrentState()); info.setStartTime(jobExecutionAPIEntity.getStartTime()); info.setEndTime(jobExecutionAPIEntity.getEndTime()); info.setDurationTime(jobExecutionAPIEntity.getDurationTime()); info.setUserId(jobExecutionAPIEntity.getTags().get(MRJobTagName.USER.toString())); info.setJobId(jobExecutionAPIEntity.getTags().get(MRJobTagName.JOB_ID.toString())); info.setJobDefId(jobExecutionAPIEntity.getTags().get(MRJobTagName.JOD_DEF_ID.toString())); info.setSiteId(jobExecutionAPIEntity.getTags().get(MRJobTagName.SITE.toString())); info.setJobName(jobExecutionAPIEntity.getTags().get(MRJobTagName.JOB_NAME.toString())) ; info.setJobQueueName(jobExecutionAPIEntity.getTags().get(MRJobTagName.JOB_QUEUE.toString())); info.setJobType(jobExecutionAPIEntity.getTags().get(MRJobTagName.JOB_TYPE.toString())); info.setFinishedMaps(jobExecutionAPIEntity.getNumFinishedMaps()); info.setFinishedReduces(jobExecutionAPIEntity.getNumFinishedReduces()); info.setFailedReduces(jobExecutionAPIEntity.getNumFailedReduces()); info.setFailedMaps(jobExecutionAPIEntity.getNumFailedMaps()); info.setTotalMaps(jobExecutionAPIEntity.getNumTotalMaps()); info.setTotalReduces(jobExecutionAPIEntity.getNumTotalReduces()); info.setProgress(100); info.setTrackingUrl(((JobExecutionAPIEntity) entity).getTrackingUrl()); } }