ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [21/21] incubator-ignite git commit: ignite-341-tests - wip
Date Thu, 26 Mar 2015 14:09:58 GMT
ignite-341-tests - wip


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

Branch: refs/heads/ignite-341-test
Commit: 83313e7315c0a432da347fc7b4602a5ebb06a668
Parents: 78cc3c0
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Thu Mar 26 17:09:28 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Thu Mar 26 17:09:28 2015 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2AbstractKeyValueRow.java | 25 ++++++-----------
 .../query/h2/opt/GridH2KeyValueRowOffheap.java  | 28 +++++++++-----------
 .../processors/query/h2/opt/GridH2Table.java    |  4 +--
 3 files changed, 22 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83313e73/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
index 2770a10..39b5d79 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2AbstractKeyValueRow.java
@@ -92,6 +92,8 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
      * @throws IgniteSpiException If failed.
      */
     public static Value wrap(Object obj, int type) throws IgniteSpiException {
+        assert obj != null;
+
         switch (type) {
             case Value.BOOLEAN:
                 return ValueBoolean.get((Boolean)obj);
@@ -169,26 +171,13 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
     }
 
     /**
-     * @param val Value.
-     * @throws IgniteCheckedException
-     */
-    public synchronized void unswapBeforeRemove(Object val) throws IgniteCheckedException
{
-        assert val != null;
-
-        Value oldVal = super.getValue(VAL_COL);
-
-        if (oldVal == null || oldVal instanceof WeakValue)
-            onUnswap(val);
-        // Else we would assert that val.equals(oldVal.getObject()) but value is not necessarily
implements equals() correctly.
-    }
-
-    /**
      * Should be called when entry getting unswapped.
      *
      * @param val Value.
+     * @param beforeRmv If this is unswap before remove.
      * @throws IgniteCheckedException If failed.
      */
-    public synchronized void onUnswap(Object val) throws IgniteCheckedException {
+    public synchronized void onUnswap(Object val, boolean beforeRmv) throws IgniteCheckedException
{
         setValue(VAL_COL, wrap(val, desc.valueType()));
     }
 
@@ -223,7 +212,7 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
             Value v = super.getValue(col);
 
             if (col == VAL_COL) {
-                int loops = 0;
+                long start = 0;
 
                 while ((v = WeakValue.unwrap(v)) == null) {
                     v = getOffheapValue(VAL_COL);
@@ -261,7 +250,9 @@ public abstract class GridH2AbstractKeyValueRow extends GridH2Row {
                             v = syncValue();
                         }
 
-                        if (++loops == 1000_000)
+                        if (start == 0)
+                            start = U.currentTimeMillis();
+                        else if (U.currentTimeMillis() - start > 10_000) // Loop at most
for 10 seconds.
                             throw new IllegalStateException("Failed to get value for key:
" + k);
                     }
                     catch (IgniteCheckedException e) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83313e73/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
index 9c1d90a..dc3d166 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2KeyValueRowOffheap.java
@@ -120,6 +120,7 @@ public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow
{
      */
     @SuppressWarnings("LockAcquiredButNotSafelyReleased")
     private static Lock lock(long ptr) {
+        assert ptr > 0;
         assert (ptr & 7) == 0 : ptr; // Unsafe allocated pointers aligned.
 
         Lock l = lock.getLock(ptr >>> 3);
@@ -198,8 +199,8 @@ public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow
{
 
             final long valPtr = mem.readLongVolatile(p);
 
-            if (valPtr == 0)
-                return; // Nothing to swap.
+            if (valPtr <= 0)
+                throw new IllegalStateException("Already swapped: " + valPtr + " " + this);
 
             desc.guard().finalizeLater(new Runnable() {
                 @Override public void run() {
@@ -215,13 +216,6 @@ public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow
{
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized void unswapBeforeRemove(Object val) throws IgniteCheckedException
{
-        assert val != null;
-
-        onUnswap(val);
-    }
-
-    /** {@inheritDoc} */
     @SuppressWarnings("NonSynchronizedMethodOverridesSynchronizedMethod")
     @Override protected Value updateWeakValue(Value exp, Value upd) {
         setValue(VAL_COL, upd);
@@ -230,20 +224,22 @@ public class GridH2KeyValueRowOffheap extends GridH2AbstractKeyValueRow
{
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized void onUnswap(Object val) throws IgniteCheckedException
{
-        super.onUnswap(val);
+    @Override public synchronized void onUnswap(Object val, boolean beforeRmv) throws IgniteCheckedException
{
+        assert val != null;
 
-        long p = ptr;
-
-        assert p > 0 : p;
+        final long p = ptr;
 
         Lock l = lock(p);
 
         try {
             GridUnsafeMemory mem = desc.memory();
 
-            if (mem.readLongVolatile(p + OFFSET_VALUE_REF) != 0)
-                return; // The offheap value is in its place, nothing to do here.
+            if (mem.readLongVolatile(p + OFFSET_VALUE_REF) != 0) {
+                if (beforeRmv)
+                    return; // The offheap value is in its place, nothing to do here.
+                else
+                    throw new IllegalStateException("Unswap without swap: " + p);
+            }
 
             Value v = getValue(VAL_COL); // We just set the value above, so it will be returned
right away.
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/83313e73/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
index e686c5e..62b3b5e 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
@@ -157,7 +157,7 @@ public class GridH2Table extends TableBase {
             if (val == null)
                 row.onSwap();
             else
-                row.onUnswap(val);
+                row.onUnswap(val, false);
 
             return true;
         }
@@ -382,7 +382,7 @@ public class GridH2Table extends TableBase {
                     Value v = row.getValue(GridH2AbstractKeyValueRow.VAL_COL);
 
                     if (v != null)
-                        ((GridH2AbstractKeyValueRow)old).unswapBeforeRemove(v.getObject());
+                        ((GridH2AbstractKeyValueRow)old).onUnswap(v.getObject(), true);
                 }
 
                 if (old != null) {


Mime
View raw message