bxji commented on a change in pull request #4761: [TE] Centralized cache 
proof-of-concept for anomaly detection via Couchbase
URL: https://github.com/apache/incubator-pinot/pull/4761#discussion_r346631206
 
 

 ##########
 File path: 
thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datasource/ThirdEyeCacheRegistry.java
 ##########
 @@ -90,14 +98,42 @@ public static void initDataSources(ThirdEyeConfiguration 
thirdeyeConfig) {
     }
   }
 
+  public static void initCentralizedCache(ThirdEyeConfiguration 
thirdeyeConfig) {
+    try {
+      URL cacheConfigUrl = thirdeyeConfig.getCacheConfigAsUrl();
+      CacheConfig cacheConfig = 
CacheConfigLoader.fromCacheConfigUrl(cacheConfigUrl);
+      if (cacheConfig == null) {
+        throw new IllegalStateException("Could not get cache config from path 
" + cacheConfigUrl);
+      }
+
+      CacheDataSource dataSource = 
CacheConfig.getCentralizedCacheSettings().getDataSourceConfig();
+
+      cacheConfig.setHost(dataSource.getHost());
+      cacheConfig.setAuthUsername(dataSource.getAuthUsername());
+      cacheConfig.setAuthPassword(dataSource.getAuthPassword());
+      cacheConfig.setBucketName(dataSource.getBucketName());
+
+      if (INSTANCE.getTimeSeriesCache() == null) {
+        TimeSeriesCache timeSeriesCache = new 
DefaultTimeSeriesCache(DAO_REGISTRY.getMetricConfigDAO(), 
DAO_REGISTRY.getDatasetConfigDAO(),
+            ThirdEyeCacheRegistry.getInstance().getQueryCache(),
+            new CouchbaseCacheDAO(),
+            
Executors.newFixedThreadPool(CacheConfig.getCentralizedCacheSettings().getMaxParallelInserts()));
+
+        
ThirdEyeCacheRegistry.getInstance().registerTimeSeriesCache(timeSeriesCache);
+      }
+    } catch (Exception e) {
+      LOGGER.info("Caught exception while initializing centralized cache", e);
 
 Review comment:
   exception is probably better. When we make queries to the centralized cache, 
the code as is throws an exception if a fatal error occurs, so no detections 
will complete if the connection is not properly initialized.

----------------------------------------------------------------
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]

Reply via email to