Skip to content

Commit

Permalink
KYLIN-4667 Automatically set kylin.query.cache-signature-enabled to b…
Browse files Browse the repository at this point in the history
…e true when memcached is enabled (#1540)
  • Loading branch information
Ted-Jiang committed Mar 18, 2021
1 parent d6073d2 commit 49d7b9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1960,8 +1960,12 @@ public boolean isQueryIgnoreUnknownFunction() {
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() {
Expand Down Expand Up @@ -2139,7 +2143,8 @@ public String getSQLResponseSignatureClass() {
}

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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
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;

/**
*/
Expand Down Expand Up @@ -121,7 +121,7 @@ public void cleanDataCache(String project) {
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);
Expand All @@ -131,7 +131,10 @@ public void cleanDataCache(String project) {
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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ private boolean isSegmentLevelCacheEnabled() {
return false;
}
try {
if (KylinConfig.getInstanceFromEnv().getMemCachedHosts() == null) {
if (!KylinConfig.getInstanceFromEnv().isMemcachedEnabled()) {
return false;
}
} catch (Exception e) {
Expand Down

0 comments on commit 49d7b9b

Please sign in to comment.