Search in sources :

Example 1 with JobStatusCount

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);
        }
    }
}
Also used : JobStatusCountResult(com.thinkbiganalytics.jobrepo.query.model.JobStatusCountResult) JobStatusCount(com.thinkbiganalytics.jobrepo.query.model.JobStatusCount) Date(java.util.Date)

Example 2 with JobStatusCount

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;
}
Also used : JobStatusCountResult(com.thinkbiganalytics.jobrepo.query.model.JobStatusCountResult) JobStatusCount(com.thinkbiganalytics.jobrepo.query.model.JobStatusCount)

Example 3 with JobStatusCount

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();
        }
    });
}
Also used : ServiceLevelAgreementDescriptionProvider(com.thinkbiganalytics.metadata.api.sla.ServiceLevelAgreementDescriptionProvider) PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) DateTimeUtil(com.thinkbiganalytics.DateTimeUtil) ApiResponses(io.swagger.annotations.ApiResponses) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) AlertSummary(com.thinkbiganalytics.alerts.api.AlertSummary) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) AlertProvider(com.thinkbiganalytics.alerts.api.AlertProvider) HttpServletRequest(javax.servlet.http.HttpServletRequest) MediaType(javax.ws.rs.core.MediaType) Lists(com.google.common.collect.Lists) RestResponseStatus(com.thinkbiganalytics.rest.model.RestResponseStatus) QueryParam(javax.ws.rs.QueryParam) Alert(com.thinkbiganalytics.alerts.api.Alert) FeedHealth(com.thinkbiganalytics.jobrepo.query.model.FeedHealth) AccessController(com.thinkbiganalytics.security.AccessController) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) Api(io.swagger.annotations.Api) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) Period(org.joda.time.Period) JobStatusTransform(com.thinkbiganalytics.jobrepo.query.model.transform.JobStatusTransform) OpsManagerFeedProvider(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeedProvider) Context(javax.ws.rs.core.Context) FeedStatus(com.thinkbiganalytics.jobrepo.query.model.FeedStatus) OperationsAccessControl(com.thinkbiganalytics.jobrepo.security.OperationsAccessControl) ServiceLevelAgreementDescription(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementDescription) Collection(java.util.Collection) ExecutedFeed(com.thinkbiganalytics.jobrepo.query.model.ExecutedFeed) JobStatusCount(com.thinkbiganalytics.jobrepo.query.model.JobStatusCount) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) BatchJobExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecutionProvider) List(java.util.List) FeedModelTransform(com.thinkbiganalytics.jobrepo.query.model.transform.FeedModelTransform) ApiResponse(io.swagger.annotations.ApiResponse) KyloEntityAwareAlertManager(com.thinkbiganalytics.metadata.alerts.KyloEntityAwareAlertManager) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) AlertsModel(com.thinkbiganalytics.alerts.rest.AlertsModel) AlertSummaryGrouped(com.thinkbiganalytics.alerts.rest.model.AlertSummaryGrouped) OpsFeedManagerFeedProvider(com.thinkbiganalytics.metadata.jpa.feed.OpsFeedManagerFeedProvider) Collections(java.util.Collections) AlertCriteria(com.thinkbiganalytics.alerts.api.AlertCriteria) Period(org.joda.time.Period) JobStatusCount(com.thinkbiganalytics.jobrepo.query.model.JobStatusCount) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 4 with JobStatusCount

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();
    });
}
Also used : PathParam(javax.ws.rs.PathParam) ModelUtils(com.thinkbiganalytics.jobrepo.query.model.transform.ModelUtils) BatchStepExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.step.BatchStepExecutionProvider) SavepointReplayEvent(com.thinkbiganalytics.nifi.savepoint.model.SavepointReplayEvent) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) DateTimeUtil(com.thinkbiganalytics.DateTimeUtil) ApiResponses(io.swagger.annotations.ApiResponses) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) HttpServletRequest(javax.servlet.http.HttpServletRequest) MediaType(javax.ws.rs.core.MediaType) RestResponseStatus(com.thinkbiganalytics.rest.model.RestResponseStatus) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) AccessController(com.thinkbiganalytics.security.AccessController) DefaultValue(javax.ws.rs.DefaultValue) JobModelTransform(com.thinkbiganalytics.jobrepo.query.model.transform.JobModelTransform) Api(io.swagger.annotations.Api) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) NifiFeedStatisticsProvider(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStatisticsProvider) Period(org.joda.time.Period) JobStatusTransform(com.thinkbiganalytics.jobrepo.query.model.transform.JobStatusTransform) OpsManagerFeedProvider(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeedProvider) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) Context(javax.ws.rs.core.Context) OperationsAccessControl(com.thinkbiganalytics.jobrepo.security.OperationsAccessControl) ExecutedJob(com.thinkbiganalytics.jobrepo.query.model.ExecutedJob) Page(org.springframework.data.domain.Page) JobStatusCount(com.thinkbiganalytics.jobrepo.query.model.JobStatusCount) JobAction(com.thinkbiganalytics.jobrepo.repository.rest.model.JobAction) SearchResult(com.thinkbiganalytics.rest.model.search.SearchResult) Collectors(java.util.stream.Collectors) BatchJobExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecutionProvider) List(java.util.List) Response(javax.ws.rs.core.Response) SavepointReplayJobExecution(com.thinkbiganalytics.jobrepo.model.SavepointReplayJobExecution) ApiResponse(io.swagger.annotations.ApiResponse) JobExecutionException(com.thinkbiganalytics.jobrepo.service.JobExecutionException) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) JobService(com.thinkbiganalytics.jobrepo.service.JobService) Collections(java.util.Collections) Period(org.joda.time.Period) JobStatusCount(com.thinkbiganalytics.jobrepo.query.model.JobStatusCount) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

JobStatusCount (com.thinkbiganalytics.jobrepo.query.model.JobStatusCount)4 DateTimeUtil (com.thinkbiganalytics.DateTimeUtil)2 JobStatusCountResult (com.thinkbiganalytics.jobrepo.query.model.JobStatusCountResult)2 JobStatusTransform (com.thinkbiganalytics.jobrepo.query.model.transform.JobStatusTransform)2 OperationsAccessControl (com.thinkbiganalytics.jobrepo.security.OperationsAccessControl)2 MetadataAccess (com.thinkbiganalytics.metadata.api.MetadataAccess)2 OpsManagerFeedProvider (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeedProvider)2 BatchJobExecution (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution)2 BatchJobExecutionProvider (com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecutionProvider)2 RestResponseStatus (com.thinkbiganalytics.rest.model.RestResponseStatus)2 AccessController (com.thinkbiganalytics.security.AccessController)2 Api (io.swagger.annotations.Api)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponse (io.swagger.annotations.ApiResponse)2 ApiResponses (io.swagger.annotations.ApiResponses)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Inject (javax.inject.Inject)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2