Repository: incubator-griffin Updated Branches: refs/heads/master 898297161 -> 85d90b3c3
move hive meta refresh function to HiveMetaStoreServiceImpl Author: wenzhao <vinlyz...@gmail.com> Closes #245 from vzhao/master. Project: http://git-wip-us.apache.org/repos/asf/incubator-griffin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-griffin/commit/85d90b3c Tree: http://git-wip-us.apache.org/repos/asf/incubator-griffin/tree/85d90b3c Diff: http://git-wip-us.apache.org/repos/asf/incubator-griffin/diff/85d90b3c Branch: refs/heads/master Commit: 85d90b3c3603e34fde5173d2e179acb114d22eef Parents: 8982971 Author: wenzhao <vinlyz...@gmail.com> Authored: Fri Mar 30 11:57:23 2018 +0800 Committer: Lionel Liu <bhlx3l...@163.com> Committed: Fri Mar 30 11:57:23 2018 +0800 ---------------------------------------------------------------------- .../griffin/core/common/CacheEvictor.java | 47 -------------------- .../hive/HiveMetaStoreServiceImpl.java | 10 +++++ 2 files changed, 10 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/85d90b3c/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java ---------------------------------------------------------------------- diff --git a/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java b/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java deleted file mode 100644 index 17c0f91..0000000 --- a/service/src/main/java/org/apache/griffin/core/common/CacheEvictor.java +++ /dev/null @@ -1,47 +0,0 @@ -/* -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. -*/ -package org.apache.griffin.core.common; - -import org.apache.griffin.core.metastore.hive.HiveMetaStoreService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.cache.annotation.CacheEvict; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Component -public class CacheEvictor { - private static final Logger LOGGER = LoggerFactory.getLogger(CacheEvictor.class); - - private final HiveMetaStoreService hiveMetaStoreService; - - @Autowired - public CacheEvictor(HiveMetaStoreService hiveMetaStoreService) { - this.hiveMetaStoreService = hiveMetaStoreService; - } - - @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") - @CacheEvict(cacheNames = "hive", allEntries = true, beforeInvocation = true) - public void evictHiveCache() { - LOGGER.info("Evict hive cache"); - hiveMetaStoreService.getAllTable(); - LOGGER.info("After evict hive cache,automatically refresh hive tables cache."); - } -} http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/85d90b3c/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java ---------------------------------------------------------------------- diff --git a/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java b/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java index e941aaa..8e265e0 100644 --- a/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java +++ b/service/src/main/java/org/apache/griffin/core/metastore/hive/HiveMetaStoreServiceImpl.java @@ -27,7 +27,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -140,6 +142,14 @@ public class HiveMetaStoreServiceImpl implements HiveMetaStoreService { return result; } + @Scheduled(fixedRateString = "${cache.evict.hive.fixedRate.in.milliseconds}") + @CacheEvict(cacheNames = "hive", allEntries = true, beforeInvocation = true) + public void evictHiveCache() { + LOGGER.info("Evict hive cache"); + getAllTable(); + LOGGER.info("After evict hive cache,automatically refresh hive tables cache."); + } + private List<Table> getTables(String db) { String useDbName = getUseDbName(db);