Search in sources :

Example 1 with QJpaOpsManagerFeed

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

the class NifiFeedProcessorStatisticsProvider method findForFeedStatisticsGroupedByTime.

public List<? extends JpaNifiFeedProcessorStats> findForFeedStatisticsGroupedByTime(String feedName, DateTime start, DateTime end) {
    QJpaNifiFeedProcessorStats stats = QJpaNifiFeedProcessorStats.jpaNifiFeedProcessorStats;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    JPAQuery query = factory.select(Projections.bean(JpaNifiFeedProcessorStats.class, stats.feedName, stats.bytesIn.sum().as("bytesIn"), stats.bytesOut.sum().as("bytesOut"), stats.duration.sum().as("duration"), stats.jobsStarted.sum().as("jobsStarted"), stats.jobsFinished.sum().as("jobsFinished"), stats.jobDuration.sum().as("jobDuration"), stats.flowFilesStarted.sum().as("flowFilesStarted"), stats.flowFilesFinished.sum().as("flowFilesFinished"), stats.failedCount.sum().as("failedCount"), stats.minEventTime, stats.jobsStarted.sum().divide(stats.collectionIntervalSeconds).castToNum(BigDecimal.class).as("jobsStartedPerSecond"), stats.jobsFinished.sum().divide(stats.collectionIntervalSeconds).castToNum(BigDecimal.class).as("jobsFinishedPerSecond"), stats.collectionIntervalSeconds.as("collectionIntervalSeconds"), stats.jobsFailed.sum().as("jobsFailed"), stats.totalCount.sum().as("totalCount"), stats.count().as("resultSetCount"))).from(stats).innerJoin(feed).on(feed.name.eq(stats.feedName)).where(stats.feedName.eq(feedName).and(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, accessController.isEntityAccessControlled())).and(stats.minEventTime.goe(start).and(stats.maxEventTime.loe(end)))).groupBy(stats.feedName, stats.minEventTime, stats.collectionIntervalSeconds).orderBy(stats.minEventTime.asc());
    return (List<JpaNifiFeedProcessorStats>) query.fetch();
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) List(java.util.List) JPAQuery(com.querydsl.jpa.impl.JPAQuery) BigDecimal(java.math.BigDecimal)

Example 2 with QJpaOpsManagerFeed

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

the class NifiFeedProcessorStatisticsProvider method findFeedProcessorStatisticsByProcessorName.

@Override
public List<? extends JpaNifiFeedProcessorStats> findFeedProcessorStatisticsByProcessorName(String feedName, DateTime start, DateTime end) {
    QJpaNifiFeedProcessorStats stats = QJpaNifiFeedProcessorStats.jpaNifiFeedProcessorStats;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    JPAQuery query = factory.select(Projections.bean(JpaNifiFeedProcessorStats.class, stats.feedName, stats.processorName, stats.bytesIn.sum().as("bytesIn"), stats.bytesOut.sum().as("bytesOut"), stats.duration.sum().as("duration"), stats.jobsStarted.sum().as("jobsStarted"), stats.jobsFinished.sum().as("jobsFinished"), stats.jobDuration.sum().as("jobDuration"), stats.flowFilesStarted.sum().as("flowFilesStarted"), stats.flowFilesFinished.sum().as("flowFilesFinished"), stats.totalCount.sum().as("totalCount"), stats.maxEventTime.max().as("maxEventTime"), stats.minEventTime.min().as("minEventTime"), stats.jobsFailed.sum().as("jobsFailed"), stats.failedCount.sum().as("failedCount"), stats.count().as("resultSetCount"))).from(stats).innerJoin(feed).on(feed.name.eq(stats.feedName)).where(stats.feedName.eq(feedName).and(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, accessController.isEntityAccessControlled())).and(stats.minEventTime.goe(start).and(stats.maxEventTime.loe(end)))).groupBy(stats.feedName, stats.processorName).orderBy(stats.processorName.asc());
    return (List<JpaNifiFeedProcessorStats>) query.fetch();
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) List(java.util.List) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 3 with QJpaOpsManagerFeed

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

the class JpaServiceLevelAssessmentProvider method findAll.

@Override
public Page<? extends ServiceLevelAssessment> findAll(String filter, Pageable pageable) {
    QJpaServiceLevelAssessment serviceLevelAssessment = QJpaServiceLevelAssessment.jpaServiceLevelAssessment;
    pageable = CommonFilterTranslations.resolveSortFilters(serviceLevelAssessment, pageable);
    QJpaObligationAssessment obligationAssessment = new QJpaObligationAssessment("obligationAssessment");
    QJpaMetricAssessment metricAssessment = new QJpaMetricAssessment("metricAssessment");
    QJpaServiceLevelAgreementDescription serviceLevelAgreementDescription = new QJpaServiceLevelAgreementDescription("slaDescription");
    QJpaOpsManagerFeed feed = new QJpaOpsManagerFeed("feed");
    BooleanBuilder assessmentPredicate = GenericQueryDslFilter.buildFilter(serviceLevelAssessment, filter);
    BooleanBuilder feedPredicate = GenericQueryDslFilter.buildFilter(feed, filter);
    boolean invalidQuery = false;
    // if there is not predicate found for the supplied 'filter' then fail the query
    if (StringUtils.isNotBlank(filter) && (!assessmentPredicate.hasValue() && !feedPredicate.hasValue())) {
        invalidQuery = true;
    }
    BooleanBuilder predicate = assessmentPredicate.and(feedPredicate);
    if (invalidQuery) {
        predicate.and(ExpressionUtils.eq(ConstantImpl.create("1"), ConstantImpl.create("2")));
    }
    predicate.and(feed.isNull().or(feed.isNotNull().and(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, accessController.isEntityAccessControlled()))));
    return findAllWithFetch(serviceLevelAssessment, predicate, true, pageable, QueryDslFetchJoin.innerJoin(serviceLevelAssessment.serviceLevelAgreementDescription, serviceLevelAgreementDescription), QueryDslFetchJoin.leftJoin(serviceLevelAgreementDescription.feeds, feed), QueryDslFetchJoin.leftJoin(serviceLevelAssessment.obligationAssessments, obligationAssessment), QueryDslFetchJoin.leftJoin(obligationAssessment.metricAssessments, metricAssessment));
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) BooleanBuilder(com.querydsl.core.BooleanBuilder)

Example 4 with QJpaOpsManagerFeed

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

the class JpaBatchJobExecutionProvider method getJobStatusCountByDateFromNow.

/**
 * gets job executions grouped by status and Day looking back from Now - the supplied {@code period}
 *
 * @param period period to look back from the current time to get job execution status
 */
@Override
public List<JobStatusCount> getJobStatusCountByDateFromNow(ReadablePeriod period, String filter) {
    QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
    QJpaBatchJobInstance jobInstance = QJpaBatchJobInstance.jpaBatchJobInstance;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    BooleanBuilder whereBuilder = new BooleanBuilder();
    whereBuilder.and(jobExecution.startTime.goe(DateTimeUtil.getNowUTCTime().minus(period)));
    if (StringUtils.isNotBlank(filter)) {
        whereBuilder.and(GenericQueryDslFilter.buildFilter(jobExecution, filter));
    }
    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(whereBuilder.and(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) BooleanBuilder(com.querydsl.core.BooleanBuilder) List(java.util.List) ArrayList(java.util.ArrayList) JPAQuery(com.querydsl.jpa.impl.JPAQuery)

Example 5 with QJpaOpsManagerFeed

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

the class KyloEntityAwareAlertCriteria method createQuery.

public JPAQuery<JpaAlert> createQuery() {
    QJpaAlert alert = QJpaAlert.jpaAlert;
    QJpaOpsManagerFeed feed = QJpaOpsManagerFeed.jpaOpsManagerFeed;
    QJpaOpsManagerFeed slaFeed = new QJpaOpsManagerFeed("slaFeed");
    QJpaServiceLevelAgreementDescription sla = QJpaServiceLevelAgreementDescription.jpaServiceLevelAgreementDescription;
    JPAQuery<JpaAlert> query = queryFactory.select(alert).distinct().from(alert).leftJoin(feed).on(feed.id.uuid.eq(alert.entityId.value).and(alert.entityType.eq(Expressions.stringPath("'FEED'")))).leftJoin(sla).on(sla.slaId.uuid.eq(alert.entityId.value).and(alert.entityType.eq(Expressions.stringPath("'SLA'")))).leftJoin(sla.feeds, slaFeed).limit(getLimit());
    List<Predicate> preds = filter(alert);
    boolean entityAccessControlled = !isAsServiceAccount() && controller.isEntityAccessControlled();
    preds.add(feed.isNull().or(feed.isNotNull().and(FeedAclIndexQueryAugmentor.generateExistsExpression(feed.id, entityAccessControlled))));
    preds.add(slaFeed.isNull().or(slaFeed.isNotNull().and(FeedAclIndexQueryAugmentor.generateExistsExpression(slaFeed.id, entityAccessControlled))));
    BooleanBuilder orFilter = orFilter(alert, feed, sla);
    addEntityFilter(alert, preds);
    // In all other cases sort descending. The results will be ordered correctly when aggregated by the provider.
    if (getLimit() != Integer.MAX_VALUE && getAfterTime() != null && getBeforeTime() == null) {
        query.orderBy(alert.createdTime.asc());
    } else {
        query.orderBy(alert.createdTime.desc());
    }
    return super.addWhere(query, preds, orFilter);
}
Also used : QJpaOpsManagerFeed(com.thinkbiganalytics.metadata.jpa.feed.QJpaOpsManagerFeed) QJpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert) BooleanBuilder(com.querydsl.core.BooleanBuilder) QJpaServiceLevelAgreementDescription(com.thinkbiganalytics.metadata.jpa.sla.QJpaServiceLevelAgreementDescription) JpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.JpaAlert) QJpaAlert(com.thinkbiganalytics.metadata.jpa.alerts.QJpaAlert) Predicate(com.querydsl.core.types.Predicate)

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