ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [06/22] incubator-ignite git commit: Ignite-99-2 review
Date Tue, 27 Jan 2015 16:49:29 GMT
Ignite-99-2 review


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

Branch: refs/heads/sprint-1
Commit: 71b2f03c8df598878af19e00af80076ef71d482b
Parents: 885e763
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri Jan 23 19:56:03 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Fri Jan 23 19:56:03 2015 +0300

----------------------------------------------------------------------
 .../affinity/GridAffinityProcessor.java         | 24 ++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/71b2f03c/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
index 879895a..331b639 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessor.java
@@ -209,8 +209,8 @@ public class GridAffinityProcessor extends GridProcessorAdapter {
      * @param cacheName Cache name.
      * @return Cache affinity.
      */
-    public <K> GridCacheAffinityProxy<K> affinityProxy(String cacheName) {
-        return new GridCacheAffinityProxy(cacheName);
+    public <K> CacheAffinityProxy<K> affinityProxy(String cacheName) {
+        return new CacheAffinityProxy(cacheName);
     }
 
     /**
@@ -536,30 +536,36 @@ public class GridAffinityProcessor extends GridProcessorAdapter {
     /**
      * Grid cache affinity.
      */
-    private class GridCacheAffinityProxy<K> implements CacheAffinity<K> {
+    private class CacheAffinityProxy<K> implements CacheAffinity<K> {
+        /** */
         private final String cacheName;
 
         /**
          * @param cacheName Cache name.
          */
-        public GridCacheAffinityProxy(String cacheName) {
+        public CacheAffinityProxy(String cacheName) {
             this.cacheName = cacheName;
         }
 
         /** {@inheritDoc} */
         @Override public int partitions() {
+            ctx.gateway().readLock();
+
             try {
-                return GridAffinityProcessor.this.affinityCache(cacheName, topologyVersion()).affFunc.partitions();
+                return affinityCache(cacheName, topologyVersion()).affFunc.partitions();
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);
             }
+            finally {
+                ctx.gateway().readUnlock();
+            }
         }
 
         /** {@inheritDoc} */
         @Override public int partition(K key) {
             try {
-                return GridAffinityProcessor.this.affinityCache(cacheName, topologyVersion()).affFunc.partition(key);
+                return affinityCache(cacheName, topologyVersion()).affFunc.partition(key);
             }
             catch (IgniteCheckedException e) {
                 throw new IgniteException(e);
@@ -624,7 +630,7 @@ public class GridAffinityProcessor extends GridProcessorAdapter {
             try {
                 Collection<Integer> parts = new HashSet<>();
 
-                AffinityInfo affInfo= GridAffinityProcessor.this.affinityCache(cacheName,
topologyVersion());
+                AffinityInfo affInfo = affinityCache(cacheName, topologyVersion());
 
                 for (int partsCnt = affInfo.affFunc.partitions(), part = 0; part < partsCnt;
part++) {
                     for (ClusterNode affNode : affInfo.assignment.get(part)) {
@@ -723,7 +729,7 @@ public class GridAffinityProcessor extends GridProcessorAdapter {
          * @return Topology version.
          */
         private long topologyVersion() {
-            return GridAffinityProcessor.this.ctx.discovery().topologyVersion();
+            return ctx.discovery().topologyVersion();
         }
     }
-}
\ No newline at end of file
+}


Mime
View raw message