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/06/11 17:13:54 UTC
[1/2] incubator-ignite git commit: #sberb-28: Change check for exists
locks.
Repository: incubator-ignite
Updated Branches:
refs/heads/sberb-28 9e949c83b -> dd52e01b0
#sberb-28: Change check for exists locks.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a610c30f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a610c30f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a610c30f
Branch: refs/heads/sberb-28
Commit: a610c30fa540202b6ba9e43213fd37c92ffe6983
Parents: 9e949c8
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 11 18:03:43 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 11 18:03:43 2015 +0300
----------------------------------------------------------------------
.../internal/processors/cache/GridCacheMvccManager.java | 7 -------
.../ignite/internal/processors/cache/GridCacheProcessor.java | 3 ++-
2 files changed, 2 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a610c30f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index bd48f5e..c528e08 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -572,13 +572,6 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
}
/**
- * @return True if any locks acquired.
- */
- public boolean hasLocks() {
- return !locked.isEmpty() || !nearLocked.isEmpty();
- }
-
- /**
* This method has poor performance, so use with care. It is currently only used by {@code DGC}.
*
* @return Remote candidates.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a610c30f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 6c320ae..f7f27ab 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -2962,7 +2962,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (transactions().tx() != null)
throw new IgniteException("Cannot start/stop cache within transaction.");
- if (ctx.cache().context().mvcc().hasLocks())
+ if (ctx.cache().context().mvcc().
+ lastExplicitLockTopologyVersion(Thread.currentThread().getId()) != null)
throw new IgniteException("Cannot start/stop cache within lock.");
}
[2/2] incubator-ignite git commit: #sberb-28: Add tests
Posted by sb...@apache.org.
#sberb-28: Add tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/dd52e01b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/dd52e01b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/dd52e01b
Branch: refs/heads/sberb-28
Commit: dd52e01b07bcd31d0ca94c32d3c85ed3f3c24374
Parents: a610c30
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 11 18:13:47 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 11 18:13:47 2015 +0300
----------------------------------------------------------------------
...teStartCacheInTransactionAtomicSelfTest.java | 32 +++++
.../IgniteStartCacheInTransactionSelfTest.java | 126 ++++++++++++++++++-
.../testsuites/IgniteCacheTestSuite4.java | 1 +
3 files changed, 158 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dd52e01b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionAtomicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionAtomicSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionAtomicSelfTest.java
new file mode 100644
index 0000000..17320eb
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionAtomicSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+
+/**
+ * Check starting cache in transaction.
+ */
+public class IgniteStartCacheInTransactionAtomicSelfTest extends IgniteStartCacheInTransactionSelfTest {
+ /** {@inheritDoc} */
+ @Override public CacheAtomicityMode atomicityMode() {
+ return ATOMIC;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dd52e01b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java
index 815b4b9..fb0bee2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteStartCacheInTransactionSelfTest.java
@@ -27,6 +27,8 @@ import org.apache.ignite.transactions.*;
import java.util.concurrent.*;
import java.util.concurrent.locks.*;
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+
/**
* Check starting cache in transaction.
*/
@@ -37,7 +39,7 @@ public class IgniteStartCacheInTransactionSelfTest extends GridCommonAbstractTes
CacheConfiguration ccfg = new CacheConfiguration();
- ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+ ccfg.setAtomicityMode(atomicityMode());
ccfg.setBackups(1);
cfg.setCacheConfiguration(ccfg);
@@ -45,6 +47,25 @@ public class IgniteStartCacheInTransactionSelfTest extends GridCommonAbstractTes
return cfg;
}
+ /**
+ * @return Cache atomicity mode.
+ */
+ public CacheAtomicityMode atomicityMode() {
+ return TRANSACTIONAL;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ * @return Cache configuration.
+ */
+ public CacheConfiguration cacheConfiguration(String cacheName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setName(cacheName);
+
+ return cfg;
+ }
+
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
startGrids(2);
@@ -83,6 +104,106 @@ public class IgniteStartCacheInTransactionSelfTest extends GridCommonAbstractTes
/**
* @throws Exception If failed.
*/
+ public void testStartConfigurationCache() throws Exception {
+ final Ignite ignite = grid(0);
+
+ final String key = "key";
+ final String val = "val";
+
+ try (Transaction tx = ignite.transactions().txStart(
+ TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)){
+ ignite.cache(null).put(key, val);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ ignite.createCache(cacheConfiguration("NEW_CACHE"));
+
+ return null;
+ }
+ }, IgniteException.class, "Cannot start/stop cache within transaction.");
+
+ tx.commit();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStartConfigurationCacheWithNear() throws Exception {
+ final Ignite ignite = grid(0);
+
+ final String key = "key";
+ final String val = "val";
+
+ try (Transaction tx = ignite.transactions().txStart(
+ TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)){
+ ignite.cache(null).put(key, val);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ ignite.createCache(cacheConfiguration("NEW_CACHE"), new NearCacheConfiguration());
+
+ return null;
+ }
+ }, IgniteException.class, "Cannot start/stop cache within transaction.");
+
+ tx.commit();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetOrCreateCache() throws Exception {
+ final Ignite ignite = grid(0);
+
+ final String key = "key";
+ final String val = "val";
+
+ try (Transaction tx = ignite.transactions().txStart(
+ TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)){
+ ignite.cache(null).put(key, val);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ ignite.getOrCreateCache("NEW_CACHE");
+
+ return null;
+ }
+ }, IgniteException.class, "Cannot start/stop cache within transaction.");
+
+ tx.commit();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetOrCreateCacheConfiguration() throws Exception {
+ final Ignite ignite = grid(0);
+
+ final String key = "key";
+ final String val = "val";
+
+ try (Transaction tx = ignite.transactions().txStart(
+ TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ)){
+ ignite.cache(null).put(key, val);
+
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ ignite.getOrCreateCache(cacheConfiguration("NEW_CACHE"));
+
+ return null;
+ }
+ }, IgniteException.class, "Cannot start/stop cache within transaction.");
+
+ tx.commit();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testStopCache() throws Exception {
final Ignite ignite = grid(0);
@@ -109,6 +230,9 @@ public class IgniteStartCacheInTransactionSelfTest extends GridCommonAbstractTes
* @throws Exception If failed.
*/
public void testLockCache() throws Exception {
+ if (atomicityMode() != TRANSACTIONAL)
+ return;
+
final Ignite ignite = grid(0);
final String key = "key";
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dd52e01b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 2cbb00d..7ed95cf 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -141,6 +141,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(IgniteCacheManyClientsTest.class);
suite.addTestSuite(IgniteStartCacheInTransactionSelfTest.class);
+ suite.addTestSuite(IgniteStartCacheInTransactionAtomicSelfTest.class);
return suite;
}