ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject incubator-ignite git commit: Added handling for GridDhtInvalidPartitionException
Date Thu, 06 Aug 2015 12:55:00 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1197 [created] 8c4153355


Added handling for GridDhtInvalidPartitionException


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

Branch: refs/heads/ignite-1197
Commit: 8c415335541f2b582003a9dc93f77adf319525b7
Parents: 63944d4
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Thu Aug 6 15:54:48 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Thu Aug 6 15:54:48 2015 +0300

----------------------------------------------------------------------
 .../distributed/dht/GridDhtLocalPartition.java  | 51 ++++++++++++++------
 1 file changed, 37 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8c415335/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 87c7f0e..192795a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -645,33 +645,56 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
             return null;
 
         return new Iterator<GridDhtCacheEntry>() {
-            /** */
             GridDhtCacheEntry lastEntry;
 
-            @Override public boolean hasNext() {
-                return it.hasNext();
+            {
+                lastEntry = advance();
             }
 
-            @Override public GridDhtCacheEntry next() {
-                Map.Entry<byte[], GridCacheSwapEntry> entry = it.next();
+            private GridDhtCacheEntry advance() {
+                if (it.hasNext()) {
+                    Map.Entry<byte[], GridCacheSwapEntry> entry = it.next();
 
-                byte[] keyBytes = entry.getKey();
+                    byte[] keyBytes = entry.getKey();
 
-                try {
-                    KeyCacheObject key = cctx.toCacheKeyObject(keyBytes);
+                    try {
+                        KeyCacheObject key = cctx.toCacheKeyObject(keyBytes);
 
-                    lastEntry = (GridDhtCacheEntry)cctx.cache().entryEx(key, false);
+                        lastEntry = (GridDhtCacheEntry)cctx.cache().entryEx(key, false);
 
-                    lastEntry.unswap(true);
+                        lastEntry.unswap(true);
 
-                    return lastEntry;
-                }
-                catch (IgniteCheckedException e) {
-                    throw new CacheException(e);
+                        return lastEntry;
+                    }
+                    catch (IgniteCheckedException e) {
+                        throw new CacheException(e);
+                    }
+                    catch (GridDhtInvalidPartitionException e) {
+                        if (log.isDebugEnabled())
+                            log.debug("Got invalid partition exception: " + e);
+
+                        return null;
+                    }
                 }
+
+                return null;
+            }
+
+            @Override public boolean hasNext() {
+                return lastEntry != null;
+            }
+
+            @Override public GridDhtCacheEntry next() {
+                if (lastEntry == null)
+                    throw new NoSuchElementException();
+
+                return lastEntry;
             }
 
             @Override public void remove() {
+                if (lastEntry == null)
+                    throw new NoSuchElementException();
+
                 map.remove(lastEntry.key(), lastEntry);
             }
         };


Mime
View raw message