ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [46/50] [abbrv] ignite git commit: Fixes sync.nodeMap access modifier;
Date Wed, 18 Nov 2015 13:41:02 GMT
Fixes sync.nodeMap access modifier;


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

Branch: refs/heads/ignite-638
Commit: c1c8b21018a658004ee43ed8cfed9fa7796382e1
Parents: d038b02
Author: Vladisav Jelisavcic <vladisavj@gmail.com>
Authored: Wed Nov 18 09:10:53 2015 +0100
Committer: vladisav <vladisavj@gmail.com>
Committed: Wed Nov 18 09:10:53 2015 +0100

----------------------------------------------------------------------
 .../datastructures/GridCacheSemaphoreImpl.java  | 48 +++++++++++++-------
 1 file changed, 31 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c1c8b210/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
index 73638bc..befff13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
@@ -108,7 +108,7 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx,
Exter
         private static final long serialVersionUID = 1192457210091910933L;
 
         /** Map containing number of acquired permits for each node waiting on this semaphore.
*/
-        protected Map<UUID, Integer> nodeMap;
+        private Map<UUID, Integer> nodeMap;
 
         /** Flag indicating that it is safe to continue after node that acquired semaphore
fails. */
         final boolean failoverSafe;
@@ -148,6 +148,21 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx,
Exter
         }
 
         /**
+         * Get number of permits for node.
+         *
+         * @param nodeID
+         * @return Number of permits node has acquired at this semaphore. Can be less than
0 if
+         * more permits were released than acquired on node.
+         */
+        public int getPermitsForNode(UUID nodeID){
+            int ret = 0;
+            if(nodeMap.containsKey(nodeID)){
+                ret = nodeMap.get(nodeID);
+            }
+            return ret;
+        }
+
+        /**
          * Sets the number of permits currently available on this semaphore. This method
should only be used in
          * {@linkplain GridCacheSemaphoreImpl#onUpdate(GridCacheSemaphoreState)}.
          *
@@ -465,27 +480,26 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx,
Exter
     }
 
     @Override public void onNodeRemoved(UUID nodeID) {
-      if (sync.nodeMap.containsKey(nodeID)) {
-            int numPermits = sync.nodeMap.get(nodeID);
+        int numPermits = sync.getPermitsForNode(nodeID);
 
-            if (numPermits > 0) {
-                if (sync.failoverSafe) {
-                    // Release permits acquired by threads on failing node.
-                    sync.releaseFailedNode(nodeID);
-                }
-                else {
-                    // Interrupt every waiting thread if this semaphore is not failover safe.
-                    sync.broken = true;
-
-                    for(Thread t:sync.getSharedQueuedThreads()){
-                        t.interrupt();
-                    }
+        if (numPermits > 0) {
+            if (sync.failoverSafe) {
+                // Release permits acquired by threads on failing node.
+                sync.releaseFailedNode(nodeID);
+            }
+            else {
+                // Interrupt every waiting thread if this semaphore is not failover safe.
+                sync.broken = true;
 
-                    // Try to notify any waiting threads.
-                    sync.releaseShared(0);
+                for(Thread t:sync.getSharedQueuedThreads()){
+                    t.interrupt();
                 }
+
+                // Try to notify any waiting threads.
+                sync.releaseShared(0);
             }
         }
+
     }
 
     /** {@inheritDoc} */


Mime
View raw message