akshayrai commented on a change in pull request #5155: [TE] anomaly detection
model downloader
URL: https://github.com/apache/incubator-pinot/pull/5155#discussion_r393306061
##########
File path:
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/model/download/ModelDownloaderManager.java
##########
@@ -0,0 +1,68 @@
+package org.apache.pinot.thirdeye.model.download;
+
+import java.lang.reflect.Constructor;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import org.apache.pinot.thirdeye.auto.onboard.AutoOnboardService;
+import org.apache.pinot.thirdeye.common.time.TimeGranularity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The model downloader manager. This class manages the life cycle of the
model downloader.
+ * It constructs the model downloader, and then schedules the model downloader
to run periodically and downloads the
+ * models into a local destination path. The class names, the run frequency
and the download path can be configured.
+ */
+public class ModelDownloaderManager {
+ private static final Logger LOG =
LoggerFactory.getLogger(AutoOnboardService.class);
+
+ private final List<ModelDownloaderConfiguration> configs;
+ private final Map<String, ModelDownloader> modelDownloaders;
+ private ScheduledExecutorService scheduledExecutorService;
+
+ public ModelDownloaderManager(List<ModelDownloaderConfiguration>
modelDownloaderConfigs) {
+ this.configs = modelDownloaderConfigs;
+ this.modelDownloaders = new HashMap<>();
+ this.scheduledExecutorService = Executors.newScheduledThreadPool(5);
+
+ constructModelDownloaders();
+ }
+
+ private void constructModelDownloaders() {
+ for (ModelDownloaderConfiguration config : this.configs) {
+ try {
+ Constructor<?> constructor =
Class.forName(config.getClassName()).getConstructor(Map.class);
+ ModelDownloader downloader = (ModelDownloader)
constructor.newInstance(config.getProperties());
+ this.modelDownloaders.put(config.getClassName(), downloader);
+ } catch (Exception e) {
+ LOG.warn("Failed to initialize model downloader {}",
config.getClassName(), e);
+ }
+ }
+ }
+
+ /**
+ * start the model downloader manager
+ */
+ public void start() {
Review comment:
Where will this run? every worker?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]