ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [18/43] incubator-ignite git commit: #IGNITE-86: Change undeploys from concurrentMap to Map
Date Mon, 02 Feb 2015 14:17:10 GMT
#IGNITE-86: Change undeploys from concurrentMap to Map


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4b690fc4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4b690fc4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4b690fc4

Branch: refs/heads/ignite-26
Commit: 4b690fc4217e26a27f7385f1c3ecb0b006e9eb15
Parents: fb37ccf
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Tue Jan 27 15:56:35 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Tue Jan 27 15:56:35 2015 +0300

----------------------------------------------------------------------
 .../cache/GridCacheDeploymentManager.java       | 31 +++++++++++++-------
 1 file changed, 21 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b690fc4/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
index 8729b86..fa0f65f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
@@ -53,7 +53,7 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap
     private volatile ClassLoader globalLdr;
 
     /** Undeploys. */
-    private final ConcurrentMap<String, ConcurrentLinkedQueue<CA>> undeploys
= new ConcurrentHashMap8<>();
+    private final Map<String, List<CA>> undeploys = new HashMap<>();
 
     /** Per-thread deployment context. */
     private ConcurrentMap<IgniteUuid, CachedDeploymentInfo<K, V>> deps = new
ConcurrentHashMap8<>();
@@ -182,12 +182,16 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap
     public void unwind(GridCacheContext ctx) {
         int cnt = 0;
 
-        ConcurrentLinkedQueue<CA> q = undeploys.get(ctx.namexx());
+        List<CA> q;
+
+        synchronized (undeploys) {
+            q = undeploys.remove(ctx.namexx());
+        }
 
         if (q == null)
             return;
 
-        for (CA c = q.poll(); c != null; c = q.poll()) {
+        for (CA c : q) {
             c.apply();
 
             cnt++;
@@ -209,14 +213,21 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap
             log.debug("Received onUndeploy() request [ldr=" + ldr + ", cctx=" + cctx + ']');
 
         for (final GridCacheContext<K, V> cacheCtx : cctx.cacheContexts()) {
-            undeploys.putIfAbsent(cacheCtx.namexx(), new ConcurrentLinkedQueue<CA>());
+            synchronized (undeploys) {
+                List<CA> queue = new ArrayList<>();
 
-            undeploys.get(cacheCtx.namexx()).add(new CA() {
-                @Override
-                public void apply() {
-                    onUndeploy0(ldr, cacheCtx);
-                }
-            });
+                if (undeploys.containsKey(cacheCtx.namexx()))
+                    queue = undeploys.get(cacheCtx.namexx());
+                else
+                    undeploys.put(cacheCtx.namexx(), queue);
+
+                queue.add(new CA() {
+                    @Override
+                    public void apply() {
+                        onUndeploy0(ldr, cacheCtx);
+                    }
+                });
+            }
         }
 
         for (GridCacheContext<K, V> cacheCtx : cctx.cacheContexts()) {


Mime
View raw message