This is an automated email from the ASF dual-hosted git repository.

apucher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 29ac151  [TE] Mock event generator for demo purposes (#5354)
29ac151 is described below

commit 29ac1519588222ab6b31479df19c6c59f3d96402
Author: Alexander Pucher <[email protected]>
AuthorDate: Mon May 11 22:09:48 2020 -0700

    [TE] Mock event generator for demo purposes (#5354)
    
    * Mock event generator for demo purposes
    - pseudo-random distribution-based generator similar to mock data source
    - configuration via detector.yml
    - one-time execution at statup in backend with db-persistence and 
deduplication
    - mock event names (for kishore)
---
 thirdeye/thirdeye-pinot/config/detector.yml        |  42 +++++
 thirdeye/thirdeye-pinot/config/rca.yml             |  26 ++-
 .../anomaly/MockEventsLoaderConfiguration.java     | 134 ++++++++++++++
 .../anomaly/ThirdEyeAnomalyApplication.java        |   6 +
 .../anomaly/ThirdEyeAnomalyConfiguration.java      |  18 ++
 .../thirdeye/anomaly/events/MockEventsLoader.java  | 200 +++++++++++++++++++++
 .../thirdeye/datalayer/entity/EventIndex.java      |   8 +-
 .../datasource/mock/MockThirdEyeDataSource.java    |   4 +-
 .../rootcause/impl/ThirdEyeEventEntity.java        |   2 +-
 .../rootcause/impl/ThirdEyeEventsPipeline.java     |  21 +--
 10 files changed, 434 insertions(+), 27 deletions(-)

diff --git a/thirdeye/thirdeye-pinot/config/detector.yml 
b/thirdeye/thirdeye-pinot/config/detector.yml
index 43cfe5a..b5c1951 100644
--- a/thirdeye/thirdeye-pinot/config/detector.yml
+++ b/thirdeye/thirdeye-pinot/config/detector.yml
@@ -17,6 +17,7 @@ alert: false
 autoload: false
 classifier: false
 holidayEventsLoader: false
+mockEventsLoader: true
 monitor: false
 pinotProxy: false
 scheduler: false
@@ -82,3 +83,44 @@ holidayEventsLoaderConfiguration:
        - "en.vietnamese#[email protected]"
   holidayLoadRange: 2592000000
   runFrequency: 7
+mockEventsLoaderConfiguration:
+  generators:
+    - type: HOLIDAY
+      arrivalType: exponential
+      arrivalMean: 86400000
+      durationType: fixed
+      durationMean: 86400000
+      seed: 0
+      namePrefixes: [First, Second, Third, Last, Funky, Happy, Sad, Glorious, 
Jolly, Unity, Pinot's]
+      nameSuffixes: [day, day, days, celebration, rememberance, occurrence, 
moment]
+    - type: INFORMED
+      arrivalType: exponential
+      arrivalMean: 43200000
+      durationType: exponential
+      durationMean: 3600000
+      seed: 1
+      namePrefixes: [Login, Web, Search, Catalog, Integration, Network, 
Backup, Ingress, Proxy, Failure, Pinot, ThirdEye]
+      nameSuffixes: [backend, frontend, v1.1, v1.2, v1.3, v2.0, v3, v4, v5, 
storage, topic, container, database]
+    - type: CM
+      arrivalType: exponential
+      arrivalMean: 21600000
+      durationType: fixed
+      durationMean: 1800000
+      seed: 2
+      namePrefixes: [Database, Web, Search, Catalog, Integration, Network, 
Backup, Ingress, Proxy, Failure, Pinot, ThirdEye]
+    - type: CUSTOM
+      arrivalType: exponential
+      arrivalMean: 432000000
+      durationType: exponential
+      durationMean: 86400000
+      seed: 3
+      namePrefixes: [Marketing, Onboarding, Vaction, Outreach, InDay]
+      nameSuffixes: [integration, campaign, meeting]
+    - type: LIX
+      arrivalType: exponential
+      arrivalMean: 259200000
+      durationType: exponential
+      durationMean: 604800000
+      seed: 4
+      namePrefixes: [System, Model, Campaign, Welcome, Pinot, ThirdEye]
+      nameSuffixes: [tuning, bugfix, rollout, test]
diff --git a/thirdeye/thirdeye-pinot/config/rca.yml 
b/thirdeye/thirdeye-pinot/config/rca.yml
index 0c3cb2d..aecfd76 100644
--- a/thirdeye/thirdeye-pinot/config/rca.yml
+++ b/thirdeye/thirdeye-pinot/config/rca.yml
@@ -31,7 +31,11 @@ frameworks:
     eventExperiment:
         - outputName: OUTPUT
           inputNames: [INPUT]
-          className: org.apache.pinot.thirdeye.rootcause.impl.EmptyPipeline
+          className: 
org.apache.pinot.thirdeye.rootcause.impl.ThirdEyeEventsPipeline
+          properties:
+            strategy: COMPOUND
+            k: 500
+            eventType: LIX
 
     eventHoliday:
         - outputName: METRIC_RELATED
@@ -44,7 +48,7 @@ frameworks:
           properties:
               strategy: COMPOUND
               k: 500
-              eventType: holiday
+              eventType: HOLIDAY
 
     eventCustom:
         - outputName: OUTPUT
@@ -53,7 +57,7 @@ frameworks:
           properties:
               strategy: COMPOUND
               k: 500
-              eventType: custom
+              eventType: CUSTOM
 
     eventAnomaly:
         - outputName: OUTPUT
@@ -73,10 +77,22 @@ frameworks:
     eventChange:
         - outputName: OUTPUT
           inputNames: [INPUT]
-          className: org.apache.pinot.thirdeye.rootcause.impl.EmptyPipeline
+          className: 
org.apache.pinot.thirdeye.rootcause.impl.ThirdEyeEventsPipeline
+          properties:
+            strategy: COMPOUND
+            k: 500
+            eventType: CM
 
     eventDeployment:
         - outputName: OUTPUT
           inputNames: [INPUT]
-          className: org.apache.pinot.thirdeye.rootcause.impl.EmptyPipeline
+          className: 
org.apache.pinot.thirdeye.rootcause.impl.ThirdEyeEventsPipeline
+          properties:
+            strategy: COMPOUND
+            k: 500
+            eventType: INFORMED
 
+    eventAC:
+      - outputName: OUTPUT
+        inputNames: [INPUT]
+        className: org.apache.pinot.thirdeye.rootcause.impl.EmptyPipeline
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/MockEventsLoaderConfiguration.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/MockEventsLoaderConfiguration.java
new file mode 100644
index 0000000..6df4251
--- /dev/null
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/MockEventsLoaderConfiguration.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.pinot.thirdeye.anomaly;
+
+
+import org.apache.pinot.thirdeye.anomaly.events.MockEventsLoader;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Configuration container for generating series of mock events
+ *
+ * @see MockEventsLoader
+ */
+public class MockEventsLoaderConfiguration {
+    public static class EventGeneratorConfig {
+
+        /** EventDTO event type */
+        String type;
+
+        /** Distribution type of arrival times distribution */
+        String arrivalType = MockEventsLoader.DIST_TYPE_EXPONENTIAL;
+
+        /** Distribution mean of arrival time distribution */
+        double arrivalMean;
+
+        /** Distribution type of event duration distribution */
+        String durationType = MockEventsLoader.DIST_TYPE_FIXED;
+
+        /** Distribution mean of event duration distribution */
+        double durationMean = 86400000;
+
+        /** Distribution RNG seed for deterministic sampling */
+        int seed = 0;
+
+        /** List of event name prefixes */
+        List<String> namePrefixes = Collections.emptyList();
+
+        /** List of event name suffixes */
+        List<String> nameSuffixes = Collections.emptyList();
+
+        public String getType() {
+            return type;
+        }
+
+        public void setType(String type) {
+            this.type = type;
+        }
+
+        public String getArrivalType() {
+            return arrivalType;
+        }
+
+        public void setArrivalType(String arrivalType) {
+            this.arrivalType = arrivalType;
+        }
+
+        public double getArrivalMean() {
+            return arrivalMean;
+        }
+
+        public void setArrivalMean(double arrivalMean) {
+            this.arrivalMean = arrivalMean;
+        }
+
+        public String getDurationType() {
+            return durationType;
+        }
+
+        public void setDurationType(String durationType) {
+            this.durationType = durationType;
+        }
+
+        public double getDurationMean() {
+            return durationMean;
+        }
+
+        public void setDurationMean(double durationMean) {
+            this.durationMean = durationMean;
+        }
+
+        public int getSeed() {
+            return seed;
+        }
+
+        public void setSeed(int seed) {
+            this.seed = seed;
+        }
+
+        public List<String> getNamePrefixes() {
+            return namePrefixes;
+        }
+
+        public void setNamePrefixes(List<String> namePrefixes) {
+            this.namePrefixes = namePrefixes;
+        }
+
+        public List<String> getNameSuffixes() {
+            return nameSuffixes;
+        }
+
+        public void setNameSuffixes(List<String> nameSuffixes) {
+            this.nameSuffixes = nameSuffixes;
+        }
+    }
+
+    List<EventGeneratorConfig> generators = Collections.emptyList();
+
+    public List<EventGeneratorConfig> getGenerators() {
+        return generators;
+    }
+
+    public void setGenerators(List<EventGeneratorConfig> generators) {
+        this.generators = generators;
+    }
+}
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyApplication.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyApplication.java
index 08126dd..23f979c 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyApplication.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyApplication.java
@@ -28,6 +28,7 @@ import 
org.apache.pinot.thirdeye.anomaly.detection.trigger.DataAvailabilityEvent
 import 
org.apache.pinot.thirdeye.anomaly.detection.trigger.DataAvailabilityTaskScheduler;
 import org.apache.pinot.thirdeye.anomaly.events.HolidayEventResource;
 import org.apache.pinot.thirdeye.anomaly.events.HolidayEventsLoader;
+import org.apache.pinot.thirdeye.anomaly.events.MockEventsLoader;
 import org.apache.pinot.thirdeye.anomaly.monitor.MonitorJobScheduler;
 import org.apache.pinot.thirdeye.anomaly.task.TaskDriver;
 import 
org.apache.pinot.thirdeye.anomalydetection.alertFilterAutotune.AlertFilterAutotuneFactory;
@@ -73,6 +74,7 @@ public class ThirdEyeAnomalyApplication
   private ClassificationJobScheduler classificationJobScheduler = null;
   private EmailResource emailResource = null;
   private HolidayEventsLoader holidayEventsLoader = null;
+  private MockEventsLoader mockEventsLoader = null;
   private RequestStatisticsLogger requestStatisticsLogger = null;
   private DataAvailabilityEventListenerDriver 
dataAvailabilityEventListenerDriver = null;
   private DataAvailabilityTaskScheduler dataAvailabilityTaskScheduler = null;
@@ -170,6 +172,10 @@ public class ThirdEyeAnomalyApplication
           holidayEventsLoader.start();
           environment.jersey().register(new 
HolidayEventResource(holidayEventsLoader));
         }
+        if (config.isMockEventsLoader()) {
+          mockEventsLoader = new 
MockEventsLoader(config.getMockEventsLoaderConfiguration(), 
DAORegistry.getInstance().getEventDAO());
+          mockEventsLoader.run();
+        }
         if (config.isDataCompleteness()) {
           dataCompletenessScheduler = new DataCompletenessScheduler();
           dataCompletenessScheduler.start();
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyConfiguration.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyConfiguration.java
index 8c8ff52..23d3b83 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyConfiguration.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/ThirdEyeAnomalyConfiguration.java
@@ -34,6 +34,7 @@ public class ThirdEyeAnomalyConfiguration extends 
ThirdEyeConfiguration {
   private boolean classifier = false;
   private boolean dataCompleteness = false;
   private boolean holidayEventsLoader = false;
+  private boolean mockEventsLoader = false;
   private boolean monitor = false;
   private boolean pinotProxy = false;
   private boolean scheduler = false;
@@ -46,6 +47,7 @@ public class ThirdEyeAnomalyConfiguration extends 
ThirdEyeConfiguration {
   private long id;
   private String dashboardHost;
   private HolidayEventsLoaderConfiguration holidayEventsLoaderConfiguration = 
new HolidayEventsLoaderConfiguration();
+  private MockEventsLoaderConfiguration mockEventsLoaderConfiguration = new 
MockEventsLoaderConfiguration();
   private MonitorConfiguration monitorConfiguration = new 
MonitorConfiguration();
   private AutoOnboardConfiguration autoOnboardConfiguration = new 
AutoOnboardConfiguration();
   private TaskDriverConfiguration taskDriverConfiguration = new 
TaskDriverConfiguration();
@@ -63,6 +65,22 @@ public class ThirdEyeAnomalyConfiguration extends 
ThirdEyeConfiguration {
     this.holidayEventsLoaderConfiguration = holidayEventsLoaderConfiguration;
   }
 
+  public boolean isMockEventsLoader() {
+    return mockEventsLoader;
+  }
+
+  public void setMockEventsLoader(boolean mockEventsLoader) {
+    this.mockEventsLoader = mockEventsLoader;
+  }
+
+  public MockEventsLoaderConfiguration getMockEventsLoaderConfiguration() {
+    return mockEventsLoaderConfiguration;
+  }
+
+  public void setMockEventsLoaderConfiguration(MockEventsLoaderConfiguration 
mockEventsLoaderConfiguration) {
+    this.mockEventsLoaderConfiguration = mockEventsLoaderConfiguration;
+  }
+
   public boolean isDetectionAlert() {
     return detectionAlert;
   }
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/events/MockEventsLoader.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/events/MockEventsLoader.java
new file mode 100644
index 0000000..0841ddf
--- /dev/null
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/anomaly/events/MockEventsLoader.java
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.pinot.thirdeye.anomaly.events;
+
+import org.apache.commons.math3.distribution.*;
+import org.apache.commons.math3.random.Well19937c;
+import org.apache.pinot.thirdeye.anomaly.MockEventsLoaderConfiguration;
+import org.apache.pinot.thirdeye.datalayer.bao.EventManager;
+import org.apache.pinot.thirdeye.datalayer.dto.EventDTO;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.*;
+
+
+/**
+ * Mock data generator for RCA events similar to mock time series generator. 
Produces series of events with pseudo-randomly
+ * chosen arrival times and durations based on user config with a 
deterministic RNG seed. Events are generated
+ * and persistent into ThirdEye's database after deduplication with 
pre-existing events.
+ *
+ * Events are generated from a fixed point in the past (Jan 1st 2019 12am GMT) 
into the future relative to the generator's
+ * time of execution (now + 365 days).
+ *
+ * @see org.apache.pinot.thirdeye.datasource.mock.MockThirdEyeDataSource
+ */
+public class MockEventsLoader implements Runnable {
+    private static final Logger LOG = 
LoggerFactory.getLogger(MockEventsLoader.class);
+
+    private static Comparator<EventDTO> MOCK_EVENT_COMPARATOR = Comparator
+            .comparingLong(EventDTO::getStartTime)
+            .thenComparingLong(EventDTO::getEndTime)
+            .thenComparing(EventDTO::getEventType);
+
+    private static final long START_TIMESTAMP = 1546300800000L; // January 1, 
2019 12:00:00 AM GMT
+    private static final long END_OFFSET = 31536000000L; // 365d in ms
+
+    public static final String DIST_TYPE_GAUSSIAN = "gaussian";
+    public static final String DIST_TYPE_EXPONENTIAL = "exponential";
+    public static final String DIST_TYPE_LOGNORMAL = "lognormal";
+    public static final String DIST_TYPE_FIXED = "fixed";
+
+    MockEventsLoaderConfiguration configuration;
+    EventManager eventDAO;
+
+    public MockEventsLoader(MockEventsLoaderConfiguration configuration, 
EventManager eventDAO) {
+        this.configuration = configuration;
+        this.eventDAO = eventDAO;
+    }
+
+    @Override
+    public void run() {
+        final long cutoff = System.currentTimeMillis() + END_OFFSET;
+
+        for (MockEventsLoaderConfiguration.EventGeneratorConfig conf : 
this.configuration.getGenerators()) {
+            LOG.info("Generating '{}' events from {} to {}", conf.getType(), 
START_TIMESTAMP, cutoff);
+
+            List<EventDTO> generated = generateEvents(conf, cutoff);
+            List<EventDTO> existing = 
this.eventDAO.findEventsBetweenTimeRange(conf.getType(), START_TIMESTAMP, 
cutoff);
+
+            Set<EventDTO> deduplicated = deduplicate(generated, existing);
+            LOG.info("Generated '{}' events: {} generated, {} pre-existing, {} 
saved after deduplication",
+                    conf.getType(), generated.size(), existing.size(), 
deduplicated.size());
+
+            deduplicated.forEach(this.eventDAO::save);
+        }
+    }
+
+    /**
+     * Generate an event time series based on a given config, up to a cutoff 
timestamp.
+     *
+     * @param conf generator config
+     * @param cutoff cutoff timestamp
+     * @return series of mock events
+     */
+    List<EventDTO> 
generateEvents(MockEventsLoaderConfiguration.EventGeneratorConfig conf, long 
cutoff) {
+        List<EventDTO> generated = new ArrayList<>();
+
+        AbstractRealDistribution arrivalDist = makeDist(conf.getArrivalType(), 
conf.getArrivalMean(), conf.getSeed());
+        AbstractRealDistribution durationDist = 
makeDist(conf.getDurationType(), conf.getDurationMean(), conf.getSeed());
+        Random nameDist = new Random(conf.getSeed());
+
+        EventGenerator generator = new EventGenerator(conf.getType(), 
arrivalDist, durationDist,
+                nameDist, conf.getNamePrefixes(), conf.getNameSuffixes());
+
+        EventDTO event;
+        while ((event = generator.next()).getStartTime() < cutoff) {
+            generated.add(event);
+        }
+
+        return generated;
+    }
+
+    /**
+     * Deduplicates a list of generated events relative to a (larger, 
streamed) set of existing events. Uses a custom
+     * comparator to avoid polluting the <code>equals()</code> implementation 
of EventDTO.
+     *
+     * @param generated generated events
+     * @param existing existing events (as per ThirdEye DB)
+     * @return deduplicated (newly) generated events
+     */
+    Set<EventDTO> deduplicate(Collection<EventDTO> generated, 
Collection<EventDTO> existing) {
+        Set<EventDTO> sorted = new TreeSet<>(MOCK_EVENT_COMPARATOR);
+        sorted.addAll(generated);
+        existing.forEach(sorted::remove);
+        return sorted;
+    }
+
+    /**
+     * Return a pre-configured distribution given a set of configuration 
parameters.
+     *
+     * @param type distribution type
+     * @param param main param (usually mean)
+     * @param seed RNG seed
+     * @return distribution
+     */
+    AbstractRealDistribution makeDist(String type, double param, int seed) {
+        switch (type.toLowerCase()) {
+            case DIST_TYPE_FIXED:
+                return new UniformRealDistribution(param, param + 0.001);
+            case DIST_TYPE_GAUSSIAN:
+                return new NormalDistribution(new Well19937c(seed), param, 
1.0d, 1.0E-9D);
+            case DIST_TYPE_EXPONENTIAL:
+                return new ExponentialDistribution(new Well19937c(seed), 
param, 1.0E-9D);
+            case DIST_TYPE_LOGNORMAL:
+                return new LogNormalDistribution(new Well19937c(seed), param, 
1.0d, 1.0E-9D);
+            default:
+                throw new IllegalArgumentException(String.format("Unsupported 
distribution type '%s'", type));
+        }
+    }
+
+    /**
+     * Iterator-like wrapper to generate an endless series of events given an 
event type, an arrival time
+     * distribution, an event duration distribution, and a random name 
generator.
+     */
+    static class EventGenerator {
+        String type;
+        AbstractRealDistribution arrivalDist;
+        AbstractRealDistribution durationDist;
+        Random nameDist;
+        List<String> namePrefixes;
+        List<String> nameSuffixes;
+
+        int eventCount = 0;
+        long lastTimestamp = START_TIMESTAMP;
+
+        public EventGenerator(String type, AbstractRealDistribution 
arrivalDist, AbstractRealDistribution durationDist,
+                              Random nameDist, List<String> namePrefixes, 
List<String> nameSuffixes) {
+            this.type = type;
+            this.arrivalDist = arrivalDist;
+            this.durationDist = durationDist;
+            this.nameDist = nameDist;
+            this.namePrefixes = namePrefixes;
+            this.nameSuffixes = nameSuffixes;
+        }
+
+        public EventDTO next() {
+            long arrival = lastTimestamp + (long) this.arrivalDist.sample();
+            long duration = (long) this.durationDist.sample();
+
+            this.eventCount++;
+            this.lastTimestamp = arrival;
+
+            String prefix = makeString(this.nameDist, this.namePrefixes, 
this.type);
+            String suffix = makeString(this.nameDist, this.nameSuffixes, 
String.valueOf(this.eventCount));
+
+            EventDTO event = new EventDTO();
+            event.setStartTime(arrival);
+            event.setEndTime(arrival + duration);
+            event.setName(String.format("%s %s", prefix, suffix));
+            event.setEventType(this.type.toUpperCase());
+            event.setTargetDimensionMap(Collections.emptyMap());
+
+            return event;
+        }
+
+        static String makeString(Random rng, List<String> strings, String 
defaultString) {
+            if (strings.isEmpty()) {
+                return defaultString;
+            }
+            return strings.get(rng.nextInt(strings.size()));
+        }
+    }
+}
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/entity/EventIndex.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/entity/EventIndex.java
index 108141e..f3fb663 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/entity/EventIndex.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/entity/EventIndex.java
@@ -19,11 +19,9 @@
 
 package org.apache.pinot.thirdeye.datalayer.entity;
 
-import org.apache.pinot.thirdeye.anomaly.events.EventType;
-
 public class EventIndex extends AbstractIndexEntity {
   String name;
-  EventType eventType;
+  String eventType;
   long startTime;
   long endTime;
   String metricName;
@@ -45,11 +43,11 @@ public class EventIndex extends AbstractIndexEntity {
     this.endTime = endTime;
   }
 
-  public EventType getEventType() {
+  public String getEventType() {
     return eventType;
   }
 
-  public void setEventType(EventType eventType) {
+  public void setEventType(String eventType) {
     this.eventType = eventType;
   }
 
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/mock/MockThirdEyeDataSource.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/mock/MockThirdEyeDataSource.java
index a022b0f..0731e84 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/mock/MockThirdEyeDataSource.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/mock/MockThirdEyeDataSource.java
@@ -94,8 +94,6 @@ public class MockThirdEyeDataSource implements 
ThirdEyeDataSource {
    * @throws Exception if properties cannot be parsed
    */
   public MockThirdEyeDataSource(Map<String, Object> properties) throws 
Exception {
-    loadMockCSVData(properties);
-
     // datasets
     this.datasets = new HashMap<>();
     Map<String, Object> config = ConfigUtils.getMap(properties.get(DATASETS));
@@ -214,6 +212,8 @@ public class MockThirdEyeDataSource implements 
ThirdEyeDataSource {
 
       onboarding.runAdhoc();
     }
+
+    loadMockCSVData(properties);
   }
 
   private void loadMockCSVData(Map<String, Object> properties) throws 
Exception {
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventEntity.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventEntity.java
index 6ec1459..9c8e0c8 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventEntity.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventEntity.java
@@ -19,9 +19,9 @@
 
 package org.apache.pinot.thirdeye.rootcause.impl;
 
-import org.apache.pinot.thirdeye.anomaly.events.EventType;
 import org.apache.pinot.thirdeye.datalayer.dto.EventDTO;
 import org.apache.pinot.thirdeye.rootcause.Entity;
+
 import java.util.ArrayList;
 import java.util.List;
 
diff --git 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventsPipeline.java
 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventsPipeline.java
index f70b0d8..c5d6cbf 100644
--- 
a/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventsPipeline.java
+++ 
b/thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/rootcause/impl/ThirdEyeEventsPipeline.java
@@ -19,27 +19,20 @@
 
 package org.apache.pinot.thirdeye.rootcause.impl;
 
+import org.apache.commons.collections4.MapUtils;
 import org.apache.pinot.thirdeye.datalayer.bao.EventManager;
 import org.apache.pinot.thirdeye.datalayer.dto.EventDTO;
 import org.apache.pinot.thirdeye.datalayer.util.Predicate;
 import org.apache.pinot.thirdeye.datasource.DAORegistry;
-import org.apache.pinot.thirdeye.rootcause.Entity;
-import org.apache.pinot.thirdeye.rootcause.MaxScoreSet;
-import org.apache.pinot.thirdeye.rootcause.Pipeline;
-import org.apache.pinot.thirdeye.rootcause.PipelineContext;
-import org.apache.pinot.thirdeye.rootcause.PipelineResult;
+import org.apache.pinot.thirdeye.rootcause.*;
 import org.apache.pinot.thirdeye.rootcause.util.EntityUtils;
 import org.apache.pinot.thirdeye.rootcause.util.ScoreUtils;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import org.apache.commons.collections4.MapUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
 
 /**
  * ThirdEyeEventsPipeline produces EventEntities within the current
@@ -139,7 +132,7 @@ public class ThirdEyeEventsPipeline extends Pipeline {
     return this.eventDAO.findByPredicate(Predicate.AND(
         Predicate.GE("startTime", start - OVERFETCH),
         Predicate.LT("endTime", end + OVERFETCH),
-        Predicate.EQ("eventType", eventType.toUpperCase())
+        Predicate.EQ("eventType", this.eventType.toUpperCase())
     ));
   }
 
@@ -160,7 +153,7 @@ public class ThirdEyeEventsPipeline extends Pipeline {
         }
       }
 
-      ThirdEyeEventEntity entity = ThirdEyeEventEntity.fromDTO(1.0, related, 
dto, eventType);
+      ThirdEyeEventEntity entity = ThirdEyeEventEntity.fromDTO(1.0, related, 
dto, this.eventType.toLowerCase());
       entities.add(entity.withScore(strategy.score(entity) * coefficient));
     }
     return entities;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to