ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [01/50] [abbrv] incubator-ignite git commit: ignite-59 review
Date Wed, 28 Jan 2015 15:20:22 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-72 b4cdb00c5 -> 7a9497525


ignite-59 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/0357b74b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0357b74b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0357b74b

Branch: refs/heads/ignite-72
Commit: 0357b74b0fa155f3eb18766591abda15821fbd2e
Parents: 17d1b5f
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Tue Jan 27 16:43:26 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Tue Jan 27 16:43:26 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheLockImpl.java         | 44 +++++++-------------
 .../processors/cache/IgniteCacheProxy.java      |  3 --
 .../transactions/IgniteTxConcurrency.java       |  2 +-
 .../cache/GridCacheBasicApiAbstractTest.java    |  4 +-
 .../GridCacheMultiNodeLockAbstractTest.java     | 10 ++---
 5 files changed, 22 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0357b74b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
index c1ed7eb..0f1fe42 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
@@ -18,7 +18,7 @@
 package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.jetbrains.annotations.*;
 
@@ -54,6 +54,8 @@ class CacheLockImpl<K> implements Lock {
 
     /** {@inheritDoc} */
     @Override public void lock() {
+        //cctx.readlock();
+
         try {
             delegate.lockAll(keys, 0);
 
@@ -62,6 +64,9 @@ class CacheLockImpl<K> implements Lock {
         catch (IgniteCheckedException e) {
             throw new CacheException(e.getMessage(), e);
         }
+        finally {
+            //cctx.readunlock();
+        }
     }
 
     /**
@@ -70,9 +75,9 @@ class CacheLockImpl<K> implements Lock {
     private void incrementLockCounter() {
         assert (lockedThread == null && cntr == 0) || (lockedThread == Thread.currentThread()
&& cntr > 0);
 
-        lockedThread = Thread.currentThread();
-
         cntr++;
+
+        lockedThread = Thread.currentThread();
     }
 
     /** {@inheritDoc} */
@@ -139,34 +144,12 @@ class CacheLockImpl<K> implements Lock {
         }
     }
 
-    /**
-     *
-     */
-    private boolean isKeysLocked() {
-        for (K key : keys) {
-            if (delegate.isLocked(key))
-                return true;
-        }
-
-        return false;
-    }
-
     /** {@inheritDoc} */
     @Override public void unlock() {
         try {
-            Thread lockedThread = this.lockedThread;
-
             if (lockedThread != Thread.currentThread()) {
-                if (lockedThread == null) {
-                    if (isKeysLocked()) {
-                        throw new IllegalStateException("Failed to unlock keys, looks like
lock has been obtain on " +
-                            "another instance of Lock, that was returned by IgniteCache.lock(key).
You have to call " +
-                            "lock() and unlock() methods on the same instance of Lock [keys="
+ keys + ']');
-                    }
-                } else {
-                    throw new IllegalStateException("Failed to unlock cache keys, keys are
locked by another thread " +
-                        "any threads [keys=" + keys + ", lockOwnerThread=" + lockedThread.getName()
+ ']');
-                }
+                throw new IllegalStateException("Failed to unlock keys (did current thread
acquire lock " +
+                    "with this lock instance?).");
             }
 
             assert cntr > 0;
@@ -174,7 +157,7 @@ class CacheLockImpl<K> implements Lock {
             cntr--;
 
             if (cntr == 0)
-                this.lockedThread = null;
+                lockedThread = null;
 
             delegate.unlockAll(keys);
         }
@@ -187,4 +170,9 @@ class CacheLockImpl<K> implements Lock {
     @NotNull @Override public Condition newCondition() {
         throw new UnsupportedOperationException();
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(CacheLockImpl.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0357b74b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 63c1f65..5993097 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -20,9 +20,7 @@ package org.apache.ignite.internal.processors.cache;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.*;
-import org.apache.ignite.cluster.*;
 import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -35,7 +33,6 @@ import javax.cache.integration.*;
 import javax.cache.processor.*;
 import java.io.*;
 import java.util.*;
-import java.util.concurrent.*;
 import java.util.concurrent.locks.*;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0357b74b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxConcurrency.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxConcurrency.java
b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxConcurrency.java
index cc2f678..14213e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxConcurrency.java
+++ b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTxConcurrency.java
@@ -17,7 +17,7 @@
 
 package org.apache.ignite.transactions;
 
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.*;
 
 /**
  * Transaction concurrency control. See {@link IgniteTx} for more information

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0357b74b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
index 1309c43..4b34bd2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import com.beust.jcommander.internal.*;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
@@ -30,7 +29,6 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
-import org.jetbrains.annotations.Nullable;
 
 import javax.cache.expiry.*;
 import java.util.*;
@@ -547,7 +545,7 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
     public void testMultiLocks() throws Exception {
         IgniteCache<Integer, String> cache = ignite.jcache(null);
 
-        Collection<Integer> keys = Lists.newArrayList(1, 2, 3);
+        Collection<Integer> keys = Arrays.asList(1, 2, 3);
 
         Lock lock = cache.lockAll(keys);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0357b74b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
index bc53d0b..8796d69 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
@@ -17,22 +17,20 @@
 
 package org.apache.ignite.internal.processors.cache.distributed;
 
-import com.beust.jcommander.internal.*;
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.distributed.dht.*;
+import org.apache.ignite.internal.processors.cache.distributed.near.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.internal.processors.cache.distributed.dht.*;
-import org.apache.ignite.internal.processors.cache.distributed.near.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 import org.jetbrains.annotations.*;
-import org.jetbrains.annotations.Nullable;
 
 import java.util.*;
 import java.util.concurrent.*;
@@ -385,8 +383,8 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
         IgniteCache<Integer, String> cache1 = ignite1.jcache(null);
         IgniteCache<Integer, String> cache2 = ignite2.jcache(null);
 
-        Collection<Integer> keys1 = Lists.newArrayList(1, 2, 3);
-        Collection<Integer> keys2 = Lists.newArrayList(2, 3, 4);
+        Collection<Integer> keys1 = Arrays.asList(1, 2, 3);
+        Collection<Integer> keys2 = Arrays.asList(2, 3, 4);
 
         Lock lock1_1 = cache1.lockAll(keys1);
         Lock lock2_2 = cache2.lockAll(keys2);


Mime
View raw message