kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liy...@apache.org
Subject kylin git commit: KYLIN-2581 fix possible deadlock in Broadcaster
Date Sun, 14 May 2017 05:35:55 GMT
Repository: kylin
Updated Branches:
  refs/heads/master 320e56a53 -> fd671d165


KYLIN-2581 fix possible deadlock in Broadcaster


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/fd671d16
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/fd671d16
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/fd671d16

Branch: refs/heads/master
Commit: fd671d165aa59c734b2f273ffae6d1017dc61153
Parents: 320e56a
Author: Yang Li <liyang@apache.org>
Authored: Sun May 14 13:34:58 2017 +0800
Committer: Yang Li <liyang@apache.org>
Committed: Sun May 14 13:35:29 2017 +0800

----------------------------------------------------------------------
 .../kylin/metadata/cachesync/Broadcaster.java   | 66 ++++++++++----------
 1 file changed, 32 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/fd671d16/core-metadata/src/main/java/org/apache/kylin/metadata/cachesync/Broadcaster.java
----------------------------------------------------------------------
diff --git a/core-metadata/src/main/java/org/apache/kylin/metadata/cachesync/Broadcaster.java
b/core-metadata/src/main/java/org/apache/kylin/metadata/cachesync/Broadcaster.java
index 5b45d9e..1394f7b 100644
--- a/core-metadata/src/main/java/org/apache/kylin/metadata/cachesync/Broadcaster.java
+++ b/core-metadata/src/main/java/org/apache/kylin/metadata/cachesync/Broadcaster.java
@@ -142,7 +142,7 @@ public class Broadcaster {
     }
 
     public void registerListener(Listener listener, String... entities) {
-        synchronized (CACHE) {
+        synchronized (listenerMap) {
             // ignore re-registration
             List<Listener> all = listenerMap.get(SYNC_ALL);
             if (all != null && all.contains(listener)) {
@@ -181,43 +181,41 @@ public class Broadcaster {
     }
 
     public void notifyListener(String entity, Event event, String cacheKey) throws IOException
{
-        synchronized (CACHE) {
-            List<Listener> list = listenerMap.get(entity);
-            if (list == null)
-                return;
+        List<Listener> list = listenerMap.get(entity);
+        if (list == null)
+            return;
 
-            logger.debug("Broadcasting metadata change: entity=" + entity + ", event=" +
event + ", cacheKey=" + cacheKey + ", listeners=" + list);
+        logger.debug("Broadcasting metadata change: entity=" + entity + ", event=" + event
+ ", cacheKey=" + cacheKey + ", listeners=" + list);
 
-            // prevents concurrent modification exception
-            list = Lists.newArrayList(list);
-            switch (entity) {
-            case SYNC_ALL:
-                for (Listener l : list) {
-                    l.onClearAll(this);
-                }
-                clearCache(); // clear broadcaster too in the end
-                break;
-            case SYNC_PRJ_SCHEMA:
-                ProjectManager.getInstance(config).clearL2Cache();
-                for (Listener l : list) {
-                    l.onProjectSchemaChange(this, cacheKey);
-                }
-                break;
-            case SYNC_PRJ_DATA:
-                ProjectManager.getInstance(config).clearL2Cache(); // cube's first becoming
ready leads to schema change too
-                for (Listener l : list) {
-                    l.onProjectDataChange(this, cacheKey);
-                }
-                break;
-            default:
-                for (Listener l : list) {
-                    l.onEntityChange(this, entity, event, cacheKey);
-                }
-                break;
+        // prevents concurrent modification exception
+        list = Lists.newArrayList(list);
+        switch (entity) {
+        case SYNC_ALL:
+            for (Listener l : list) {
+                l.onClearAll(this);
             }
-
-            logger.debug("Done broadcasting metadata change: entity=" + entity + ", event="
+ event + ", cacheKey=" + cacheKey);
+            clearCache(); // clear broadcaster too in the end
+            break;
+        case SYNC_PRJ_SCHEMA:
+            ProjectManager.getInstance(config).clearL2Cache();
+            for (Listener l : list) {
+                l.onProjectSchemaChange(this, cacheKey);
+            }
+            break;
+        case SYNC_PRJ_DATA:
+            ProjectManager.getInstance(config).clearL2Cache(); // cube's first becoming ready
leads to schema change too
+            for (Listener l : list) {
+                l.onProjectDataChange(this, cacheKey);
+            }
+            break;
+        default:
+            for (Listener l : list) {
+                l.onEntityChange(this, entity, event, cacheKey);
+            }
+            break;
         }
+
+        logger.debug("Done broadcasting metadata change: entity=" + entity + ", event=" +
event + ", cacheKey=" + cacheKey);
     }
 
     /**


Mime
View raw message