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_r347547660
##########
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:
changed the code so that if exception occurs, we exit (since all queries to
couchbase will fail anyways), but if the issue is that the config could not be
read, we default to using in-memory cache.
----------------------------------------------------------------
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]