コード例 #1
0
ファイル: ApplicationService.java プロジェクト: masonmei/apm
  /**
   * @param timeRange
   * @param apps
   * @param period in Second
   * @return
   */
  public Iterable<ApplicationStatistic> selectApplicationStatistics(
      TimeRange timeRange, Iterable<Application> apps, Long period) {
    final long periodInMillis = period * 1000;
    List<Long> appIds =
        StreamSupport.stream(apps.spliterator(), false)
            .map(Application::getId)
            .collect(Collectors.toList());

    QApplicationStatistic appStatistic = QApplicationStatistic.applicationStatistic;
    BooleanExpression timestampCondition =
        appStatistic.timestamp.between(
            toMillisSecond(timeRange.getFrom()), toMillisSecond(timeRange.getTo()));
    BooleanExpression appIdCondition = appStatistic.appId.in(appIds);
    BooleanExpression periodCondition = appStatistic.period.eq(periodInMillis);

    BooleanExpression whereCondition = timestampCondition.and(appIdCondition).and(periodCondition);

    return applicationStatisticRepository.findAll(whereCondition);
  }
コード例 #2
0
ファイル: ApplicationService.java プロジェクト: masonmei/apm
  /**
   * @param timeRange
   * @param instances
   * @param period in Second
   * @return
   */
  public Iterable<InstanceStatistic> selectInstanceStatistics(
      TimeRange timeRange, List<Instance> instances, Long period) {
    final long periodInMillis = period * 1000;

    List<Long> instanceIds =
        StreamSupport.stream(instances.spliterator(), false)
            .map(Instance::getId)
            .collect(Collectors.toList());

    QInstanceStatistic instanceStatistic = QInstanceStatistic.instanceStatistic;
    BooleanExpression timestampCondition =
        instanceStatistic.timestamp.between(
            toMillisSecond(timeRange.getFrom()), toMillisSecond(timeRange.getTo()));
    BooleanExpression instanceIdCondition = instanceStatistic.instanceId.in(instanceIds);
    BooleanExpression periodCondition = instanceStatistic.period.eq(periodInMillis);
    BooleanExpression whereCondition =
        instanceIdCondition.and(timestampCondition).and(periodCondition);

    return instanceStatisticRepository.findAll(whereCondition);
  }