ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [29/30] incubator-ignite git commit: ignite-sql-tests - swap fix
Date Fri, 13 Mar 2015 17:06:54 GMT
ignite-sql-tests - swap fix


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

Branch: refs/heads/ignite-sql-tests
Commit: 0cced36e2da0464a84a4c2ffd177c14f900e936f
Parents: 0b1c0d7
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Fri Mar 13 20:00:48 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Fri Mar 13 20:00:48 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheSwapListener.java |  5 +++-
 .../processors/cache/GridCacheSwapManager.java  | 29 ++++++++++++++------
 .../spi/swapspace/file/FileSwapSpaceSpi.java    | 10 +++++--
 .../processors/query/h2/IgniteH2Indexing.java   | 10 ++++++-
 4 files changed, 42 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0cced36e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
index ff5ad32..811b951f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapListener.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.internal.processors.cache;
 
+import org.apache.ignite.*;
+
 /**
  * Provides ability to listen to swap events in cache which is necessary for preloading.
  */
@@ -25,6 +27,7 @@ public interface GridCacheSwapListener {
      * @param part Partition.
      * @param key Cache key.
      * @param e Entry.
+     * @throws IgniteCheckedException If failed.
      */
-    public void onEntryUnswapped(int part, KeyCacheObject key, GridCacheSwapEntry e);
+    public void onEntryUnswapped(int part, KeyCacheObject key, GridCacheSwapEntry e) throws
IgniteCheckedException;
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0cced36e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index d6aef65..ca29f89 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -226,8 +226,9 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      * @param part Partition.
      * @param key Cache key.
      * @param e Entry.
+     * @throws IgniteCheckedException If failed.
      */
-    private void onUnswapped(int part, KeyCacheObject key, GridCacheSwapEntry e) {
+    private void onUnswapped(int part, KeyCacheObject key, GridCacheSwapEntry e) throws IgniteCheckedException
{
         onEntryUnswapped(swapLsnrs, part, key, e);
     }
 
@@ -235,8 +236,9 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      * @param part Partition.
      * @param key Cache key.
      * @param e Entry.
+     * @throws IgniteCheckedException If failed.
      */
-    private void onOffHeaped(int part, KeyCacheObject key, GridCacheSwapEntry e) {
+    private void onOffHeaped(int part, KeyCacheObject key, GridCacheSwapEntry e) throws IgniteCheckedException
{
         onEntryUnswapped(offheapLsnrs, part, key, e);
     }
 
@@ -245,9 +247,10 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      * @param part Partition.
      * @param key Cache key.
      * @param e Entry.
+     * @throws IgniteCheckedException If failed.
      */
     private void onEntryUnswapped(ConcurrentMap<Integer, Collection<GridCacheSwapListener>>
map,
-        int part, KeyCacheObject key, GridCacheSwapEntry e) {
+        int part, KeyCacheObject key, GridCacheSwapEntry e) throws IgniteCheckedException
{
         Collection<GridCacheSwapListener> lsnrs = map.get(part);
 
         if (lsnrs == null) {
@@ -391,7 +394,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      * @return Reconstituted swap entry or {@code null} if entry is obsolete.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable private GridCacheSwapEntry swapEntry(GridCacheSwapEntry e) throws IgniteCheckedException
+    @Nullable private <X extends GridCacheSwapEntry> X swapEntry(X e) throws IgniteCheckedException
     {
         assert e != null;
 
@@ -1849,7 +1852,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
     /**
      *
      */
-    private static class KeySwapListener implements GridCacheSwapListener {
+    private class KeySwapListener implements GridCacheSwapListener {
         /** */
         private final KeyCacheObject key;
 
@@ -1866,16 +1869,26 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter
{
         /** {@inheritDoc} */
         @Override public void onEntryUnswapped(int part,
             KeyCacheObject key,
-            GridCacheSwapEntry e)
-        {
+            GridCacheSwapEntry e) throws IgniteCheckedException {
             if (this.key.equals(key)) {
-                entry = new GridCacheSwapEntryImpl(ByteBuffer.wrap(e.valueBytes()),
+                GridCacheSwapEntryImpl e0 = new GridCacheSwapEntryImpl(ByteBuffer.wrap(e.valueBytes()),
                     e.type(),
                     e.version(),
                     e.ttl(),
                     e.expireTime(),
                     e.keyClassLoaderId(),
                     e.valueClassLoaderId());
+
+                CacheObject v = e.value();
+
+                if (v != null)
+                    e0.value(v);
+                else
+                    e0 = swapEntry(e0);
+
+                assert e0 != null;
+
+                entry = e0;
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0cced36e/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
index 5eec025..858db79 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/swapspace/file/FileSwapSpaceSpi.java
@@ -718,8 +718,14 @@ public class FileSwapSpaceSpi extends IgniteSpiAdapter implements SwapSpaceSpi,
             try {
                 res = ch.read(ByteBuffer.wrap(v), pos);
             }
-            catch (ClosedChannelException ignore) {
-                assert idx == DELETED;
+            catch (ClosedByInterruptException e) {
+                throw new IgniteSpiException("Operation was interrupted.", e);
+            }
+            catch (AsynchronousCloseException ignore) {
+                assert idx == DELETED; // We closed it ourselves.
+            }
+            catch (ClosedChannelException e) {
+                throw new IgniteSpiException("File channel was unexpectedly closed.", e);
             }
             catch (IOException e) {
                 throw new IgniteSpiException("Failed to read value.", e);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0cced36e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 0892a6f..c3a3da3 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -24,6 +24,7 @@ import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.query.*;
 import org.apache.ignite.internal.processors.query.h2.opt.*;
@@ -1912,7 +1913,14 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             GridCacheSwapEntry e = cctx.swap().read(cctx.toCacheKeyObject(key), true, true);
 
-            return e != null ? e.value().value(cctx.cacheObjectContext(), false) : null;
+            if (e == null)
+                return null;
+
+            CacheObject v = e.value();
+
+            assert v != null : "swap must unmarshall it for us";
+
+            return v.value(cctx.cacheObjectContext(), false);
         }
 
         /** {@inheritDoc} */


Mime
View raw message