Java Code Examples for org.apache.commons.collections4.MapUtils#getIntValue()

The following examples show how to use org.apache.commons.collections4.MapUtils#getIntValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaselineAlgorithm.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
public BaselineAlgorithm(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime) {
  super(provider, config, startTime, endTime);

  Preconditions.checkArgument(config.getProperties().containsKey(PROP_METRIC_URN));

  String metricUrn = MapUtils.getString(config.getProperties(), PROP_METRIC_URN);
  MetricEntity me = MetricEntity.fromURN(metricUrn);
  this.slice = MetricSlice.from(me.getId(), this.startTime, this.endTime, me.getFilters());

  int weeks = MapUtils.getIntValue(config.getProperties(), PROP_WEEKS, PROP_WEEKS_DEFAULT);
  BaselineAggregateType aggregation = BaselineAggregateType.valueOf(MapUtils.getString(config.getProperties(), PROP_AGGREGATION, PROP_AGGREGATION_DEFAULT));
  DateTimeZone timezone = DateTimeZone.forID(MapUtils.getString(this.config.getProperties(), PROP_TIMEZONE, PROP_TIMEZONE_DEFAULT));
  this.baseline = BaselineAggregate.fromWeekOverWeek(aggregation, weeks, 1, timezone);

  this.change = MapUtils.getDoubleValue(config.getProperties(), PROP_CHANGE, PROP_CHANGE_DEFAULT);
  this.difference = MapUtils.getDoubleValue(config.getProperties(), PROP_DIFFERENCE, PROP_DIFFERENCE_DEFAULT);
}
 
Example 2
Source File: CallGraphPipeline.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
public CallGraphPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) {
  super(outputName, inputNames);
  this.metricDAO = DAORegistry.getInstance().getMetricConfigDAO();
  this.datasetDAO = DAORegistry.getInstance().getDatasetConfigDAO();
  this.cache = ThirdEyeCacheRegistry.getInstance().getQueryCache();
  this.dataset = MapUtils.getString(properties, PROP_DATASET, PROP_DATASET_DEFAULT);
  this.metricCount = MapUtils.getString(properties, PROP_METRIC_COUNT, PROP_METRIC_COUNT_DEFAULT);
  this.metricLatency = MapUtils.getString(properties, PROP_METRIC_LATENCY, PROP_METRIC_LATENCY_DEFAULT);
  this.k = MapUtils.getIntValue(properties, PROP_K, PROP_K_DEFAULT);
  this.cutoffFraction = MapUtils.getDoubleValue(properties, PROP_CUTOFF_FRACTION, PROP_CUTOFF_FRACTION_DEFAULT);

  if (properties.containsKey(PROP_INCLUDE_DIMENSIONS)) {
    this.includeDimensions = new HashSet<>((Collection<String>) properties.get(PROP_INCLUDE_DIMENSIONS));
  } else {
    this.includeDimensions = new HashSet<>();
  }

  if (properties.containsKey(PROP_EXCLUDE_DIMENSIONS)) {
    this.excludeDimensions = new HashSet<>((Collection<String>) properties.get(PROP_EXCLUDE_DIMENSIONS));
  } else {
    this.excludeDimensions = new HashSet<>();
  }
}
 
Example 3
Source File: DimensionWrapper.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public DimensionWrapper(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime) {
  super(provider, config, startTime, endTime);

  // the metric used in dimension exploration
  this.metricUrn = MapUtils.getString(config.getProperties(), "metricUrn", null);

  this.minContribution = MapUtils.getDoubleValue(config.getProperties(), "minContribution", Double.NaN);
  this.minValue = MapUtils.getDoubleValue(config.getProperties(), "minValue", Double.NaN);
  this.minValueHourly = MapUtils.getDoubleValue(config.getProperties(), "minValueHourly", Double.NaN);
  this.maxValueHourly = MapUtils.getDoubleValue(config.getProperties(), "maxValueHourly", Double.NaN);
  this.minValueDaily = MapUtils.getDoubleValue(config.getProperties(), "minValueDaily", Double.NaN);
  this.maxValueDaily = MapUtils.getDoubleValue(config.getProperties(), "maxValueDaily", Double.NaN);
  this.k = MapUtils.getIntValue(config.getProperties(), "k", -1);
  this.dimensions = ConfigUtils.getList(config.getProperties().get("dimensions"));
  this.lookback = ConfigUtils.parsePeriod(MapUtils.getString(config.getProperties(), "lookback", "1w"));
  this.timezone = DateTimeZone.forID(MapUtils.getString(config.getProperties(), "timezone", "America/Los_Angeles"));

  /*
   * A bucket of the time series is taken into consider only if its value is above the minLiveZone. In other words,
   * if a bucket's value is smaller than minLiveZone, then this bucket is ignored when calculating the average value.
   * Used for outlier removal. Replace legacy average threshold filter.
   */
  this.minLiveZone = MapUtils.getDoubleValue(config.getProperties(), "minLiveZone", Double.NaN);
  this.liveBucketPercentageThreshold = MapUtils.getDoubleValue(config.getProperties(), "liveBucketPercentageThreshold", 0.5);

  // the metric to run the detection for
  this.nestedMetricUrns = ConfigUtils.getList(config.getProperties().get(PROP_NESTED_METRIC_URNS), Collections.singletonList(this.metricUrn));
  this.nestedMetricUrnKey = MapUtils.getString(config.getProperties(), PROP_NESTED_METRIC_URN_KEY, PROP_NESTED_METRIC_URN_KEY_DEFAULT);
  this.nestedProperties = ConfigUtils.getList(config.getProperties().get(PROP_NESTED));

  this.start = new DateTime(this.startTime, this.timezone);
  this.end = new DateTime(this.endTime, this.timezone);

  DateTime minStart = this.end.minus(this.lookback);
  if (minStart.isBefore(this.start)) {
    this.start = minStart;
  }

  this.evaluationMetricUrns = new HashSet<>();
}
 
Example 4
Source File: BaselineRuleFilterWrapper.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public BaselineRuleFilterWrapper(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime) {
  super(provider, config, startTime, endTime);
  int weeks = MapUtils.getIntValue(config.getProperties(), PROP_WEEKS, PROP_WEEKS_DEFAULT);
  DateTimeZone timezone =
      DateTimeZone.forID(MapUtils.getString(this.config.getProperties(), PROP_TIMEZONE, PROP_TIMEZONE_DEFAULT));
  this.baseline = BaselineAggregate.fromWeekOverWeek(BaselineAggregateType.MEDIAN, weeks, 1, timezone);
  // percentage change
  this.change = MapUtils.getDoubleValue(config.getProperties(), PROP_CHANGE, PROP_CHANGE_DEFAULT);
  // absolute change
  this.difference = MapUtils.getDoubleValue(config.getProperties(), PROP_DIFFERENCE, PROP_DIFFERENCE_DEFAULT);
  // site wide impact
  this.siteWideImpactThreshold = MapUtils.getDoubleValue(config.getProperties(), PROP_SITEWIDE_THRESHOLD, PROP_SITEWIDE_THRESHOLD_DEFAULT);
  this.siteWideMetricUrn = MapUtils.getString(config.getProperties(), PROP_SITEWIDE_METRIC);
}
 
Example 5
Source File: MovingWindowAlgorithm.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public MovingWindowAlgorithm(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime) {
  super(provider, config, startTime, endTime);

  Preconditions.checkArgument(config.getProperties().containsKey(PROP_METRIC_URN));

  String metricUrn = MapUtils.getString(config.getProperties(), PROP_METRIC_URN);
  MetricEntity me = MetricEntity.fromURN(metricUrn);

  this.quantileMin = MapUtils.getDoubleValue(config.getProperties(), "quantileMin", Double.NaN);
  this.quantileMax = MapUtils.getDoubleValue(config.getProperties(), "quantileMax", Double.NaN);
  this.zscoreMin = MapUtils.getDoubleValue(config.getProperties(), "zscoreMin", Double.NaN);
  this.zscoreMax = MapUtils.getDoubleValue(config.getProperties(), "zscoreMax", Double.NaN);
  this.zscoreOutlier = MapUtils.getDoubleValue(config.getProperties(), "zscoreOutlier", Double.NaN);
  this.kernelSize = MapUtils.getIntValue(config.getProperties(), "kernelSize", 1);
  this.timezone = DateTimeZone.forID(MapUtils.getString(config.getProperties(), "timezone", "UTC"));
  this.windowSize = ConfigUtils.parsePeriod(MapUtils.getString(config.getProperties(), "windowSize", "1week"));
  this.lookbackPeriod = ConfigUtils.parsePeriod(MapUtils.getString(config.getProperties(), "lookbackPeriod", "1week"));
  this.reworkPeriod = ConfigUtils.parsePeriod(MapUtils.getString(config.getProperties(), "reworkPeriod", "1day"));
  this.changeDuration = ConfigUtils.parsePeriod(MapUtils.getString(config.getProperties(), "changeDuration", "5days"));
  this.changeFraction = MapUtils.getDoubleValue(config.getProperties(), "changeFraction", 0.666);
  this.baselineWeeks = MapUtils.getIntValue(config.getProperties(), "baselineWeeks", 0);
  this.applyLog = MapUtils.getBooleanValue(config.getProperties(), "applyLog", true);
  this.learningRate = MapUtils.getDoubleValue(config.getProperties(), "learningRate", 0.666);

  Preconditions.checkArgument(Double.isNaN(this.quantileMin) || (this.quantileMin >= 0 && this.quantileMin <= 1.0), "quantileMin must be between 0.0 and 1.0");
  Preconditions.checkArgument(Double.isNaN(this.quantileMax) || (this.quantileMax >= 0 && this.quantileMax <= 1.0), "quantileMax must be between 0.0 and 1.0");

  this.effectiveStartTime = new DateTime(startTime, this.timezone).minus(this.lookbackPeriod).getMillis();

  DateTime trainStart = new DateTime(this.effectiveStartTime, this.timezone).minus(this.windowSize);
  DateTime dataStart = trainStart.minus(new Period().withField(DurationFieldType.weeks(), baselineWeeks));
  DateTime detectionStart = new DateTime(startTime, this.timezone).minus(this.reworkPeriod);

  this.sliceData = MetricSlice.from(me.getId(), dataStart.getMillis(), endTime, me.getFilters());
  this.sliceDetection = MetricSlice.from(me.getId(), detectionStart.getMillis(), endTime, me.getFilters());

  AnomalySlice slice = new AnomalySlice().withStart(this.sliceData.getStart()).withEnd(this.sliceData.getEnd());
  if (this.config.getId() != null) {
    this.anomalySlice = slice.withDetectionId(this.config.getId());
  } else {
    this.anomalySlice = slice;
  }
}
 
Example 6
Source File: AnomalyDetectorWrapper.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public AnomalyDetectorWrapper(DataProvider provider, DetectionConfigDTO config, long startTime, long endTime) {
  super(provider, config, startTime, endTime);

  Preconditions.checkArgument(this.config.getProperties().containsKey(PROP_SUB_ENTITY_NAME));
  this.entityName = MapUtils.getString(config.getProperties(), PROP_SUB_ENTITY_NAME);

  this.metricUrn = MapUtils.getString(config.getProperties(), PROP_METRIC_URN);
  this.metricEntity = MetricEntity.fromURN(this.metricUrn);
  this.metric = provider.fetchMetrics(Collections.singleton(this.metricEntity.getId())).get(this.metricEntity.getId());

  Preconditions.checkArgument(this.config.getProperties().containsKey(PROP_DETECTOR));
  this.detectorName = DetectionUtils.getComponentKey(MapUtils.getString(config.getProperties(), PROP_DETECTOR));
  Preconditions.checkArgument(this.config.getComponents().containsKey(this.detectorName));
  this.anomalyDetector = (AnomalyDetector) this.config.getComponents().get(this.detectorName);

  // emulate moving window or now
  this.isMovingWindowDetection = MapUtils.getBooleanValue(config.getProperties(), PROP_MOVING_WINDOW_DETECTION, false);
  // delays to wait for data becomes available
  this.windowDelay = MapUtils.getIntValue(config.getProperties(), PROP_WINDOW_DELAY, 0);
  // window delay unit
  this.windowDelayUnit = TimeUnit.valueOf(MapUtils.getString(config.getProperties(), PROP_WINDOW_DELAY_UNIT, "DAYS"));
  // detection window size
  this.windowSize = MapUtils.getIntValue(config.getProperties(), PROP_WINDOW_SIZE, 1);
  // detection window unit
  this.windowUnit = TimeUnit.valueOf(MapUtils.getString(config.getProperties(), PROP_WINDOW_UNIT, "DAYS"));
  // run frequency, used to determine moving windows for minute-level detection
  Map<String, Object> frequency = (Map<String, Object>) MapUtils.getMap(config.getProperties(), PROP_FREQUENCY);
  this.functionFrequency = new TimeGranularity(MapUtils.getIntValue(frequency, "size", 15), TimeUnit.valueOf(MapUtils.getString(frequency, "unit", "MINUTES")));

  MetricConfigDTO metricConfigDTO = this.provider.fetchMetrics(Collections.singletonList(this.metricEntity.getId())).get(this.metricEntity.getId());
  this.dataset = this.provider.fetchDatasets(Collections.singletonList(metricConfigDTO.getDataset()))
      .get(metricConfigDTO.getDataset());
  // date time zone for moving windows. use dataset time zone as default
  this.dateTimeZone = DateTimeZone.forID(MapUtils.getString(config.getProperties(), PROP_TIMEZONE, this.dataset.getTimezone()));

  String bucketStr = MapUtils.getString(config.getProperties(), PROP_BUCKET_PERIOD);
  this.bucketPeriod = bucketStr == null ? this.getBucketSizePeriodForDataset() : Period.parse(bucketStr);
  this.cachingPeriodLookback = config.getProperties().containsKey(PROP_CACHE_PERIOD_LOOKBACK) ?
      MapUtils.getLong(config.getProperties(), PROP_CACHE_PERIOD_LOOKBACK) : ThirdEyeUtils.getCachingPeriodLookback(this.dataset.bucketTimeGranularity());

  speedUpMinuteLevelDetection();
}
 
Example 7
Source File: MaxAggregationPipeline.java    From incubator-pinot with Apache License 2.0 2 votes vote down vote up
/**
 * Alternate constructor for use by RCAFrameworkLoader
 *
 * @param outputName pipeline output name
 * @param inputNames input pipeline names
 * @param properties configuration properties ({@code PROP_K})
 */
public MaxAggregationPipeline(String outputName, Set<String> inputNames, Map<String, Object> properties) {
  super(outputName, inputNames);
  this.k = MapUtils.getIntValue(properties, PROP_K, PROP_K_DEFAULT);
}