use of com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount in project kylo by Teradata.
the class JpaBatchJobExecutionTest method testJobStatusCountFromNow.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin" })
@Test
public void testJobStatusCountFromNow() {
operationalMetadataAccess.read(() -> {
Period period = DateTimeUtil.period("3Y");
List<JobStatusCount> counts = jobExecutionProvider.getJobStatusCountByDateFromNow(period, null);
return counts;
});
}
use of com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount in project kylo by Teradata.
the class JpaBatchJobExecutionProvider method getJobStatusCount.
/**
* Get count of Jobs grouped by Status
* Streaming Feeds are given a count of 1 if they are running, regardless of the number of active running flows
*/
@Override
public List<JobStatusCount> getJobStatusCount(String filter) {
QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
QJpaBatchJobInstance jobInstance = QJpaBatchJobInstance.jpaBatchJobInstance;
QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
BooleanBuilder whereBuilder = new BooleanBuilder();
if (StringUtils.isNotBlank(filter)) {
whereBuilder.and(GenericQueryDslFilter.buildFilter(jobExecution, filter));
}
ConstructorExpression<JpaBatchJobExecutionStatusCounts> expr = Projections.constructor(JpaBatchJobExecutionStatusCounts.class, JobStatusDslQueryExpressionBuilder.jobState().as("status"), jobExecution.jobExecutionId.count().as("count"));
JPAQuery<?> query = factory.select(expr).from(jobExecution).innerJoin(jobInstance).on(jobExecution.jobInstance.jobInstanceId.eq(jobInstance.jobInstanceId)).innerJoin(feed).on(jobInstance.feed.id.eq(feed.id)).where(whereBuilder.and(feed.isStream.eq(false)).and(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, controller.isEntityAccessControlled()))).groupBy(jobExecution.status);
List<JobStatusCount> stats = (List<JobStatusCount>) query.fetch();
// merge in streaming feed stats
List<? extends NifiFeedStats> streamingFeedStats = feedStatisticsProvider.findFeedStats(true);
if (streamingFeedStats != null) {
if (stats == null) {
stats = new ArrayList<>();
}
Long runningCount = streamingFeedStats.stream().filter(s -> s.getRunningFeedFlows() > 0L).count();
if (runningCount > 0) {
JobStatusCount runningStatusCount = stats.stream().filter(s -> s.getStatus().equalsIgnoreCase(BatchJobExecution.RUNNING_DISPLAY_STATUS)).findFirst().orElse(null);
if (runningStatusCount != null) {
runningCount = runningStatusCount.getCount() + runningCount;
runningStatusCount.setCount(runningCount);
} else {
JpaBatchJobExecutionStatusCounts runningStreamingFeedCounts = new JpaBatchJobExecutionStatusCounts();
runningStreamingFeedCounts.setCount(runningCount);
runningStreamingFeedCounts.setStatus(BatchJobExecution.RUNNING_DISPLAY_STATUS);
stats.add(runningStreamingFeedCounts);
}
}
}
return stats;
}
use of com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount in project kylo by Teradata.
the class JpaFeedProviderTest method testJobStatusCountFromNow.
@WithMockJaasUser(username = "dladmin", password = "secret", authorities = { "admin" })
@Test
public void testJobStatusCountFromNow() {
String feedName = "movies.new_releases";
metadataAccess.read(() -> {
Period period = DateTimeUtil.period("10W");
List<JobStatusCount> counts = feedProvider.getJobStatusCountByDateFromNow(feedName, period);
return counts;
});
}
Aggregations