Search in sources :

Example 6 with QJpaOpsManagerFeed

use of com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed 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;
}
Also used : AlertManager(com.thinkbiganalytics.alerts.spi.AlertManager) JobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount) BatchRelatedFlowFile(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchRelatedFlowFile) ClusterServiceMessageReceiver(com.thinkbiganalytics.cluster.ClusterServiceMessageReceiver) JpaNifiEventJobExecution(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiEventJobExecution) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Projections(com.querydsl.core.types.Projections) FeedAclIndexQueryAugmentor(com.thinkbiganalytics.metadata.jpa.feed.FeedAclIndexQueryAugmentor) StringUtils(org.apache.commons.lang3.StringUtils) GenericQueryDslFilter(com.thinkbiganalytics.metadata.jpa.support.GenericQueryDslFilter) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) BatchAndStreamingJobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchAndStreamingJobStatusCount) Map(java.util.Map) AccessController(com.thinkbiganalytics.security.AccessController) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) Pageable(org.springframework.data.domain.Pageable) BigInteger(java.math.BigInteger) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) NifiFeedStatisticsProvider(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStatisticsProvider) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ClusterMessage(com.thinkbiganalytics.cluster.ClusterMessage) Page(org.springframework.data.domain.Page) Expression(com.querydsl.core.types.Expression) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) Collectors(java.util.stream.Collectors) JPAExpressions(com.querydsl.jpa.JPAExpressions) JpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.JpaOpsManagerFeed) JPAQuery(com.querydsl.jpa.impl.JPAQuery) BatchJobExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecutionProvider) ReadablePeriod(org.joda.time.ReadablePeriod) List(java.util.List) ExecutionConstants(com.thinkbiganalytics.metadata.api.jobrepo.ExecutionConstants) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) PostConstruct(javax.annotation.PostConstruct) ClusterService(com.thinkbiganalytics.cluster.ClusterService) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) CommonFilterTranslations(com.thinkbiganalytics.metadata.jpa.support.CommonFilterTranslations) Predicate(com.querydsl.core.types.Predicate) SearchCriteria(com.thinkbiganalytics.metadata.api.SearchCriteria) Authentication(org.springframework.security.core.Authentication) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FeedOperationBatchStatusChange(com.thinkbiganalytics.metadata.api.event.feed.FeedOperationBatchStatusChange) BatchStepExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.step.BatchStepExecutionProvider) Stopwatch(com.google.common.base.Stopwatch) MessageDigest(java.security.MessageDigest) DateTimeUtil(com.thinkbiganalytics.DateTimeUtil) BooleanBuilder(com.querydsl.core.BooleanBuilder) QOpsManagerFeedId(com.thinkbiganalytics.metadata.jpa.feed.QOpsManagerFeedId) BooleanUtils(org.apache.commons.lang3.BooleanUtils) HashMap(java.util.HashMap) JPQLQuery(com.querydsl.jpa.JPQLQuery) DefaultAlertChangeEventContent(com.thinkbiganalytics.alerts.spi.DefaultAlertChangeEventContent) QueryDslFetchJoin(com.thinkbiganalytics.metadata.jpa.support.QueryDslFetchJoin) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) AlertProvider(com.thinkbiganalytics.alerts.api.AlertProvider) RoleSetExposingSecurityExpressionRoot(com.thinkbiganalytics.metadata.config.RoleSetExposingSecurityExpressionRoot) NifiRelatedRootFlowFilesRepository(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.NifiRelatedRootFlowFilesRepository) Alert(com.thinkbiganalytics.alerts.api.Alert) CheckDataStepConstants(com.thinkbiganalytics.jobrepo.common.constants.CheckDataStepConstants) Service(org.springframework.stereotype.Service) QueryDslPagingSupport(com.thinkbiganalytics.metadata.jpa.support.QueryDslPagingSupport) Named(javax.inject.Named) ProvenanceEventRecordDTO(com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTO) FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) Logger(org.slf4j.Logger) BatchJobInstance(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobInstance) FeedNameUtil(com.thinkbiganalytics.support.FeedNameUtil) OptimisticLockException(javax.persistence.OptimisticLockException) ConstructorExpression(com.querydsl.core.types.ConstructorExpression) DateTime(org.joda.time.DateTime) NifiFeedStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory) OperationalAlerts(com.thinkbiganalytics.metadata.api.alerts.OperationalAlerts) QJpaNifiFeedStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.QJpaNifiFeedStats) TimeUnit(java.util.concurrent.TimeUnit) JobStatusDslQueryExpressionBuilder(com.thinkbiganalytics.metadata.jpa.support.JobStatusDslQueryExpressionBuilder) QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) FeedConstants(com.thinkbiganalytics.jobrepo.common.constants.FeedConstants) Collections(java.util.Collections) OpsManagerFeedRepository(com.thinkbiganalytics.metadata.jpa.feed.OpsManagerFeedRepository) QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) JobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount) BatchAndStreamingJobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchAndStreamingJobStatusCount) BooleanBuilder(com.querydsl.core.BooleanBuilder) List(java.util.List) ArrayList(java.util.ArrayList)

Example 7 with QJpaOpsManagerFeed

use of com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed in project kylo by Teradata.

the class JpaBatchJobExecutionProvider method findAllForFeed.

private Page<? extends BatchJobExecution> findAllForFeed(String feedName, List<SearchCriteria> filters, Pageable pageable) {
    QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    QJpaOpsManagerFeed checkDataFeed = new QJpaOpsManagerFeed("checkDataFeed");
    QJpaBatchJobInstance jobInstance = QJpaBatchJobInstance.jpaBatchJobInstance;
    JPQLQuery checkFeedQuery = JPAExpressions.select(checkDataFeed.id).from(feed).join(feed.checkDataFeeds, checkDataFeed).where(feed.name.eq(feedName));
    JPAQuery query = factory.select(jobExecution).from(jobExecution).join(jobExecution.jobInstance, jobInstance).join(jobInstance.feed, feed).where((feed.name.eq(feedName).or(feed.id.in(checkFeedQuery))).and(GenericQueryDslFilter.buildFilter(jobExecution, filters).and(augment(feed.id)))).fetchAll();
    pageable = CommonFilterTranslations.resolveSortFilters(jobExecution, pageable);
    return findAll(query, pageable);
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) JPQLQuery(com.querydsl.jpa.JPQLQuery) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 8 with QJpaOpsManagerFeed

use of com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed in project kylo by Teradata.

the class JpaBatchJobExecutionProvider method getJobStatusCountByDate.

@Override
public List<JobStatusCount> getJobStatusCountByDate() {
    QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
    QJpaBatchJobInstance jobInstance = QJpaBatchJobInstance.jpaBatchJobInstance;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    JPAQuery query = factory.select(Projections.constructor(JpaBatchJobExecutionStatusCounts.class, JobStatusDslQueryExpressionBuilder.jobState().as("status"), jobExecution.startYear, jobExecution.startMonth, jobExecution.startDay, jobExecution.count().as("count"))).from(jobExecution).innerJoin(jobInstance).on(jobExecution.jobInstance.jobInstanceId.eq(jobInstance.jobInstanceId)).innerJoin(feed).on(jobInstance.feed.id.eq(feed.id)).where(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, controller.isEntityAccessControlled())).groupBy(jobExecution.status, jobExecution.startYear, jobExecution.startMonth, jobExecution.startDay);
    return (List<JobStatusCount>) query.fetch();
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) List(java.util.List) ArrayList(java.util.ArrayList) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 9 with QJpaOpsManagerFeed

use of com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed in project kylo by Teradata.

the class JpaBatchJobExecutionProvider method getBatchAndStreamingJobCounts.

/**
 * 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
 */
public List<BatchAndStreamingJobStatusCount> getBatchAndStreamingJobCounts(String filter) {
    QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
    QJpaBatchJobInstance jobInstance = QJpaBatchJobInstance.jpaBatchJobInstance;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    QJpaNifiFeedStats feedStats = QJpaNifiFeedStats.jpaNifiFeedStats;
    BooleanBuilder whereBuilder = new BooleanBuilder();
    if (StringUtils.isNotBlank(filter)) {
        whereBuilder.and(GenericQueryDslFilter.buildFilter(jobExecution, filter));
    }
    Expression<JpaBatchAndStreamingJobStatusCounts> expr = Projections.bean(JpaBatchAndStreamingJobStatusCounts.class, JobStatusDslQueryExpressionBuilder.jobState().as("status"), feed.id.as("opsManagerFeedId"), feed.name.as("feedName"), feed.isStream.as("isStream"), feedStats.runningFeedFlows.as("runningFeedFlows"), jobExecution.jobExecutionId.count().as("count"), feedStats.lastActivityTimestamp.max().as("lastActivityTimestamp"));
    JPAQuery<?> query = factory.select(expr).from(feed).innerJoin(jobInstance).on(jobInstance.feed.id.eq(feed.id)).innerJoin(jobExecution).on(jobExecution.jobInstance.jobInstanceId.eq(jobInstance.jobInstanceId)).leftJoin(feedStats).on(feed.id.uuid.eq(feedStats.feedId.uuid)).where(whereBuilder).groupBy(jobExecution.status, feed.id, feed.name, feed.isStream, feedStats.runningFeedFlows);
    List<BatchAndStreamingJobStatusCount> stats = (List<BatchAndStreamingJobStatusCount>) query.fetch();
    return stats.stream().map(s -> {
        if (s.isStream() && (BatchJobExecution.RUNNING_DISPLAY_STATUS.equalsIgnoreCase(s.getStatus()) || BatchJobExecution.JobStatus.STARTING.name().equalsIgnoreCase(s.getStatus()) || BatchJobExecution.JobStatus.STARTED.name().equalsIgnoreCase(s.getStatus())) && s.getRunningFeedFlows() == 0L) {
            ((JpaBatchAndStreamingJobStatusCounts) s).setStatus(BatchJobExecution.JobStatus.STOPPED.name());
        }
        return s;
    }).collect(Collectors.toList());
// return stats;
}
Also used : AlertManager(com.thinkbiganalytics.alerts.spi.AlertManager) JobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount) BatchRelatedFlowFile(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchRelatedFlowFile) ClusterServiceMessageReceiver(com.thinkbiganalytics.cluster.ClusterServiceMessageReceiver) JpaNifiEventJobExecution(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiEventJobExecution) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Projections(com.querydsl.core.types.Projections) FeedAclIndexQueryAugmentor(com.thinkbiganalytics.metadata.jpa.feed.FeedAclIndexQueryAugmentor) StringUtils(org.apache.commons.lang3.StringUtils) GenericQueryDslFilter(com.thinkbiganalytics.metadata.jpa.support.GenericQueryDslFilter) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) BatchAndStreamingJobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchAndStreamingJobStatusCount) Map(java.util.Map) AccessController(com.thinkbiganalytics.security.AccessController) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) Pageable(org.springframework.data.domain.Pageable) BigInteger(java.math.BigInteger) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) NifiFeedStatisticsProvider(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStatisticsProvider) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ClusterMessage(com.thinkbiganalytics.cluster.ClusterMessage) Page(org.springframework.data.domain.Page) Expression(com.querydsl.core.types.Expression) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) Collectors(java.util.stream.Collectors) JPAExpressions(com.querydsl.jpa.JPAExpressions) JpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.JpaOpsManagerFeed) JPAQuery(com.querydsl.jpa.impl.JPAQuery) BatchJobExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecutionProvider) ReadablePeriod(org.joda.time.ReadablePeriod) List(java.util.List) ExecutionConstants(com.thinkbiganalytics.metadata.api.jobrepo.ExecutionConstants) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) PostConstruct(javax.annotation.PostConstruct) ClusterService(com.thinkbiganalytics.cluster.ClusterService) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) CommonFilterTranslations(com.thinkbiganalytics.metadata.jpa.support.CommonFilterTranslations) Predicate(com.querydsl.core.types.Predicate) SearchCriteria(com.thinkbiganalytics.metadata.api.SearchCriteria) Authentication(org.springframework.security.core.Authentication) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FeedOperationBatchStatusChange(com.thinkbiganalytics.metadata.api.event.feed.FeedOperationBatchStatusChange) BatchStepExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.step.BatchStepExecutionProvider) Stopwatch(com.google.common.base.Stopwatch) MessageDigest(java.security.MessageDigest) DateTimeUtil(com.thinkbiganalytics.DateTimeUtil) BooleanBuilder(com.querydsl.core.BooleanBuilder) QOpsManagerFeedId(com.thinkbiganalytics.metadata.jpa.feed.QOpsManagerFeedId) BooleanUtils(org.apache.commons.lang3.BooleanUtils) HashMap(java.util.HashMap) JPQLQuery(com.querydsl.jpa.JPQLQuery) DefaultAlertChangeEventContent(com.thinkbiganalytics.alerts.spi.DefaultAlertChangeEventContent) QueryDslFetchJoin(com.thinkbiganalytics.metadata.jpa.support.QueryDslFetchJoin) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) AlertProvider(com.thinkbiganalytics.alerts.api.AlertProvider) RoleSetExposingSecurityExpressionRoot(com.thinkbiganalytics.metadata.config.RoleSetExposingSecurityExpressionRoot) NifiRelatedRootFlowFilesRepository(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.NifiRelatedRootFlowFilesRepository) Alert(com.thinkbiganalytics.alerts.api.Alert) CheckDataStepConstants(com.thinkbiganalytics.jobrepo.common.constants.CheckDataStepConstants) Service(org.springframework.stereotype.Service) QueryDslPagingSupport(com.thinkbiganalytics.metadata.jpa.support.QueryDslPagingSupport) Named(javax.inject.Named) ProvenanceEventRecordDTO(com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTO) FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) Logger(org.slf4j.Logger) BatchJobInstance(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobInstance) FeedNameUtil(com.thinkbiganalytics.support.FeedNameUtil) OptimisticLockException(javax.persistence.OptimisticLockException) ConstructorExpression(com.querydsl.core.types.ConstructorExpression) DateTime(org.joda.time.DateTime) NifiFeedStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory) OperationalAlerts(com.thinkbiganalytics.metadata.api.alerts.OperationalAlerts) QJpaNifiFeedStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.QJpaNifiFeedStats) TimeUnit(java.util.concurrent.TimeUnit) JobStatusDslQueryExpressionBuilder(com.thinkbiganalytics.metadata.jpa.support.JobStatusDslQueryExpressionBuilder) QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) FeedConstants(com.thinkbiganalytics.jobrepo.common.constants.FeedConstants) Collections(java.util.Collections) OpsManagerFeedRepository(com.thinkbiganalytics.metadata.jpa.feed.OpsManagerFeedRepository) QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) BatchAndStreamingJobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchAndStreamingJobStatusCount) BooleanBuilder(com.querydsl.core.BooleanBuilder) List(java.util.List) ArrayList(java.util.ArrayList) QJpaNifiFeedStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.QJpaNifiFeedStats)

Example 10 with QJpaOpsManagerFeed

use of com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed in project kylo by Teradata.

the class JpaBatchJobExecutionProvider method findAll.

/**
 * Find all BatchJobExecution objects with the provided filter. the filter needs to match
 *
 * @return a paged result set of all the job executions matching the incoming filter
 */
@Override
public Page<? extends BatchJobExecution> findAll(String filter, Pageable pageable) {
    QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
    // if the filter contains a filter on the feed then delegate to the findAllForFeed method to include any check data jobs
    List<SearchCriteria> searchCriterias = GenericQueryDslFilter.parseFilterString(filter);
    SearchCriteria feedFilter = searchCriterias.stream().map(searchCriteria -> searchCriteria.withKey(CommonFilterTranslations.resolvedFilter(jobExecution, searchCriteria.getKey()))).filter(sc -> sc.getKey().equalsIgnoreCase(CommonFilterTranslations.jobExecutionFeedNameFilterKey)).findFirst().orElse(null);
    if (feedFilter != null && feedFilter.getPreviousSearchCriteria() != null && !feedFilter.isValueCollection()) {
        // remove the feed filter from the list and filter by this feed
        searchCriterias.remove(feedFilter.getPreviousSearchCriteria());
        String feedValue = feedFilter.getValue().toString();
        // remove any quotes around the feedValue
        feedValue = feedValue.replaceAll("^\"|\"$", "");
        return findAllForFeed(feedValue, searchCriterias, pageable);
    } else {
        pageable = CommonFilterTranslations.resolveSortFilters(jobExecution, pageable);
        QJpaBatchJobInstance jobInstancePath = new QJpaBatchJobInstance("jobInstance");
        QJpaOpsManagerFeed feedPath = new QJpaOpsManagerFeed("feed");
        return findAllWithFetch(jobExecution, GenericQueryDslFilter.buildFilter(jobExecution, filter).and(augment(feedPath.id)), pageable, QueryDslFetchJoin.innerJoin(jobExecution.nifiEventJobExecution), QueryDslFetchJoin.innerJoin(jobExecution.jobInstance, jobInstancePath), QueryDslFetchJoin.innerJoin(jobInstancePath.feed, feedPath));
    }
}
Also used : AlertManager(com.thinkbiganalytics.alerts.spi.AlertManager) JobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.JobStatusCount) BatchRelatedFlowFile(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchRelatedFlowFile) ClusterServiceMessageReceiver(com.thinkbiganalytics.cluster.ClusterServiceMessageReceiver) JpaNifiEventJobExecution(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.JpaNifiEventJobExecution) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Projections(com.querydsl.core.types.Projections) FeedAclIndexQueryAugmentor(com.thinkbiganalytics.metadata.jpa.feed.FeedAclIndexQueryAugmentor) StringUtils(org.apache.commons.lang3.StringUtils) GenericQueryDslFilter(com.thinkbiganalytics.metadata.jpa.support.GenericQueryDslFilter) SecurityRole(com.thinkbiganalytics.security.role.SecurityRole) BatchAndStreamingJobStatusCount(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchAndStreamingJobStatusCount) Map(java.util.Map) AccessController(com.thinkbiganalytics.security.AccessController) OpsManagerFeed(com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed) Pageable(org.springframework.data.domain.Pageable) BigInteger(java.math.BigInteger) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) NifiFeedStatisticsProvider(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStatisticsProvider) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ClusterMessage(com.thinkbiganalytics.cluster.ClusterMessage) Page(org.springframework.data.domain.Page) Expression(com.querydsl.core.types.Expression) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) Collectors(java.util.stream.Collectors) JPAExpressions(com.querydsl.jpa.JPAExpressions) JpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.JpaOpsManagerFeed) JPAQuery(com.querydsl.jpa.impl.JPAQuery) BatchJobExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecutionProvider) ReadablePeriod(org.joda.time.ReadablePeriod) List(java.util.List) ExecutionConstants(com.thinkbiganalytics.metadata.api.jobrepo.ExecutionConstants) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) PostConstruct(javax.annotation.PostConstruct) ClusterService(com.thinkbiganalytics.cluster.ClusterService) BatchJobExecution(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobExecution) CommonFilterTranslations(com.thinkbiganalytics.metadata.jpa.support.CommonFilterTranslations) Predicate(com.querydsl.core.types.Predicate) SearchCriteria(com.thinkbiganalytics.metadata.api.SearchCriteria) Authentication(org.springframework.security.core.Authentication) UnsupportedEncodingException(java.io.UnsupportedEncodingException) FeedOperationBatchStatusChange(com.thinkbiganalytics.metadata.api.event.feed.FeedOperationBatchStatusChange) BatchStepExecutionProvider(com.thinkbiganalytics.metadata.api.jobrepo.step.BatchStepExecutionProvider) Stopwatch(com.google.common.base.Stopwatch) MessageDigest(java.security.MessageDigest) DateTimeUtil(com.thinkbiganalytics.DateTimeUtil) BooleanBuilder(com.querydsl.core.BooleanBuilder) QOpsManagerFeedId(com.thinkbiganalytics.metadata.jpa.feed.QOpsManagerFeedId) BooleanUtils(org.apache.commons.lang3.BooleanUtils) HashMap(java.util.HashMap) JPQLQuery(com.querydsl.jpa.JPQLQuery) DefaultAlertChangeEventContent(com.thinkbiganalytics.alerts.spi.DefaultAlertChangeEventContent) QueryDslFetchJoin(com.thinkbiganalytics.metadata.jpa.support.QueryDslFetchJoin) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) AlertProvider(com.thinkbiganalytics.alerts.api.AlertProvider) RoleSetExposingSecurityExpressionRoot(com.thinkbiganalytics.metadata.config.RoleSetExposingSecurityExpressionRoot) NifiRelatedRootFlowFilesRepository(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.NifiRelatedRootFlowFilesRepository) Alert(com.thinkbiganalytics.alerts.api.Alert) CheckDataStepConstants(com.thinkbiganalytics.jobrepo.common.constants.CheckDataStepConstants) Service(org.springframework.stereotype.Service) QueryDslPagingSupport(com.thinkbiganalytics.metadata.jpa.support.QueryDslPagingSupport) Named(javax.inject.Named) ProvenanceEventRecordDTO(com.thinkbiganalytics.nifi.provenance.model.ProvenanceEventRecordDTO) FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) Logger(org.slf4j.Logger) BatchJobInstance(com.thinkbiganalytics.metadata.api.jobrepo.job.BatchJobInstance) FeedNameUtil(com.thinkbiganalytics.support.FeedNameUtil) OptimisticLockException(javax.persistence.OptimisticLockException) ConstructorExpression(com.querydsl.core.types.ConstructorExpression) DateTime(org.joda.time.DateTime) NifiFeedStats(com.thinkbiganalytics.metadata.api.jobrepo.nifi.NifiFeedStats) JPAQueryFactory(com.querydsl.jpa.impl.JPAQueryFactory) OperationalAlerts(com.thinkbiganalytics.metadata.api.alerts.OperationalAlerts) QJpaNifiFeedStats(com.thinkbiganalytics.metadata.jpa.jobrepo.nifi.QJpaNifiFeedStats) TimeUnit(java.util.concurrent.TimeUnit) JobStatusDslQueryExpressionBuilder(com.thinkbiganalytics.metadata.jpa.support.JobStatusDslQueryExpressionBuilder) QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) FeedConstants(com.thinkbiganalytics.jobrepo.common.constants.FeedConstants) Collections(java.util.Collections) OpsManagerFeedRepository(com.thinkbiganalytics.metadata.jpa.feed.OpsManagerFeedRepository) QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) SearchCriteria(com.thinkbiganalytics.metadata.api.SearchCriteria)

Aggregations

QJpaOpsManagerFeed (com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed)12 JPAQuery (com.querydsl.jpa.impl.JPAQuery)10 List (java.util.List)8 BooleanBuilder (com.querydsl.core.BooleanBuilder)7 Predicate (com.querydsl.core.types.Predicate)5 ArrayList (java.util.ArrayList)5 JPQLQuery (com.querydsl.jpa.JPQLQuery)4 Stopwatch (com.google.common.base.Stopwatch)3 ConstructorExpression (com.querydsl.core.types.ConstructorExpression)3 Expression (com.querydsl.core.types.Expression)3 Projections (com.querydsl.core.types.Projections)3 JPAExpressions (com.querydsl.jpa.JPAExpressions)3 JPAQueryFactory (com.querydsl.jpa.impl.JPAQueryFactory)3 DateTimeUtil (com.thinkbiganalytics.DateTimeUtil)3 Alert (com.thinkbiganalytics.alerts.api.Alert)3 AlertProvider (com.thinkbiganalytics.alerts.api.AlertProvider)3 AlertManager (com.thinkbiganalytics.alerts.spi.AlertManager)3 DefaultAlertChangeEventContent (com.thinkbiganalytics.alerts.spi.DefaultAlertChangeEventContent)3 ClusterMessage (com.thinkbiganalytics.cluster.ClusterMessage)3 ClusterService (com.thinkbiganalytics.cluster.ClusterService)3