This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kylin.git
The following commit(s) were added to refs/heads/master by this push: new 49d7b9b KYLIN-4667 Automatically set kylin.query.cache-signature-enabled to be true when memcached is enabled (#1540) 49d7b9b is described below commit 49d7b9bd6c022bf842c731c0521f0898e16566bf Author: Jiang Yang <37145547+ted-ji...@users.noreply.github.com> AuthorDate: Thu Mar 18 17:21:41 2021 +0800 KYLIN-4667 Automatically set kylin.query.cache-signature-enabled to be true when memcached is enabled (#1540) --- .../src/main/java/org/apache/kylin/common/KylinConfigBase.java | 9 +++++++-- .../main/java/org/apache/kylin/rest/service/CacheService.java | 9 ++++++--- .../apache/kylin/storage/hbase/cube/v2/CubeHBaseEndpointRPC.java | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java index c3739b0..cd251ee 100644 --- a/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java +++ b/core-common/src/main/java/org/apache/kylin/common/KylinConfigBase.java @@ -1960,8 +1960,12 @@ public abstract class KylinConfigBase implements Serializable { return Boolean.parseBoolean(this.getOptional("kylin.query.ignore-unknown-function", FALSE)); } + public boolean isMemcachedEnabled() { + return !StringUtil.isEmpty(getMemCachedHosts()); + } + public String getMemCachedHosts() { - return getRequired("kylin.cache.memcached.hosts"); + return getOptional("kylin.cache.memcached.hosts", null); } public boolean isQuerySegmentCacheEnabled() { @@ -2139,7 +2143,8 @@ public abstract class KylinConfigBase implements Serializable { } public boolean isQueryCacheSignatureEnabled() { - return Boolean.parseBoolean(this.getOptional("kylin.query.cache-signature-enabled", FALSE)); + return Boolean.parseBoolean( + this.getOptional("kylin.query.cache-signature-enabled", String.valueOf(isMemcachedEnabled()))); } public int getFlatFilterMaxChildrenSize() { diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/CacheService.java b/server-base/src/main/java/org/apache/kylin/rest/service/CacheService.java index 9904cef..fca0316 100644 --- a/server-base/src/main/java/org/apache/kylin/rest/service/CacheService.java +++ b/server-base/src/main/java/org/apache/kylin/rest/service/CacheService.java @@ -27,11 +27,11 @@ import org.apache.kylin.storage.hbase.HBaseConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; +import org.springframework.cache.CacheManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import net.sf.ehcache.CacheManager; /** */ @@ -121,7 +121,7 @@ public class CacheService extends BasicService implements InitializingBean { logger.info("cleaning cache for project " + project + " (currently remove nothing)"); } else { logger.info("cleaning cache for project " + project + " (currently remove all entries)"); - cacheManager.getCache(QueryService.QUERY_CACHE).removeAll(); + cacheManager.getCache(QueryService.QUERY_CACHE).clear(); } } else { logger.warn("skip cleaning cache for project " + project); @@ -131,7 +131,10 @@ public class CacheService extends BasicService implements InitializingBean { protected void cleanAllDataCache() { if (cacheManager != null) { logger.warn("cleaning all storage cache"); - cacheManager.clearAll(); + for (String cacheName : cacheManager.getCacheNames()) { + logger.warn("cleaning storage cache for {}", cacheName); + cacheManager.getCache(cacheName).clear(); + } } else { logger.warn("skip cleaning all storage cache"); } diff --git a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/CubeHBaseEndpointRPC.java b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/CubeHBaseEndpointRPC.java index 8cc4daa..a2900fa 100644 --- a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/CubeHBaseEndpointRPC.java +++ b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/cube/v2/CubeHBaseEndpointRPC.java @@ -559,7 +559,7 @@ public class CubeHBaseEndpointRPC extends CubeHBaseRPC { return false; } try { - if (KylinConfig.getInstanceFromEnv().getMemCachedHosts() == null) { + if (!KylinConfig.getInstanceFromEnv().isMemcachedEnabled()) { return false; } } catch (Exception e) {