use of com.thinkbiganalytics.jobrepo.query.model.JobStatusCount in project kylo by Teradata.
the class JobStatusTransform method ensureDateFromPeriodExists.
/**
* Enusre that the list contains a date matching Now - the Period. if not add it to the collection
*/
public static void ensureDateFromPeriodExists(List<JobStatusCount> jobStatusCounts, Period period) {
// add in the very first date relative to the period if it doesnt exist with a count of 0
if (jobStatusCounts != null && !jobStatusCounts.isEmpty()) {
// get the first min date in the result set
Date firstDateInResultSet = jobStatusCounts.stream().map(jobStatusCount -> jobStatusCount.getDate()).min(Date::compareTo).get();
Date firstDate = DateUtils.truncate(DateTimeUtil.getNowUTCTime().minus(period).toDate(), Calendar.DATE);
boolean containsFirstDate = jobStatusCounts.stream().anyMatch(jobStatusCount -> jobStatusCount.getDate().equals(firstDate));
if (!containsFirstDate) {
JobStatusCount first = jobStatusCounts.get(0);
JobStatusCount min = new JobStatusCountResult(first);
min.setDate(firstDate);
min.setCount(new Long(0));
jobStatusCounts.add(min);
}
}
}
use of com.thinkbiganalytics.jobrepo.query.model.JobStatusCount in project kylo by Teradata.
the class JobStatusTransform method jobStatusCount.
public static JobStatusCount jobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount domain) {
JobStatusCount count = new JobStatusCountResult();
count.setCount(domain.getCount());
if (domain.getDate() != null) {
count.setDate(domain.getDate().toDate());
}
count.setFeedName(domain.getFeedName());
count.setFeedId(domain.getFeedId());
count.setStatus(domain.getStatus());
return count;
}
use of com.thinkbiganalytics.jobrepo.query.model.JobStatusCount in project kylo by Teradata.
the class FeedsRestController method findFeedDailyStatusCount.
@GET
@Path("/{feedName}/daily-status-count")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets a daily health summary for the specified feed.")
@ApiResponses(@ApiResponse(code = 200, message = "Returns the health.", response = JobStatusCount.class, responseContainer = "List"))
public List<JobStatusCount> findFeedDailyStatusCount(@PathParam("feedName") String feedName, @QueryParam("period") String periodString) {
this.accessController.checkPermission(AccessController.SERVICES, OperationsAccessControl.ACCESS_OPS);
return metadataAccess.read(() -> {
Period period = DateTimeUtil.period(periodString);
List<com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount> counts = opsFeedManagerFeedProvider.getJobStatusCountByDateFromNow(feedName, period);
if (counts != null) {
List<JobStatusCount> jobStatusCounts = counts.stream().map(c -> JobStatusTransform.jobStatusCount(c)).collect(Collectors.toList());
JobStatusTransform.ensureDateFromPeriodExists(jobStatusCounts, period);
return jobStatusCounts;
} else {
return Collections.emptyList();
}
});
}
use of com.thinkbiganalytics.jobrepo.query.model.JobStatusCount in project kylo by Teradata.
the class JobsRestController method findDailyStatusCount.
@GET
@Path("/daily-status-count")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Gets the daily statistics.")
@ApiResponses(@ApiResponse(code = 200, message = "Returns the daily stats.", response = JobStatusCount.class, responseContainer = "List"))
public List<JobStatusCount> findDailyStatusCount(@QueryParam("period") String periodString) {
this.accessController.checkPermission(AccessController.SERVICES, OperationsAccessControl.ACCESS_OPS);
Period period = DateTimeUtil.period(periodString);
return metadataAccess.read(() -> {
List<com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount> counts = jobExecutionProvider.getJobStatusCountByDateFromNow(period, null);
if (counts != null) {
List<JobStatusCount> jobStatusCounts = counts.stream().map(c -> JobStatusTransform.jobStatusCount(c)).collect(Collectors.toList());
JobStatusTransform.ensureDateFromPeriodExists(jobStatusCounts, period);
return jobStatusCounts;
}
return Collections.emptyList();
});
}
Aggregations