You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2015/11/05 11:17:42 UTC
incubator-kylin git commit: KYLIN-1127 Drop LocalCacheUpdater
Repository: incubator-kylin
Updated Branches:
refs/heads/2.x-staging f8590d25e -> 8a77b8600
KYLIN-1127 Drop LocalCacheUpdater
Project: http://git-wip-us.apache.org/repos/asf/incubator-kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kylin/commit/8a77b860
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kylin/tree/8a77b860
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kylin/diff/8a77b860
Branch: refs/heads/2.x-staging
Commit: 8a77b8600fb9e3fbf60b230e63b573a9cd3d1d49
Parents: f8590d2
Author: Li, Yang <ya...@ebay.com>
Authored: Thu Nov 5 18:16:32 2015 +0800
Committer: Li, Yang <ya...@ebay.com>
Committed: Thu Nov 5 18:17:13 2015 +0800
----------------------------------------------------------------------
.../apache/kylin/common/cache/CacheUpdater.java | 1 +
.../kylin/common/cache/LocalCacheUpdater.java | 1 +
.../kylin/common/cache/RemoteCacheUpdater.java | 1 +
.../common/restclient/AbstractRestCache.java | 4 ++--
.../common/restclient/SingleValueCache.java | 6 +++++-
.../apache/kylin/rest/service/CacheService.java | 19 -------------------
server/src/main/resources/applicationContext.xml | 2 --
.../kylin/rest/service/CacheServiceTest.java | 11 +++--------
8 files changed, 13 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/core-common/src/main/java/org/apache/kylin/common/cache/CacheUpdater.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/cache/CacheUpdater.java b/core-common/src/main/java/org/apache/kylin/common/cache/CacheUpdater.java
index 186fd42..615ee14 100644
--- a/core-common/src/main/java/org/apache/kylin/common/cache/CacheUpdater.java
+++ b/core-common/src/main/java/org/apache/kylin/common/cache/CacheUpdater.java
@@ -5,6 +5,7 @@ import org.apache.kylin.common.restclient.Broadcaster;
/**
*/
+@SuppressWarnings("rawtypes")
public interface CacheUpdater {
void updateCache(Object key, Object value, Broadcaster.EVENT syncAction, Broadcaster.TYPE type, AbstractRestCache cache);
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/core-common/src/main/java/org/apache/kylin/common/cache/LocalCacheUpdater.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/cache/LocalCacheUpdater.java b/core-common/src/main/java/org/apache/kylin/common/cache/LocalCacheUpdater.java
index 8f629e3..8d3b648 100644
--- a/core-common/src/main/java/org/apache/kylin/common/cache/LocalCacheUpdater.java
+++ b/core-common/src/main/java/org/apache/kylin/common/cache/LocalCacheUpdater.java
@@ -5,6 +5,7 @@ import org.apache.kylin.common.restclient.Broadcaster;
/**
*/
+@SuppressWarnings({ "rawtypes", "unchecked" })
public class LocalCacheUpdater implements CacheUpdater {
@Override
public void updateCache(Object key, Object value, Broadcaster.EVENT syncAction, Broadcaster.TYPE type, AbstractRestCache cache) {
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/core-common/src/main/java/org/apache/kylin/common/cache/RemoteCacheUpdater.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/cache/RemoteCacheUpdater.java b/core-common/src/main/java/org/apache/kylin/common/cache/RemoteCacheUpdater.java
index 2a5e59a..2927d2d 100644
--- a/core-common/src/main/java/org/apache/kylin/common/cache/RemoteCacheUpdater.java
+++ b/core-common/src/main/java/org/apache/kylin/common/cache/RemoteCacheUpdater.java
@@ -5,6 +5,7 @@ import org.apache.kylin.common.restclient.Broadcaster;
/**
*/
+@SuppressWarnings("rawtypes")
public class RemoteCacheUpdater implements CacheUpdater {
@Override
public void updateCache(Object key, Object value, Broadcaster.EVENT syncAction, Broadcaster.TYPE type, AbstractRestCache cache) {
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/core-common/src/main/java/org/apache/kylin/common/restclient/AbstractRestCache.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/restclient/AbstractRestCache.java b/core-common/src/main/java/org/apache/kylin/common/restclient/AbstractRestCache.java
index 043a3b4..68d9be5 100644
--- a/core-common/src/main/java/org/apache/kylin/common/restclient/AbstractRestCache.java
+++ b/core-common/src/main/java/org/apache/kylin/common/restclient/AbstractRestCache.java
@@ -19,7 +19,7 @@
package org.apache.kylin.common.restclient;
import org.apache.kylin.common.cache.CacheUpdater;
-import org.apache.kylin.common.cache.LocalCacheUpdater;
+import org.apache.kylin.common.cache.RemoteCacheUpdater;
/**
* @author xjiang
@@ -27,7 +27,7 @@ import org.apache.kylin.common.cache.LocalCacheUpdater;
*/
public abstract class AbstractRestCache<K, V> {
- protected static CacheUpdater cacheUpdater = new LocalCacheUpdater();
+ protected static CacheUpdater cacheUpdater = new RemoteCacheUpdater();
public static void setCacheUpdater(CacheUpdater cu) {
cacheUpdater = cu;
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/core-common/src/main/java/org/apache/kylin/common/restclient/SingleValueCache.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/restclient/SingleValueCache.java b/core-common/src/main/java/org/apache/kylin/common/restclient/SingleValueCache.java
index 2a3ff06..cb6c286 100644
--- a/core-common/src/main/java/org/apache/kylin/common/restclient/SingleValueCache.java
+++ b/core-common/src/main/java/org/apache/kylin/common/restclient/SingleValueCache.java
@@ -59,7 +59,11 @@ public abstract class SingleValueCache<K, V> extends AbstractRestCache<K, V> {
}
public void remove(K key) {
- if (innerCache.containsKey(key)) {
+ boolean exists = innerCache.containsKey(key);
+
+ innerCache.remove(key);
+
+ if (exists) {
cacheUpdater.updateCache(key, null, Broadcaster.EVENT.DROP, syncType, this);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/server/src/main/java/org/apache/kylin/rest/service/CacheService.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/kylin/rest/service/CacheService.java b/server/src/main/java/org/apache/kylin/rest/service/CacheService.java
index 98ddc6f..c1e0ed2 100644
--- a/server/src/main/java/org/apache/kylin/rest/service/CacheService.java
+++ b/server/src/main/java/org/apache/kylin/rest/service/CacheService.java
@@ -20,10 +20,6 @@ package org.apache.kylin.rest.service;
import java.io.IOException;
-import javax.annotation.PostConstruct;
-
-import org.apache.kylin.common.cache.CacheUpdater;
-import org.apache.kylin.common.restclient.AbstractRestCache;
import org.apache.kylin.common.restclient.Broadcaster;
import org.apache.kylin.cube.CubeDescManager;
import org.apache.kylin.cube.CubeInstance;
@@ -43,29 +39,14 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.google.common.base.Preconditions;
-
/**
*/
@Component("cacheService")
public class CacheService extends BasicService {
@Autowired
- private CacheUpdater cacheUpdater;
-
- @Autowired
private CubeService cubeService;
- @PostConstruct
- public void init() throws IOException {
- initCacheUpdater(cacheUpdater);
- }
-
- public void initCacheUpdater(CacheUpdater cacheUpdater) {
- Preconditions.checkNotNull(cacheUpdater, "cacheManager is not injected yet");
- AbstractRestCache.setCacheUpdater(cacheUpdater);
- }
-
public void setCubeService(CubeService cubeService) {
this.cubeService = cubeService;
}
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/server/src/main/resources/applicationContext.xml
----------------------------------------------------------------------
diff --git a/server/src/main/resources/applicationContext.xml b/server/src/main/resources/applicationContext.xml
index 5bb7ed3..a103b56 100644
--- a/server/src/main/resources/applicationContext.xml
+++ b/server/src/main/resources/applicationContext.xml
@@ -89,13 +89,11 @@
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:configLocation="classpath:ehcache.xml" p:shared="true"/>
- <bean id="cacheUpdater" class="org.apache.kylin.common.cache.RemoteCacheUpdater"/>
</beans>
<beans profile="sandbox,testing">
<bean id="ehcache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
p:configLocation="classpath:ehcache-test.xml" p:shared="true"/>
- <bean id="cacheUpdater" class="org.apache.kylin.common.cache.LocalCacheUpdater"/>
</beans>
<!-- hbase storage/global lock Config -->
http://git-wip-us.apache.org/repos/asf/incubator-kylin/blob/8a77b860/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
----------------------------------------------------------------------
diff --git a/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java b/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
index b997814..88d6273 100644
--- a/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
+++ b/server/src/test/java/org/apache/kylin/rest/service/CacheServiceTest.java
@@ -18,9 +18,7 @@
package org.apache.kylin.rest.service;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
import java.util.Arrays;
import java.util.Set;
@@ -28,7 +26,6 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.common.cache.RemoteCacheUpdater;
import org.apache.kylin.common.restclient.Broadcaster;
import org.apache.kylin.common.util.LocalFileMetadataTestCase;
import org.apache.kylin.cube.CubeDescManager;
@@ -55,10 +52,10 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*/
-
public class CacheServiceTest extends LocalFileMetadataTestCase {
private static Server server;
@@ -66,7 +63,7 @@ public class CacheServiceTest extends LocalFileMetadataTestCase {
private static KylinConfig configA;
private static KylinConfig configB;
- private static final Logger logger = org.slf4j.LoggerFactory.getLogger(CacheServiceTest.class);
+ private static final Logger logger = LoggerFactory.getLogger(CacheServiceTest.class);
private static AtomicLong counter = new AtomicLong();
@@ -108,9 +105,7 @@ public class CacheServiceTest extends LocalFileMetadataTestCase {
}
};
- serviceA.initCacheUpdater(new RemoteCacheUpdater());
serviceA.setCubeService(cubeServiceA);
- serviceB.initCacheUpdater(new RemoteCacheUpdater());
serviceB.setCubeService(cubeServiceB);
context.addServlet(new ServletHolder(new BroadcasterReceiveServlet(new BroadcasterReceiveServlet.BroadcasterHandler() {