You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/11/25 06:49:39 UTC
[1/3] ignite git commit: IGNITE-1988 - Exception for explicit lock
inside a transaction
Repository: ignite
Updated Branches:
refs/heads/ignite-sql-cache-stmt 1213f2c00 -> 1171b36b4
IGNITE-1988 - Exception for explicit lock inside a transaction
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4d29cb7f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4d29cb7f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4d29cb7f
Branch: refs/heads/ignite-sql-cache-stmt
Commit: 4d29cb7f87aafa505807f4b10cddd0264cdac85f
Parents: c23cda1
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Nov 24 16:23:05 2015 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Nov 24 16:23:05 2015 -0800
----------------------------------------------------------------------
.../processors/cache/CacheLockImpl.java | 18 ++++++++-
.../colocated/GridDhtColocatedLockFuture.java | 8 ++--
.../cache/GridCacheAbstractFullApiSelfTest.java | 42 +++++++++++++++++++-
3 files changed, 61 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d29cb7f/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 2e8dc9b..ae7b42e 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
@@ -69,6 +69,8 @@ class CacheLockImpl<K, V> implements Lock {
CacheOperationContext prev = gate.enter(opCtx);
try {
+ checkTx();
+
delegate.lockAll(keys, 0);
incrementLockCounter();
@@ -102,6 +104,8 @@ class CacheLockImpl<K, V> implements Lock {
CacheOperationContext prev = gate.enter(opCtx);
try {
+ checkTx();
+
boolean res = delegate.lockAll(keys, -1);
if (res)
@@ -128,6 +132,8 @@ class CacheLockImpl<K, V> implements Lock {
CacheOperationContext prev = gate.enter(opCtx);
try {
+ checkTx();
+
IgniteInternalFuture<Boolean> fut = delegate.lockAllAsync(keys, unit.toMillis(time));
try {
@@ -198,8 +204,18 @@ class CacheLockImpl<K, V> implements Lock {
throw new UnsupportedOperationException();
}
+ /**
+ * Verifies there is no ongoing user transaction.
+ *
+ * @throws CacheException
+ */
+ private void checkTx() throws CacheException {
+ if (delegate.context().tm().inUserTx())
+ throw new CacheException("Explicit lock can't be acquired within a transaction.");
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(CacheLockImpl.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d29cb7f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index 7e6ce89..ecdf641 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -296,10 +296,6 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
GridCacheMvccCandidate cand = cctx.mvcc().explicitLock(threadId, txKey);
if (inTx()) {
- IgniteTxEntry txEntry = tx.entry(txKey);
-
- txEntry.cached(entry);
-
if (cand != null) {
if (!tx.implicit())
throw new IgniteCheckedException("Cannot access key within transaction if lock is " +
@@ -308,6 +304,10 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
return null;
}
else {
+ IgniteTxEntry txEntry = tx.entry(txKey);
+
+ txEntry.cached(entry);
+
// Check transaction entries (corresponding tx entries must be enlisted in transaction).
cand = new GridCacheMvccCandidate(entry,
cctx.localNodeId(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/4d29cb7f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index e8e86e9..89c4029 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -17,8 +17,6 @@
package org.apache.ignite.internal.processors.cache;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,6 +36,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import javax.cache.Cache;
+import javax.cache.CacheException;
import javax.cache.expiry.Duration;
import javax.cache.expiry.ExpiryPolicy;
import javax.cache.expiry.TouchedExpiryPolicy;
@@ -45,6 +44,8 @@ import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.EntryProcessorResult;
import javax.cache.processor.MutableEntry;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
import junit.framework.AssertionFailedError;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
@@ -5128,6 +5129,43 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
/**
+ * @throws Exception If failed.
+ */
+ public void testLockInsideTransaction() throws Exception {
+ if (txEnabled()) {
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (Transaction tx = ignite(0).transactions().txStart()) {
+ jcache(0).lock("key").lock();
+ }
+
+ return null;
+ }
+ },
+ CacheException.class,
+ "Explicit lock can't be acquired within a transaction."
+ );
+
+ GridTestUtils.assertThrows(
+ log,
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try (Transaction tx = ignite(0).transactions().txStart()) {
+ jcache(0).lockAll(Arrays.asList("key1", "key2")).lock();
+ }
+
+ return null;
+ }
+ },
+ CacheException.class,
+ "Explicit lock can't be acquired within a transaction."
+ );
+ }
+ }
+
+ /**
* Sets given value, returns old value.
*/
public static final class SetValueProcessor implements EntryProcessor<String, Integer, Integer> {
[2/3] ignite git commit: Better exception message if Ignite is not
started
Posted by sb...@apache.org.
Better exception message if Ignite is not started
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dafad526
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dafad526
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dafad526
Branch: refs/heads/ignite-sql-cache-stmt
Commit: dafad526f84ecbf503135c7538ffef07dd5e1c4f
Parents: 4d29cb7
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Nov 24 16:34:37 2015 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Nov 24 16:34:37 2015 -0800
----------------------------------------------------------------------
.../main/java/org/apache/ignite/internal/IgnitionEx.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dafad526/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 7d2b2dc..6bd74be 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1187,8 +1187,8 @@ public class IgnitionEx {
Ignite res;
if (grid == null || (res = grid.grid()) == null)
- throw new IgniteIllegalStateException("Grid instance was not properly started " +
- "or was already stopped: " + name);
+ throw new IgniteIllegalStateException("Ignite instance with provided name doesn't exist. " +
+ "Did you call Ignition.start(..) to start an Ignite instance? [name=" + name + ']');
return res;
}
@@ -1205,7 +1205,8 @@ public class IgnitionEx {
IgniteKernal res;
if (grid == null || (res = grid.gridx()) == null)
- throw new IllegalStateException("Grid instance was not properly started or was already stopped: " + name);
+ throw new IgniteIllegalStateException("Ignite instance with provided name doesn't exist. " +
+ "Did you call Ignition.start(..) to start an Ignite instance? [name=" + name + ']');
return res;
}
@@ -2388,4 +2389,4 @@ public class IgnitionEx {
}
}
}
-}
\ No newline at end of file
+}
[3/3] ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-1.5' into ignite-sql-cache-stmt
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-1.5' into ignite-sql-cache-stmt
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1171b36b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1171b36b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1171b36b
Branch: refs/heads/ignite-sql-cache-stmt
Commit: 1171b36b44a7ae8838d71fa7896d1526b485fa65
Parents: 1213f2c dafad52
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 25 08:48:37 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Nov 25 08:48:37 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/IgnitionEx.java | 9 +++--
.../processors/cache/CacheLockImpl.java | 18 ++++++++-
.../colocated/GridDhtColocatedLockFuture.java | 8 ++--
.../cache/GridCacheAbstractFullApiSelfTest.java | 42 +++++++++++++++++++-
4 files changed, 66 insertions(+), 11 deletions(-)
----------------------------------------------------------------------