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/01/15 15:42:58 UTC
[1/5] incubator-ignite git commit: # ignite-42
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-42 806ce6a36 -> 4b8ec5f23
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
index 9e3559a..cb641c4 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
@@ -18,12 +18,12 @@
package org.gridgain.grid.kernal.processors.cache.distributed;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -139,8 +139,8 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid
*
* @return Write through storage emulator.
*/
- protected GridCacheStore<?, ?> cacheStore() {
- return new GridCacheStoreAdapter<Integer, String>() {
+ protected CacheStore<?, ?> cacheStore() {
+ return new CacheStoreAdapter<Integer, String>() {
@IgniteInstanceResource
private Ignite g;
@@ -152,17 +152,17 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends Grid
c.apply(e.getKey(), e.getValue());
}
- @Override public String load(IgniteTx tx, Integer key) {
+ @Override public String load(Integer key) {
X.println("Loading on: " + caches.indexOf(g.<Integer, String>cache(null)) + " key=" + key);
return map.get(key);
}
- @Override public void put(IgniteTx tx, Integer key, @Nullable String val) {
+ @Override public void put(Integer key, @Nullable String val) {
fail("Should not be called within the test.");
}
- @Override public void remove(IgniteTx tx, Integer key) {
+ @Override public void remove(Integer key) {
fail("Should not be called within the test.");
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
index 6f81490..7ce762c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
@@ -18,12 +18,12 @@
package org.gridgain.grid.kernal.processors.cache.distributed.dht;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.affinity.consistenthash.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.apache.ignite.spi.discovery.tcp.*;
@@ -761,7 +761,7 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
private void checkStore(Ignite ignite, Map<Integer, String> map) throws Exception {
- GridCacheStore store = ignite.configuration().getCacheConfiguration()[0].getStore();
+ CacheStore store = ignite.configuration().getCacheConfiguration()[0].getStore();
assertEquals(map, ((GridCacheTestStore)store).getMap());
}
@@ -773,7 +773,7 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest {
*/
private void clearStores(int cnt) {
for (int i = 0; i < cnt; i++) {
- GridCacheStore store = grid(i).configuration().getCacheConfiguration()[0].getStore();
+ CacheStore store = grid(i).configuration().getCacheConfiguration()[0].getStore();
((GridCacheTestStore)store).reset();
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
index 6027986..6a781cf 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java
@@ -10,12 +10,11 @@
package org.gridgain.grid.kernal.processors.cache.distributed.dht;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.jdk8.backport.*;
import org.jetbrains.annotations.*;
import org.junit.*;
@@ -114,21 +113,21 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
}
/** {@inheritDoc} */
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return new TestStore();
}
/**
* Test store.
*/
- private static class TestStore extends GridCacheStoreAdapter<Integer, Integer> {
+ private static class TestStore extends CacheStoreAdapter<Integer, Integer> {
/** */
@IgniteInstanceResource
private Ignite ignite;
/** {@inheritDoc} */
@Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo,
- @Nullable Object... args) throws IgniteCheckedException {
+ @Nullable Object... args) {
assertNotNull(ignite);
assertNotNull(clo);
assertNotNull(map);
@@ -144,19 +143,19 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest {
}
/** {@inheritDoc} */
- @Override public Integer load(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public Integer load(Integer key) {
assertEquals((Integer)5, key);
return null;
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Integer key, Integer val) throws IgniteCheckedException {
+ @Override public void put(Integer key, Integer val) {
fail();
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public void remove(Integer key) {
fail();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java
index f351d97..3865b44 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheGetStoreErrorSelfTest.java
@@ -18,13 +18,12 @@
package org.gridgain.grid.kernal.processors.cache.distributed.near;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
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.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.testframework.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
@@ -65,18 +64,16 @@ public class GridCacheGetStoreErrorSelfTest extends GridCommonAbstractTest {
cc.setDistributionMode(nearEnabled ? NEAR_PARTITIONED : PARTITIONED_ONLY);
cc.setAtomicityMode(TRANSACTIONAL);
- cc.setStore(new GridCacheStoreAdapter<Object, Object>() {
- @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
- throw new IgniteCheckedException("Failed to get key from store: " + key);
+ cc.setStore(new CacheStoreAdapter<Object, Object>() {
+ @Override public Object load(Object key) {
+ throw new IgniteException("Failed to get key from store: " + key);
}
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) {
+ @Override public void put(Object key,@Nullable Object val) {
// No-op.
}
- @Override public void remove(@Nullable IgniteTx tx, Object key) {
+ @Override public void remove(Object key) {
// No-op.
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
index 2145a30..7d97169 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
@@ -18,12 +18,12 @@
package org.gridgain.grid.kernal.processors.cache.distributed.near;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.distributed.*;
import org.gridgain.grid.kernal.processors.cache.distributed.dht.*;
@@ -891,7 +891,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
/**
*
*/
- private static class TestStore extends GridCacheStoreAdapter<Integer, String> {
+ private static class TestStore extends CacheStoreAdapter<Integer, String> {
/** Map. */
private ConcurrentMap<Integer, String> map = new ConcurrentHashMap<>();
@@ -939,7 +939,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public String load(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public String load(Integer key) {
if (!create)
return map.get(key);
@@ -949,13 +949,12 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Integer key, @Nullable String val)
- throws IgniteCheckedException {
+ @Override public void put(Integer key, @Nullable String val) {
map.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public void remove(Integer key) {
map.remove(key);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
index be64e75..c97ae6b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
@@ -18,12 +18,12 @@
package org.gridgain.grid.kernal.processors.cache.distributed.near;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
@@ -311,7 +311,7 @@ public class GridCacheNearOneNodeSelfTest extends GridCommonAbstractTest {
/**
*
*/
- private static class TestStore extends GridCacheStoreAdapter<Integer, String> {
+ private static class TestStore extends CacheStoreAdapter<Integer, String> {
/** Map. */
private ConcurrentMap<Integer, String> map = new ConcurrentHashMap<>();
@@ -359,7 +359,7 @@ public class GridCacheNearOneNodeSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public String load(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public String load(Integer key) {
if (!create)
return map.get(key);
@@ -369,13 +369,12 @@ public class GridCacheNearOneNodeSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Integer key, @Nullable String val)
- throws IgniteCheckedException {
+ @Override public void put(Integer key, @Nullable String val) {
map.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public void remove(Integer key) {
map.remove(key);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
index d86cc95..98e741a 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
@@ -18,13 +18,13 @@
package org.gridgain.grid.kernal.processors.cache.distributed.near;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
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.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.testframework.junits.common.*;
@@ -50,7 +50,7 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes
private static final String CACHE_NAME = "cache";
/** */
- private static GridCacheStore<Object, Object> store = new GridCacheGenericTestStore<>();
+ private static CacheStore<Object, Object> store = new GridCacheGenericTestStore<>();
/** Shared IP finder. */
private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
index 3197890..4ffc87a 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache.distributed.near;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.spi.discovery.tcp.*;
@@ -26,7 +27,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
@@ -115,10 +115,9 @@ public class GridCachePartitionedLoadCacheSelfTest extends GridCommonAbstractTes
/**
* Test store.
*/
- private static class TestStore extends GridCacheStoreAdapter<Integer, String> {
+ private static class TestStore extends CacheStoreAdapter<Integer, String> {
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Integer, String> clo,
- @Nullable Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Integer, String> clo, @Nullable Object... args) {
assert clo != null;
assert args != null;
@@ -131,19 +130,19 @@ public class GridCachePartitionedLoadCacheSelfTest extends GridCommonAbstractTes
}
/** {@inheritDoc} */
- @Override public String load(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public String load(Integer key) {
// No-op.
return null;
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Integer key, String val) throws IgniteCheckedException {
+ @Override public void put(Integer key, String val) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public void remove(Integer key) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
index 3fdd09c..eaddb3d 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache.distributed.near;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.spi.discovery.*;
import org.apache.ignite.spi.discovery.tcp.*;
@@ -25,7 +26,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.processors.cache.distributed.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.testframework.junits.common.*;
@@ -124,23 +124,21 @@ public class GridCachePartitionedStorePutSelfTest extends GridCommonAbstractTest
/**
* Test store.
*/
- private static class TestStore extends GridCacheStoreAdapter<Object, Object> {
+ private static class TestStore extends CacheStoreAdapter<Object, Object> {
/** {@inheritDoc} */
- @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public Object load(Object key) {
assert false;
return null;
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Object key, @Nullable Object val)
- throws IgniteCheckedException {
+ @Override public void put(Object key, @Nullable Object val) {
// No-op
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Object key) throws IgniteCheckedException {
+ @Override public void remove(Object key) {
// No-op
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
index a32c529..00ee06f 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridPartitionedBackupLoadSelfTest.java
@@ -17,15 +17,13 @@
package org.gridgain.grid.kernal.processors.cache.distributed.near;
-import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.spi.discovery.*;
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.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
@@ -130,26 +128,24 @@ public class GridPartitionedBackupLoadSelfTest extends GridCommonAbstractTest {
/**
* Test store.
*/
- private class TestStore extends GridCacheStoreAdapter<Integer, Integer> {
+ private class TestStore extends CacheStoreAdapter<Integer, Integer> {
/** */
private Map<Integer, Integer> map = new ConcurrentHashMap<>();
/** {@inheritDoc} */
- @Override public Integer load(@Nullable IgniteTx tx, Integer key)
- throws IgniteCheckedException {
+ @Override public Integer load(Integer key) {
cnt.incrementAndGet();
return null;
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Integer key, @Nullable Integer val)
- throws IgniteCheckedException {
+ @Override public void put(Integer key, @Nullable Integer val) {
map.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public void remove(Integer key) {
// No-op
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheBatchEvictUnswapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheBatchEvictUnswapSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheBatchEvictUnswapSelfTest.java
index 4cc67a5..a318440 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheBatchEvictUnswapSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheBatchEvictUnswapSelfTest.java
@@ -18,11 +18,11 @@
package org.gridgain.grid.kernal.processors.cache.eviction;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.eviction.fifo.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.jetbrains.annotations.*;
@@ -64,8 +64,8 @@ public class GridCacheBatchEvictUnswapSelfTest extends GridCacheAbstractSelfTest
GridCacheConfiguration cacheCfg = super.cacheConfiguration(gridName);
cacheCfg.setCacheMode(GridCacheMode.PARTITIONED);
- cacheCfg.setStore(new GridCacheStoreAdapter<Long, String>() {
- @Nullable @Override public String load(@Nullable IgniteTx tx, Long key) {
+ cacheCfg.setStore(new CacheStoreAdapter<Long, String>() {
+ @Nullable @Override public String load(Long key) {
return null;
}
@@ -75,11 +75,12 @@ public class GridCacheBatchEvictUnswapSelfTest extends GridCacheAbstractSelfTest
c.apply((long)i, String.valueOf(i));
}
- @Override public void put(@Nullable IgniteTx tx, Long key,
- @Nullable String val) {
+ @Override public void put(Long key, @Nullable String val) {
+ // No-op.
}
- @Override public void remove(@Nullable IgniteTx tx, Long key) {
+ @Override public void remove(Long key) {
+ // No-op.
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
index ab7c5be..6680b00 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEmptyEntriesAbstractSelfTest.java
@@ -18,14 +18,14 @@
package org.gridgain.grid.kernal.processors.cache.eviction;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.eviction.GridCacheEvictionPolicy;
import org.gridgain.grid.cache.eviction.fifo.GridCacheFifoEvictionPolicy;
-import org.gridgain.grid.cache.store.GridCacheStore;
-import org.gridgain.grid.cache.store.GridCacheStoreAdapter;
+import org.apache.ignite.cache.store.CacheStore;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -50,7 +50,7 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb
private GridCacheEvictionPolicy<?, ?> nearPlc;
/** Test store. */
- private GridCacheStore<String, String> testStore;
+ private CacheStore<String, String> testStore;
/** Tx concurrency to use. */
private IgniteTxConcurrency txConcurrency;
@@ -131,17 +131,16 @@ public abstract class GridCacheEmptyEntriesAbstractSelfTest extends GridCommonAb
checkPolicy0();
- testStore = new GridCacheStoreAdapter<String, String>() {
- @Override public String load(@Nullable IgniteTx tx, String key) {
+ testStore = new CacheStoreAdapter<String, String>() {
+ @Override public String load(String key) {
return null;
}
- @Override public void put(@Nullable IgniteTx tx, String key,
- @Nullable String val) {
+ @Override public void put(String key, @Nullable String val) {
// No-op.
}
- @Override public void remove(@Nullable IgniteTx tx, String key) {
+ @Override public void remove(String key) {
// No-op.
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java
index 3188326..a1b3aad 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/eviction/GridCacheEvictionTouchSelfTest.java
@@ -69,14 +69,17 @@ public class GridCacheEvictionTouchSelfTest extends GridCommonAbstractTest {
cc.setEvictionPolicy(plc);
cc.setStore(new GridCacheGenericTestStore<Object, Object>() {
- @Override public Object load(IgniteTx tx, Object key) {
+ @Override public Object load(Object key) {
return key;
}
- @Override public void loadAll(IgniteTx tx, Collection<?> keys,
- IgniteBiInClosure<Object, Object> c) {
+ @Override public Map<Object, Object> loadAll(Iterable<?> keys) {
+ Map<Object, Object> loaded = new HashMap<>();
+
for (Object key : keys)
- c.apply(key, key);
+ loaded.put(key, key);
+
+ return loaded;
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
index 28ce0f7..d9bd74b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheAtomicLocalMetricsNoStoreSelfTest.java
@@ -17,13 +17,13 @@
package org.gridgain.grid.kernal.processors.cache.local;
-import org.gridgain.grid.cache.store.*;
+import org.apache.ignite.cache.store.*;
/**
* Local atomic cache metrics test.
*/
public class GridCacheAtomicLocalMetricsNoStoreSelfTest extends GridCacheAtomicLocalMetricsSelfTest {
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return null; // Test cache without store.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java
index 4a122ee..90af785 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalLoadAllSelfTest.java
@@ -18,11 +18,10 @@
package org.gridgain.grid.kernal.processors.cache.local;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
-import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.gridgain.testframework.junits.common.*;
@@ -78,11 +77,11 @@ public class GridCacheLocalLoadAllSelfTest extends GridCommonAbstractTest {
/**
*
*/
- private static class TestStore extends GridCacheStoreAdapter<Integer, Integer> {
+ private static class TestStore extends CacheStoreAdapter<Integer, Integer> {
/** {@inheritDoc} */
@SuppressWarnings({"TypeParameterExtendsFinalClass"})
- @Override public void loadAll(IgniteTx tx, Collection<? extends Integer> keys,
- IgniteBiInClosure<Integer, Integer> c) throws IgniteCheckedException {
+ @Override public void loadAll(Collection<? extends Integer> keys,
+ IgniteBiInClosure<Integer, Integer> c) {
assert keys != null;
c.apply(1, 1);
@@ -91,19 +90,19 @@ public class GridCacheLocalLoadAllSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public Integer load(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public Integer load(Integer key) {
// No-op.
return null;
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Integer key, Integer val) throws IgniteCheckedException {
+ @Override public void put(Integer key, Integer val) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public void remove(Integer key) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
index 0c08a3d..0f78df1 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache.query.continuous;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.events.*;
@@ -27,7 +28,6 @@ import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.query.*;
import org.gridgain.grid.cache.query.GridCacheContinuousQueryEntry;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.continuous.*;
import org.apache.ignite.spi.discovery.tcp.*;
@@ -1506,29 +1506,26 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
/**
* Store.
*/
- private static class TestStore extends GridCacheStoreAdapter<Object, Object> {
+ private static class TestStore extends CacheStoreAdapter<Object, Object> {
/** {@inheritDoc} */
@Override public void loadCache(IgniteBiInClosure<Object, Object> clo,
- Object... args) throws IgniteCheckedException {
+ Object... args) {
for (int i = 0; i < 10; i++)
clo.apply(i, i);
}
/** {@inheritDoc} */
- @Nullable @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Nullable @Override public Object load(Object key) {
return null;
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) throws IgniteCheckedException {
+ @Override public void put(Object key, @Nullable Object val) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public void remove(Object key) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java
index 813d3da..6fb07ab 100644
--- a/modules/core/src/test/java/org/gridgain/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java
+++ b/modules/core/src/test/java/org/gridgain/loadtests/cache/GridCacheWriteBehindStoreLoadTest.java
@@ -18,13 +18,13 @@
package org.gridgain.loadtests.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
@@ -54,20 +54,19 @@ public class GridCacheWriteBehindStoreLoadTest extends GridCommonAbstractTest {
private int threadCnt;
/** No-op cache store. */
- private static final GridCacheStore store = new GridCacheStoreAdapter() {
+ private static final CacheStore store = new CacheStoreAdapter() {
/** {@inheritDoc} */
- @Override public Object load(@Nullable IgniteTx tx, Object key) {
+ @Override public Object load(Object key) {
return null;
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) {
+ @Override public void put(Object key, @Nullable Object val) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key) {
+ @Override public void remove(Object key) {
// No-op.
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/loadtests/colocation/GridTestCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/loadtests/colocation/GridTestCacheStore.java b/modules/core/src/test/java/org/gridgain/loadtests/colocation/GridTestCacheStore.java
index 53a8127..2ad9704 100644
--- a/modules/core/src/test/java/org/gridgain/loadtests/colocation/GridTestCacheStore.java
+++ b/modules/core/src/test/java/org/gridgain/loadtests/colocation/GridTestCacheStore.java
@@ -18,22 +18,25 @@
package org.gridgain.loadtests.colocation;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.jdk8.backport.*;
+import javax.cache.integration.*;
import java.util.concurrent.*;
/**
* Accenture cache store.
*/
-public class GridTestCacheStore extends GridCacheStoreAdapter<GridTestKey, Long> {
+public class GridTestCacheStore extends CacheStoreAdapter<GridTestKey, Long> {
+ /** */
@IgniteInstanceResource
private Ignite ignite;
+ /** */
@IgniteLoggerResource
private IgniteLogger log;
@@ -42,10 +45,8 @@ public class GridTestCacheStore extends GridCacheStoreAdapter<GridTestKey, Long>
*
* @param clo Callback for every key.
* @param args Optional arguments.
- * @throws IgniteCheckedException If failed.
*/
- @Override public void loadCache(final IgniteBiInClosure<GridTestKey, Long> clo,
- Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(final IgniteBiInClosure<GridTestKey, Long> clo, Object... args) {
// Number of threads is passed in as argument by caller.
final int numThreads = (Integer)args[0];
int entryCnt = (Integer)args[1];
@@ -104,7 +105,7 @@ public class GridTestCacheStore extends GridCacheStoreAdapter<GridTestKey, Long>
completeSvc.take().get();
}
catch (InterruptedException | ExecutionException e) {
- throw new IgniteCheckedException(e);
+ throw new CacheLoaderException(e);
}
}
@@ -116,15 +117,18 @@ public class GridTestCacheStore extends GridCacheStoreAdapter<GridTestKey, Long>
}
}
- @Override public Long load(IgniteTx tx, GridTestKey key) throws IgniteCheckedException {
+ /** {@inheritDoc} */
+ @Override public Long load(GridTestKey key) {
return null; // No-op.
}
- @Override public void put(IgniteTx tx, GridTestKey key, Long val) throws IgniteCheckedException {
+ /** {@inheritDoc} */
+ @Override public void put(GridTestKey key, Long val) {
// No-op.
}
- @Override public void remove(IgniteTx tx, GridTestKey key) throws IgniteCheckedException {
+ /** {@inheritDoc} */
+ @Override public void remove(GridTestKey key) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java b/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java
index 2613587..a06df0a 100644
--- a/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java
+++ b/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java
@@ -18,12 +18,12 @@
package org.gridgain.loadtests.swap;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.eviction.fifo.*;
-import org.gridgain.grid.cache.store.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -62,8 +62,8 @@ public class GridSwapEvictAllBenchmark {
try {
String outputFileName = args.length > 0 ? args[0] : null;
- Ignite g = start(new GridCacheStoreAdapter<Long, String>() {
- @Nullable @Override public String load(@Nullable IgniteTx tx, Long key) {
+ Ignite g = start(new CacheStoreAdapter<Long, String>() {
+ @Nullable @Override public String load(Long key) {
return null;
}
@@ -73,12 +73,11 @@ public class GridSwapEvictAllBenchmark {
c.apply((long)i, String.valueOf(i));
}
- @Override public void put(@Nullable IgniteTx tx, Long key,
- @Nullable String val) {
+ @Override public void put(Long key, @Nullable String val) {
assert false;
}
- @Override public void remove(@Nullable IgniteTx tx, Long key) {
+ @Override public void remove(Long key) {
assert false;
}
});
@@ -248,7 +247,7 @@ public class GridSwapEvictAllBenchmark {
* @return Started grid.
* @throws IgniteCheckedException If failed.
*/
- private static Ignite start(GridCacheStore<Long, String> store) throws IgniteCheckedException {
+ private static Ignite start(CacheStore<Long, String> store) throws IgniteCheckedException {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setLocalHost("127.0.0.1");
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/testframework/junits/GridTestResources.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/GridTestResources.java b/modules/core/src/test/java/org/gridgain/testframework/junits/GridTestResources.java
index 9956056..41c3f6a 100644
--- a/modules/core/src/test/java/org/gridgain/testframework/junits/GridTestResources.java
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/GridTestResources.java
@@ -123,6 +123,13 @@ public class GridTestResources {
}
/**
+ * @return Resource processor.
+ */
+ public GridResourceProcessor resources() {
+ return rsrcProc;
+ }
+
+ /**
* @return Local host.
*/
@Nullable private String localHost() {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java b/modules/core/src/test/java/org/gridgain/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
index de36bb4..657dfae 100644
--- a/modules/core/src/test/java/org/gridgain/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/cache/GridAbstractCacheStoreSelfTest.java
@@ -18,9 +18,10 @@
package org.gridgain.testframework.junits.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.util.lang.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
@@ -34,11 +35,14 @@ import java.util.concurrent.atomic.*;
/**
* Abstract cache store test.
*/
-public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Object, Object>>
+public abstract class GridAbstractCacheStoreSelfTest<T extends CacheStore<Object, Object>>
extends GridCommonAbstractTest {
/** */
protected final T store;
+ /** */
+ protected TestThreadLocalCacheSession ses = new TestThreadLocalCacheSession();
+
/**
* @throws Exception If failed.
*/
@@ -58,22 +62,30 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
// Create dummy transaction
IgniteTx tx = new DummyTx();
- store.put(tx, "k1", "v1");
- store.put(tx, "k2", "v2");
+ ses.newSession(tx);
+
+ store.put("k1", "v1");
+ store.put("k2", "v2");
+
+ store.txEnd(true);
+
+ ses.newSession(null);
+
+ assertEquals("v1", store.load("k1"));
+ assertEquals("v2", store.load("k2"));
+ assertNull(store.load("k3"));
- store.txEnd(tx, true);
+ ses.newSession(tx);
- assertEquals("v1", store.load(null, "k1"));
- assertEquals("v2", store.load(null, "k2"));
- assertNull(store.load( null, "k3"));
+ store.remove("k1");
- store.remove(tx, "k1");
+ store.txEnd(true);
- store.txEnd(tx, true);
+ ses.newSession(null);
- assertNull(store.load(null, "k1"));
- assertEquals("v2", store.load(null, "k2"));
- assertNull(store.load(null, "k3"));
+ assertNull(store.load("k1"));
+ assertEquals("v2", store.load("k2"));
+ assertNull(store.load("k3"));
}
/**
@@ -82,61 +94,75 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
public void testRollback() throws IgniteCheckedException {
IgniteTx tx = new DummyTx();
+ ses.newSession(tx);
+
// Put.
- store.put(tx, "k1", "v1");
+ store.put("k1", "v1");
- store.txEnd(tx, false); // Rollback.
+ store.txEnd(false); // Rollback.
tx = new DummyTx();
- assertNull(store.load(tx, "k1"));
+ ses.newSession(tx);
+
+ assertNull(store.load("k1"));
// Put all.
- assertNull(store.load(tx, "k2"));
+ assertNull(store.load("k2"));
- store.putAll(tx, Collections.singletonMap("k2", "v2"));
+ store.putAll(Collections.singletonMap("k2", "v2"));
- store.txEnd(tx, false); // Rollback.
+ store.txEnd(false); // Rollback.
tx = new DummyTx();
- assertNull(store.load(tx, "k2"));
+ ses.newSession(tx);
+
+ assertNull(store.load("k2"));
- store.putAll(tx, Collections.singletonMap("k3", "v3"));
+ store.putAll(Collections.singletonMap("k3", "v3"));
- store.txEnd(tx, true); // Commit.
+ store.txEnd(true); // Commit.
tx = new DummyTx();
- assertEquals("v3", store.load(tx, "k3"));
+ ses.newSession(tx);
- store.put(tx, "k4", "v4");
+ assertEquals("v3", store.load("k3"));
- store.txEnd(tx, false); // Rollback.
+ store.put("k4", "v4");
+
+ store.txEnd(false); // Rollback.
tx = new DummyTx();
- assertNull(store.load(tx, "k4"));
+ ses.newSession(tx);
+
+ assertNull(store.load("k4"));
- assertEquals("v3", store.load(tx, "k3"));
+ assertEquals("v3", store.load("k3"));
// Remove.
- store.remove(tx, "k3");
+ store.remove("k3");
- store.txEnd(tx, false); // Rollback.
+ store.txEnd(false); // Rollback.
tx = new DummyTx();
- assertEquals("v3", store.load(tx, "k3"));
+ ses.newSession(tx);
+
+ assertEquals("v3", store.load("k3"));
// Remove all.
- store.removeAll(tx, Arrays.asList("k3"));
+ store.removeAll(Arrays.asList("k3"));
- store.txEnd(tx, false); // Rollback.
+ store.txEnd(false); // Rollback.
tx = new DummyTx();
- assertEquals("v3", store.load(tx, "k3"));
+ ses.newSession(tx);
+
+ assertEquals("v3", store.load("k3"));
}
/**
@@ -167,26 +193,30 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
*/
private void doTestAllOps(@Nullable IgniteTx tx, boolean commit) throws IgniteCheckedException {
try {
- store.put(tx, "key1", "val1");
+ ses.newSession(tx);
+
+ store.put("key1", "val1");
if (tx != null && commit) {
- store.txEnd(tx, true);
+ store.txEnd(true);
tx = new DummyTx();
+
+ ses.newSession(tx);
}
if (tx == null || commit)
- assertEquals("val1", store.load(tx, "key1"));
+ assertEquals("val1", store.load("key1"));
Map<String, String> m = new HashMap<>();
m.put("key2", "val2");
m.put("key3", "val3");
- store.putAll(tx, m);
+ store.putAll(m);
if (tx != null && commit) {
- store.txEnd(tx, true);
+ store.txEnd(true);
tx = new DummyTx();
}
@@ -194,7 +224,7 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
final AtomicInteger cntr = new AtomicInteger();
if (tx == null || commit) {
- store.loadAll(tx, Arrays.asList("key1", "key2", "key3", "no_such_key"), new CI2<Object, Object>() {
+ store.loadAll(Arrays.asList("key1", "key2", "key3", "no_such_key"), new CI2<Object, Object>() {
@Override public void apply(Object o, Object o1) {
if ("key1".equals(o))
assertEquals("val1", o1);
@@ -215,35 +245,41 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
assertEquals(3, cntr.get());
}
- store.removeAll(tx, Arrays.asList("key2", "key3"));
+ store.removeAll(Arrays.asList("key2", "key3"));
if (tx != null && commit) {
- store.txEnd(tx, true);
+ store.txEnd(true);
tx = new DummyTx();
+
+ ses.newSession(tx);
}
if (tx == null || commit) {
- assertNull(store.load(tx, "key2"));
- assertNull(store.load(tx, "key3"));
- assertEquals("val1", store.load(tx, "key1"));
+ assertNull(store.load("key2"));
+ assertNull(store.load("key3"));
+ assertEquals("val1", store.load("key1"));
}
- store.remove(tx, "key1");
+ store.remove("key1");
if (tx != null && commit) {
- store.txEnd(tx, true);
+ store.txEnd(true);
tx = new DummyTx();
+
+ ses.newSession(tx);
}
if (tx == null || commit)
- assertNull(store.load(tx, "key1"));
-
+ assertNull(store.load("key1"));
}
finally {
- if (tx != null)
- store.txEnd(tx, false);
+ if (tx != null) {
+ store.txEnd(false);
+
+ ses.newSession(null);
+ }
}
}
@@ -256,11 +292,12 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
final LinkedBlockingQueue<UUID> queue = new LinkedBlockingQueue<>();
multithreaded(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
for (int i = 0; i < 1000; i++) {
IgniteTx tx = rnd.nextBoolean() ? new DummyTx() : null;
+ ses.newSession(tx);
+
int op = rnd.nextInt(10);
boolean queueEmpty = false;
@@ -272,13 +309,12 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
queueEmpty = true;
else {
if (rnd.nextBoolean())
- assertNotNull(store.load(tx, key));
+ assertNotNull(store.load(key));
else {
final AtomicInteger cntr = new AtomicInteger();
- store.loadAll(tx, Collections.singleton(key), new CI2<Object, Object>() {
- @Override
- public void apply(Object o, Object o1) {
+ store.loadAll(Collections.singleton(key), new CI2<Object, Object>() {
+ @Override public void apply(Object o, Object o1) {
cntr.incrementAndGet();
assertNotNull(o);
@@ -297,7 +333,7 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
}
if (tx != null)
- store.txEnd(tx, true);
+ store.txEnd(true);
queue.add(key);
}
@@ -309,12 +345,12 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
queueEmpty = true;
else {
if (rnd.nextBoolean())
- store.remove(tx, key);
+ store.remove(key);
else
- store.removeAll(tx, Collections.singleton(key));
+ store.removeAll(Collections.singleton(key));
if (tx != null)
- store.txEnd(tx, true);
+ store.txEnd(true);
}
}
else { // Update.
@@ -326,12 +362,12 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
UUID val = new UUID(key.getLeastSignificantBits(), key.getMostSignificantBits());
if (rnd.nextBoolean())
- store.put(tx, key, val);
+ store.put(key, val);
else
- store.putAll(tx, Collections.singletonMap(key, val));
+ store.putAll(Collections.singletonMap(key, val));
if (tx != null)
- store.txEnd(tx, true);
+ store.txEnd(true);
queue.add(key);
}
@@ -341,12 +377,12 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
UUID key = UUID.randomUUID();
if (rnd.nextBoolean())
- store.put(tx, key, key);
+ store.put(key, key);
else
- store.putAll(tx, Collections.singletonMap(key, key));
+ store.putAll(Collections.singletonMap(key, key));
if (tx != null)
- store.txEnd(tx, true);
+ store.txEnd(true);
queue.add(key);
}
@@ -363,6 +399,8 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
*/
protected void inject(T store) throws Exception {
getTestResources().inject(store);
+
+ getTestResources().resources().injectBasicResource(store, IgniteCacheSessionResource.class, ses);
}
/** {@inheritDoc} */
@@ -385,7 +423,9 @@ public abstract class GridAbstractCacheStoreSelfTest<T extends GridCacheStore<Ob
if (keys.isEmpty())
return;
- store.removeAll(null, keys);
+ ses.newSession(null);
+
+ store.removeAll(keys);
keys.clear();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestCacheSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestCacheSession.java b/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestCacheSession.java
new file mode 100644
index 0000000..9093ddb
--- /dev/null
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestCacheSession.java
@@ -0,0 +1,59 @@
+/*
+ * 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.gridgain.testframework.junits.cache;
+
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public class TestCacheSession implements CacheStoreSession {
+ /** */
+ private IgniteTx tx;
+
+ /** */
+ private Map<Object, Object> props;
+
+ /**
+ *
+ * @param tx Transaction.
+ */
+ public void newSession(@Nullable IgniteTx tx) {
+ this.tx = tx;
+
+ props = null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public IgniteTx transaction() {
+ return tx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<Object, Object> properties() {
+ if (props == null)
+ props = U.newHashMap(1);
+
+ return props;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestThreadLocalCacheSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestThreadLocalCacheSession.java b/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestThreadLocalCacheSession.java
new file mode 100644
index 0000000..efe0b24
--- /dev/null
+++ b/modules/core/src/test/java/org/gridgain/testframework/junits/cache/TestThreadLocalCacheSession.java
@@ -0,0 +1,57 @@
+/*
+ * 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.gridgain.testframework.junits.cache;
+
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public class TestThreadLocalCacheSession implements CacheStoreSession {
+ /** */
+ private final ThreadLocal<TestCacheSession> sesHolder = new ThreadLocal<>();
+
+ /**
+ * @param tx Transaction.
+ */
+ public void newSession(@Nullable IgniteTx tx) {
+ TestCacheSession ses = new TestCacheSession();
+
+ ses.newSession(tx);
+
+ sesHolder.set(ses);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public IgniteTx transaction() {
+ TestCacheSession ses = sesHolder.get();
+
+ return ses != null ? ses.transaction() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<Object, Object> properties() {
+ TestCacheSession ses = sesHolder.get();
+
+ return ses != null ? ses.properties() : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
index 3b2ed6c..ddfa0b1 100644
--- a/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
+++ b/modules/core/src/test/java/org/gridgain/testsuites/bamboo/GridDataGridTestSuite.java
@@ -23,7 +23,7 @@ import org.apache.ignite.internal.processors.cache.expiry.*;
import org.gridgain.grid.*;
import org.gridgain.grid.cache.affinity.fair.*;
import org.gridgain.grid.cache.store.*;
-import org.gridgain.grid.cache.store.jdbc.*;
+import org.apache.ignite.cache.store.jdbc.*;
import org.gridgain.grid.kernal.processors.cache.*;
import org.gridgain.grid.kernal.processors.cache.distributed.*;
import org.gridgain.grid.kernal.processors.cache.distributed.dht.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/hibernate/src/main/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStore.java b/modules/hibernate/src/main/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStore.java
index ce3b17c..a22cd42 100644
--- a/modules/hibernate/src/main/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStore.java
+++ b/modules/hibernate/src/main/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStore.java
@@ -18,10 +18,11 @@
package org.gridgain.grid.cache.store.hibernate;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.marshaller.*;
import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
+import org.gridgain.grid.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.grid.util.tostring.*;
@@ -29,6 +30,7 @@ import org.hibernate.*;
import org.hibernate.cfg.*;
import org.jetbrains.annotations.*;
+import javax.cache.integration.*;
import java.io.*;
import java.net.*;
import java.util.*;
@@ -36,7 +38,7 @@ import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
/**
- * {@link GridCacheStore} implementation backed by Hibernate. This implementation
+ * {@link org.apache.ignite.cache.store.CacheStore} implementation backed by Hibernate. This implementation
* stores objects in underlying database in {@code BLOB} format.
* <h2 class="header">Configuration</h2>
* Either {@link #setSessionFactory(SessionFactory)} or
@@ -143,7 +145,7 @@ import java.util.concurrent.atomic.*;
* <br>
* For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
*/
-public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K, V> {
+public class GridCacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
/**
* Default connection URL
* (value is <tt>jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000</tt>).
@@ -192,9 +194,11 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
/** {@inheritDoc} */
@SuppressWarnings({"unchecked", "RedundantTypeArguments"})
- @Override public V load(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
+ @Override public V load(K key) {
init();
+ IgniteTx tx = transaction();
+
if (log.isDebugEnabled())
log.debug("Store load [key=" + key + ", tx=" + tx + ']');
@@ -209,10 +213,10 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
return fromBytes(entry.getValue());
}
- catch (HibernateException e) {
+ catch (IgniteCheckedException | HibernateException e) {
rollback(ses, tx);
- throw new IgniteCheckedException("Failed to load value from cache store with key: " + key, e);
+ throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
}
finally {
end(ses, tx);
@@ -220,15 +224,16 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, K key, @Nullable V val)
- throws IgniteCheckedException {
+ @Override public void put(K key, @Nullable V val) {
init();
+ IgniteTx tx = transaction();
+
if (log.isDebugEnabled())
log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
if (val == null) {
- remove(tx, key);
+ remove(key);
return;
}
@@ -240,10 +245,10 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
ses.saveOrUpdate(entry);
}
- catch (HibernateException e) {
+ catch (IgniteCheckedException | HibernateException e) {
rollback(ses, tx);
- throw new IgniteCheckedException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
+ throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
}
finally {
end(ses, tx);
@@ -252,9 +257,11 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
/** {@inheritDoc} */
@SuppressWarnings({"JpaQueryApiInspection", "JpaQlInspection"})
- @Override public void remove(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
+ @Override public void remove(K key) {
init();
+ IgniteTx tx = transaction();
+
if (log.isDebugEnabled())
log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
@@ -266,10 +273,10 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
if (obj != null)
ses.delete(obj);
}
- catch (HibernateException e) {
+ catch (IgniteCheckedException | HibernateException e) {
rollback(ses, tx);
- throw new IgniteCheckedException("Failed to remove value from cache store with key: " + key, e);
+ throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
}
finally {
end(ses, tx);
@@ -313,10 +320,12 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
init();
- Session ses = tx.removeMeta(ATTR_SES);
+ IgniteTx tx = transaction();
+
+ Session ses = (Session)session().properties().remove(ATTR_SES);
if (ses != null) {
Transaction hTx = ses.getTransaction();
@@ -335,7 +344,7 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
}
catch (HibernateException e) {
- throw new IgniteCheckedException("Failed to end transaction [xid=" + tx.xid() +
+ throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
", commit=" + commit + ']', e);
}
finally {
@@ -355,7 +364,9 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
Session ses;
if (tx != null) {
- ses = tx.meta(ATTR_SES);
+ Map<Object, Object> props = session().properties();
+
+ ses = (Session)props.get(ATTR_SES);
if (ses == null) {
ses = sesFactory.openSession();
@@ -364,7 +375,7 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
// Store session in transaction metadata, so it can be accessed
// for other operations on the same transaction.
- tx.addMeta(ATTR_SES, ses);
+ props.put(ATTR_SES, ses);
if (log.isDebugEnabled())
log.debug("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
@@ -412,9 +423,9 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
/**
* Initializes store.
*
- * @throws IgniteCheckedException If failed to initialize.
+ * @throws IgniteException If failed to initialize.
*/
- private void init() throws IgniteCheckedException {
+ private void init() throws IgniteException {
if (initGuard.compareAndSet(false, true)) {
if (log.isDebugEnabled())
log.debug("Initializing cache store.");
@@ -486,17 +497,23 @@ public class GridCacheHibernateBlobStore<K, V> extends GridCacheStoreAdapter<K,
}
}
catch (HibernateException e) {
- throw new IgniteCheckedException("Failed to initialize store.", e);
+ throw new IgniteException("Failed to initialize store.", e);
}
finally {
initLatch.countDown();
}
}
- else if (initLatch.getCount() > 0)
- U.await(initLatch);
+ else if (initLatch.getCount() > 0) {
+ try {
+ U.await(initLatch);
+ }
+ catch (GridInterruptedException e) {
+ throw new IgniteException(e);
+ }
+ }
if (sesFactory == null)
- throw new IgniteCheckedException("Cache store was not properly initialized.");
+ throw new IgniteException("Cache store was not properly initialized.");
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/hibernate/src/test/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStoreSelfTest.java b/modules/hibernate/src/test/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStoreSelfTest.java
index 5bf4009..85da9d2 100644
--- a/modules/hibernate/src/test/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStoreSelfTest.java
+++ b/modules/hibernate/src/test/java/org/gridgain/grid/cache/store/hibernate/GridCacheHibernateBlobStoreSelfTest.java
@@ -76,7 +76,7 @@ public class GridCacheHibernateBlobStoreSelfTest extends
store.setHibernateConfigurationPath(url.toString());
// Store will be implicitly initialized.
- store.load(null, "key");
+ store.load("key");
}
/**
@@ -93,7 +93,7 @@ public class GridCacheHibernateBlobStoreSelfTest extends
store.setHibernateConfigurationPath(file.getAbsolutePath());
// Store will be implicitly initialized.
- store.load(null, "key");
+ store.load("key");
}
/**
@@ -103,6 +103,6 @@ public class GridCacheHibernateBlobStoreSelfTest extends
store.setHibernateConfigurationPath("/org/gridgain/grid/cache/store/hibernate/hibernate.cfg.xml");
// Store will be implicitly initialized.
- store.load(null, "key");
+ store.load("key");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractQuerySelfTest.java
index d2e7ac8..536e3ad 100644
--- a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractQuerySelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.events.*;
import org.apache.ignite.lang.*;
@@ -29,7 +30,6 @@ import org.apache.ignite.spi.swapspace.file.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.query.*;
import org.gridgain.grid.util.tostring.*;
@@ -1994,7 +1994,7 @@ public abstract class GridCacheAbstractQuerySelfTest extends GridCommonAbstractT
/**
* Test store.
*/
- private static class TestStore extends GridCacheStoreAdapter<Object, Object> {
+ private static class TestStore extends CacheStoreAdapter<Object, Object> {
/** */
private Map<Object, Object> map = new ConcurrentHashMap<>();
@@ -2004,19 +2004,17 @@ public abstract class GridCacheAbstractQuerySelfTest extends GridCommonAbstractT
}
/** {@inheritDoc} */
- @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public Object load(Object key) {
return map.get(key);
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Object key, @Nullable Object val)
- throws IgniteCheckedException {
+ @Override public void put(Object key, @Nullable Object val) {
map.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Object key) throws IgniteCheckedException {
+ @Override public void remove(Object key) {
map.remove(key);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
index 86947cd..b41c11d 100644
--- a/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
+++ b/modules/indexing/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheQueryLoadSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.spi.discovery.tcp.*;
@@ -26,7 +27,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.query.*;
import org.gridgain.grid.util.typedef.*;
@@ -390,10 +390,9 @@ public class GridCacheQueryLoadSelfTest extends GridCommonAbstractTest {
/**
* Test store.
*/
- private static class TestStore extends GridCacheStoreAdapter<Integer, ValueObject> {
+ private static class TestStore extends CacheStoreAdapter<Integer, ValueObject> {
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Integer, ValueObject> clo,
- @Nullable Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Integer, ValueObject> clo, @Nullable Object... args) {
assert clo != null;
for (int i = 0; i < PUT_CNT; i++)
@@ -401,16 +400,14 @@ public class GridCacheQueryLoadSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public ValueObject load(@Nullable IgniteTx tx,
- Integer key) throws IgniteCheckedException {
+ @Override public ValueObject load(Integer key) {
assert key != null;
return STORE_MAP.get(key);
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx,
- Integer key, ValueObject val) throws IgniteCheckedException {
+ @Override public void put(Integer key, ValueObject val) {
assert key != null;
assert val != null;
@@ -418,8 +415,7 @@ public class GridCacheQueryLoadSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx,
- Integer key) throws IgniteCheckedException {
+ @Override public void remove(Integer key) {
assert key != null;
STORE_MAP.remove(key);
[5/5] incubator-ignite git commit: # ignite-42
Posted by sb...@apache.org.
# ignite-42
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4b8ec5f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4b8ec5f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4b8ec5f2
Branch: refs/heads/ignite-42
Commit: 4b8ec5f230456293084d9f2224bd5bda90520a81
Parents: 806ce6a
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jan 15 09:43:58 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jan 15 17:42:04 2015 +0300
----------------------------------------------------------------------
.../store/dummy/CacheDummyPersonStore.java | 20 +-
.../hibernate/CacheHibernatePersonStore.java | 55 +-
.../store/jdbc/CacheJdbcPersonStore.java | 50 +-
.../org/gridgain/client/GridHashMapStore.java | 16 +-
.../integration/GridClientAbstractSelfTest.java | 16 +-
.../java/org/apache/ignite/IgniteCache.java | 39 +-
.../cache/store/CacheLoadOnlyStoreAdapter.java | 325 +++++++++++
.../ignite/cache/store/CacheLocalStore.java | 31 +
.../apache/ignite/cache/store/CacheStore.java | 154 +++++
.../ignite/cache/store/CacheStoreAdapter.java | 116 ++++
.../cache/store/CacheStoreBalancingWrapper.java | 293 ++++++++++
.../cache/store/jdbc/CacheJdbcBlobStore.java | 573 +++++++++++++++++++
.../apache/ignite/cache/store/jdbc/package.html | 24 +
.../org/apache/ignite/cache/store/package.html | 23 +
.../java/org/gridgain/grid/cache/GridCache.java | 13 +-
.../grid/cache/GridCacheConfiguration.java | 16 +-
.../grid/cache/GridCacheProjection.java | 143 +++--
.../store/GridCacheLoadOnlyStoreAdapter.java | 328 -----------
.../grid/cache/store/GridCacheLocalStore.java | 31 -
.../grid/cache/store/GridCacheStore.java | 220 -------
.../grid/cache/store/GridCacheStoreAdapter.java | 113 ----
.../store/GridCacheStoreBalancingWrapper.java | 278 ---------
.../store/jdbc/GridCacheJdbcBlobStore.java | 552 ------------------
.../gridgain/grid/cache/store/jdbc/package.html | 24 -
.../org/gridgain/grid/cache/store/package.html | 23 -
.../kernal/processors/cache/CacheEntryImpl.java | 60 ++
.../cache/GridCacheLoaderWriterStore.java | 121 +---
.../processors/cache/GridCacheProcessor.java | 6 +-
.../processors/cache/GridCacheProjectionEx.java | 17 +-
.../processors/cache/GridCacheStoreManager.java | 92 ++-
.../cache/GridCacheWriteBehindStore.java | 74 +--
...CacheJdbcBlobStoreMultithreadedSelfTest.java | 243 ++++++++
.../jdbc/GridCacheJdbcBlobStoreSelfTest.java | 51 ++
.../apache/ignite/cache/store/jdbc/package.html | 23 +
.../cache/IgniteCacheAbstractTest.java | 12 +-
...niteCacheAtomicLocalWithStoreInvokeTest.java | 4 +-
...micPrimaryWriteOrderWithStoreInvokeTest.java | 4 +-
...maryWriteOrderWithStoreExpiryPolicyTest.java | 4 +-
...iteCacheAtomicWithStoreExpiryPolicyTest.java | 4 +-
.../IgniteCacheTxWithStoreExpiryPolicyTest.java | 4 +-
.../store/GridCacheBalancingStoreSelfTest.java | 43 +-
.../GridCacheLoadOnlyStoreAdapterSelfTest.java | 6 +-
.../cache/store/GridGeneratingTestStore.java | 38 +-
...CacheJdbcBlobStoreMultithreadedSelfTest.java | 243 --------
.../jdbc/GridCacheJdbcBlobStoreSelfTest.java | 51 --
.../gridgain/grid/cache/store/jdbc/package.html | 23 -
.../cache/GridCacheAbstractFlagsTest.java | 4 +-
.../cache/GridCacheAbstractSelfTest.java | 12 +-
.../cache/GridCacheBasicStoreAbstractTest.java | 4 +-
...acheBasicStoreMultithreadedAbstractTest.java | 12 +-
...idCacheConfigurationConsistencySelfTest.java | 31 +-
.../cache/GridCacheGenericTestStore.java | 77 +--
.../GridCacheGroupLockAbstractSelfTest.java | 16 +-
.../cache/GridCacheLifecycleAwareSelfTest.java | 25 +-
...ridCacheMultinodeUpdateAbstractSelfTest.java | 4 +-
.../cache/GridCachePartitionedWritesTest.java | 13 +-
.../cache/GridCacheReloadSelfTest.java | 11 +-
.../cache/GridCacheStorePutxSelfTest.java | 30 +-
.../cache/GridCacheSwapReloadSelfTest.java | 12 +-
.../processors/cache/GridCacheTestStore.java | 109 ++--
...idCacheWriteBehindStoreAbstractSelfTest.java | 13 +-
.../GridCacheWriteBehindStoreSelfTest.java | 50 +-
.../IgniteTxStoreExceptionAbstractSelfTest.java | 36 +-
...CacheAtomicReferenceApiSelfAbstractTest.java | 4 +-
...chePartitionedReloadAllAbstractSelfTest.java | 12 +-
.../dht/GridCacheColocatedDebugTest.java | 6 +-
.../dht/GridCacheGlobalLoadTest.java | 15 +-
.../near/GridCacheGetStoreErrorSelfTest.java | 15 +-
.../near/GridCacheNearMultiNodeSelfTest.java | 11 +-
.../near/GridCacheNearOneNodeSelfTest.java | 11 +-
.../GridCacheNearPartitionedClearSelfTest.java | 4 +-
.../GridCachePartitionedLoadCacheSelfTest.java | 13 +-
.../GridCachePartitionedStorePutSelfTest.java | 12 +-
.../near/GridPartitionedBackupLoadSelfTest.java | 14 +-
.../GridCacheBatchEvictUnswapSelfTest.java | 13 +-
.../GridCacheEmptyEntriesAbstractSelfTest.java | 15 +-
.../GridCacheEvictionTouchSelfTest.java | 11 +-
...dCacheAtomicLocalMetricsNoStoreSelfTest.java | 4 +-
.../local/GridCacheLocalLoadAllSelfTest.java | 15 +-
...ridCacheContinuousQueryAbstractSelfTest.java | 15 +-
.../GridCacheWriteBehindStoreLoadTest.java | 11 +-
.../colocation/GridTestCacheStore.java | 22 +-
.../swap/GridSwapEvictAllBenchmark.java | 13 +-
.../testframework/junits/GridTestResources.java | 7 +
.../cache/GridAbstractCacheStoreSelfTest.java | 174 +++---
.../junits/cache/TestCacheSession.java | 59 ++
.../cache/TestThreadLocalCacheSession.java | 57 ++
.../bamboo/GridDataGridTestSuite.java | 2 +-
.../hibernate/GridCacheHibernateBlobStore.java | 67 ++-
.../GridCacheHibernateBlobStoreSelfTest.java | 6 +-
.../cache/GridCacheAbstractQuerySelfTest.java | 12 +-
.../cache/GridCacheQueryLoadSelfTest.java | 16 +-
92 files changed, 2931 insertions(+), 2763 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/examples/src/main/java/org/gridgain/examples/datagrid/store/dummy/CacheDummyPersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/gridgain/examples/datagrid/store/dummy/CacheDummyPersonStore.java b/examples/src/main/java/org/gridgain/examples/datagrid/store/dummy/CacheDummyPersonStore.java
index 48390ac..f4b6553 100644
--- a/examples/src/main/java/org/gridgain/examples/datagrid/store/dummy/CacheDummyPersonStore.java
+++ b/examples/src/main/java/org/gridgain/examples/datagrid/store/dummy/CacheDummyPersonStore.java
@@ -18,12 +18,12 @@
package org.gridgain.examples.datagrid.store.dummy;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
import org.gridgain.examples.datagrid.store.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.jetbrains.annotations.*;
import java.util.*;
@@ -32,41 +32,47 @@ import java.util.concurrent.*;
/**
* Dummy cache store implementation.
*/
-public class CacheDummyPersonStore extends GridCacheStoreAdapter<Long, Person> {
+public class CacheDummyPersonStore extends CacheStoreAdapter<Long, Person> {
/** Auto-inject grid instance. */
@IgniteInstanceResource
private Ignite ignite;
/** Auto-inject cache name. */
- @GridCacheName
+ @IgniteCacheNameResource
private String cacheName;
/** Dummy database. */
private Map<Long, Person> dummyDB = new ConcurrentHashMap<>();
/** {@inheritDoc} */
- @Override public Person load(@Nullable IgniteTx tx, Long key) throws IgniteCheckedException {
+ @Override public Person load(Long key) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
return dummyDB.get(key);
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Long key, Person val) throws IgniteCheckedException {
+ @Override public void put(Long key, Person val) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store put [key=" + key + ", val=" + val + ", xid=" + (tx == null ? null : tx.xid()) + ']');
dummyDB.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Long key) throws IgniteCheckedException {
+ @Override public void remove(Long key) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
dummyDB.remove(key);
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
int cnt = (Integer)args[0];
System.out.println(">>> Store loadCache for entry count: " + cnt);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/examples/src/main/java/org/gridgain/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/gridgain/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples/src/main/java/org/gridgain/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
index cc0bbc1..c671108 100644
--- a/examples/src/main/java/org/gridgain/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
+++ b/examples/src/main/java/org/gridgain/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
@@ -17,22 +17,22 @@
package org.gridgain.examples.datagrid.store.hibernate;
-import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.examples.datagrid.store.*;
-import org.gridgain.grid.cache.store.*;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.jetbrains.annotations.*;
+import javax.cache.integration.*;
import java.util.*;
/**
- * Example of {@link GridCacheStore} implementation that uses Hibernate
+ * Example of {@link CacheStore} implementation that uses Hibernate
* and deals with maps {@link UUID} to {@link Person}.
*/
-public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Person> {
+public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
/** Default hibernate configuration resource path. */
private static final String DFLT_HIBERNATE_CFG = "/org/gridgain/examples/datagrid/store/hibernate/hibernate.cfg.xml";
@@ -50,7 +50,9 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
}
/** {@inheritDoc} */
- @Override public Person load(@Nullable IgniteTx tx, Long key) throws IgniteCheckedException {
+ @Override public Person load(Long key) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
Session ses = session(tx);
@@ -61,7 +63,7 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
catch (HibernateException e) {
rollback(ses, tx);
- throw new IgniteCheckedException("Failed to load value from cache store with key: " + key, e);
+ throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
}
finally {
end(ses, tx);
@@ -69,12 +71,13 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Long key, @Nullable Person val)
- throws IgniteCheckedException {
+ @Override public void put(Long key, @Nullable Person val) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store put [key=" + key + ", val=" + val + ", xid=" + (tx == null ? null : tx.xid()) + ']');
if (val == null) {
- remove(tx, key);
+ remove(key);
return;
}
@@ -87,7 +90,7 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
catch (HibernateException e) {
rollback(ses, tx);
- throw new IgniteCheckedException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
+ throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
}
finally {
end(ses, tx);
@@ -96,7 +99,9 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
/** {@inheritDoc} */
@SuppressWarnings({"JpaQueryApiInspection"})
- @Override public void remove(@Nullable IgniteTx tx, Long key) throws IgniteCheckedException {
+ @Override public void remove(Long key) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
Session ses = session(tx);
@@ -108,7 +113,7 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
catch (HibernateException e) {
rollback(ses, tx);
- throw new IgniteCheckedException("Failed to remove value from cache store with key: " + key, e);
+ throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
}
finally {
end(ses, tx);
@@ -116,9 +121,9 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
if (args == null || args.length == 0 || args[0] == null)
- throw new IgniteCheckedException("Expected entry count parameter is not provided.");
+ throw new CacheLoaderException("Expected entry count parameter is not provided.");
final int entryCnt = (Integer)args[0];
@@ -144,7 +149,7 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
System.out.println(">>> Loaded " + cnt + " values into cache.");
}
catch (HibernateException e) {
- throw new IgniteCheckedException("Failed to load values from cache store.", e);
+ throw new CacheLoaderException("Failed to load values from cache store.", e);
}
finally {
end(ses, null);
@@ -188,8 +193,14 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
- Session ses = tx.removeMeta(ATTR_SES);
+ @Override public void txEnd(boolean commit) {
+ CacheStoreSession storeSes = session();
+
+ IgniteTx tx = storeSes.transaction();
+
+ Map<Object, Object> props = storeSes.properties();
+
+ Session ses = (Session)props.remove(ATTR_SES);
if (ses != null) {
Transaction hTx = ses.getTransaction();
@@ -207,7 +218,7 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
System.out.println("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
}
catch (HibernateException e) {
- throw new IgniteCheckedException("Failed to end transaction [xid=" + tx.xid() +
+ throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
", commit=" + commit + ']', e);
}
finally {
@@ -227,16 +238,18 @@ public class CacheHibernatePersonStore extends GridCacheStoreAdapter<Long, Perso
Session ses;
if (tx != null) {
- ses = tx.meta(ATTR_SES);
+ Map<Object, Object> props = session().properties();
+
+ ses = (Session)props.get(ATTR_SES);
if (ses == null) {
ses = sesFactory.openSession();
ses.beginTransaction();
- // Store session in transaction metadata, so it can be accessed
+ // Store session in session properties, so it can be accessed
// for other operations on the same transaction.
- tx.addMeta(ATTR_SES, ses);
+ props.put(ATTR_SES, ses);
System.out.println("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/examples/src/main/java/org/gridgain/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/gridgain/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java b/examples/src/main/java/org/gridgain/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
index 2aeb655..2711dba 100644
--- a/examples/src/main/java/org/gridgain/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
+++ b/examples/src/main/java/org/gridgain/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
@@ -18,21 +18,22 @@
package org.gridgain.examples.datagrid.store.jdbc;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.examples.datagrid.store.*;
-import org.gridgain.grid.cache.store.*;
import org.jetbrains.annotations.*;
+import javax.cache.integration.*;
import java.sql.*;
import java.util.*;
/**
- * Example of {@link GridCacheStore} implementation that uses JDBC
+ * Example of {@link CacheStore} implementation that uses JDBC
* transaction with cache transactions and maps {@link UUID} to {@link Person}.
*
*/
-public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
+public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> {
/** Transaction metadata attribute name. */
private static final String ATTR_NAME = "SIMPLE_STORE_CONNECTION";
@@ -64,8 +65,12 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
- try (Connection conn = tx.removeMeta(ATTR_NAME)) {
+ @Override public void txEnd(boolean commit) {
+ IgniteTx tx = transaction();
+
+ Map<Object, Object> props = session().properties();
+
+ try (Connection conn = (Connection)props.remove(ATTR_NAME)) {
if (conn != null) {
if (commit)
conn.commit();
@@ -76,12 +81,14 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
System.out.println(">>> Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
}
catch (SQLException e) {
- throw new IgniteCheckedException("Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e);
+ throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e);
}
}
/** {@inheritDoc} */
- @Nullable @Override public Person load(@Nullable IgniteTx tx, Long key) throws IgniteCheckedException {
+ @Nullable @Override public Person load(Long key) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
Connection conn = null;
@@ -99,7 +106,7 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
}
catch (SQLException e) {
- throw new IgniteCheckedException("Failed to load object: " + key, e);
+ throw new CacheLoaderException("Failed to load object: " + key, e);
}
finally {
end(tx, conn);
@@ -109,8 +116,9 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Long key, Person val)
- throws IgniteCheckedException {
+ @Override public void put(Long key, Person val) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store put [key=" + key + ", val=" + val + ", xid=" + (tx == null ? null : tx.xid()) + ']');
Connection conn = null;
@@ -142,7 +150,7 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
}
catch (SQLException e) {
- throw new IgniteCheckedException("Failed to put object [key=" + key + ", val=" + val + ']', e);
+ throw new CacheLoaderException("Failed to put object [key=" + key + ", val=" + val + ']', e);
}
finally {
end(tx, conn);
@@ -150,7 +158,9 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Long key) throws IgniteCheckedException {
+ @Override public void remove(Long key) {
+ IgniteTx tx = transaction();
+
System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
Connection conn = null;
@@ -165,7 +175,7 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
}
catch (SQLException e) {
- throw new IgniteCheckedException("Failed to remove object: " + key, e);
+ throw new CacheLoaderException("Failed to remove object: " + key, e);
}
finally {
end(tx, conn);
@@ -173,9 +183,9 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Long, Person> clo, Object... args) {
if (args == null || args.length == 0 || args[0] == null)
- throw new IgniteCheckedException("Expected entry count parameter is not provided.");
+ throw new CacheLoaderException("Expected entry count parameter is not provided.");
final int entryCnt = (Integer)args[0];
@@ -201,7 +211,7 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
}
}
catch (SQLException e) {
- throw new IgniteCheckedException("Failed to load values from cache store.", e);
+ throw new CacheLoaderException("Failed to load values from cache store.", e);
}
finally {
end(null, conn);
@@ -215,14 +225,16 @@ public class CacheJdbcPersonStore extends GridCacheStoreAdapter<Long, Person> {
*/
private Connection connection(@Nullable IgniteTx tx) throws SQLException {
if (tx != null) {
- Connection conn = tx.meta(ATTR_NAME);
+ Map<Object, Object> props = session().properties();
+
+ Connection conn = (Connection)props.get(ATTR_NAME);
if (conn == null) {
conn = openConnection(false);
- // Store connection in transaction metadata, so it can be accessed
+ // Store connection in session properties, so it can be accessed
// for other operations on the same transaction.
- tx.addMeta(ATTR_NAME, conn);
+ props.put(ATTR_NAME, conn);
}
return conn;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/clients/src/test/java/org/gridgain/client/GridHashMapStore.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/gridgain/client/GridHashMapStore.java b/modules/clients/src/test/java/org/gridgain/client/GridHashMapStore.java
index 67fc50d..5b0fbe7 100644
--- a/modules/clients/src/test/java/org/gridgain/client/GridHashMapStore.java
+++ b/modules/clients/src/test/java/org/gridgain/client/GridHashMapStore.java
@@ -18,9 +18,9 @@
package org.gridgain.client;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
import org.jetbrains.annotations.*;
import java.util.*;
@@ -28,32 +28,28 @@ import java.util.*;
/**
* Simple HashMap based cache store emulation.
*/
-public class GridHashMapStore extends GridCacheStoreAdapter {
+public class GridHashMapStore extends CacheStoreAdapter {
/** Map for cache store. */
private final Map<Object, Object> map = new HashMap<>();
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure c, Object... args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure c, Object... args) {
for (Map.Entry e : map.entrySet())
c.apply(e.getKey(), e.getValue());
}
/** {@inheritDoc} */
- @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public Object load(Object key) {
return map.get(key);
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) throws IgniteCheckedException {
+ @Override public void put(Object key, @Nullable Object val) {
map.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public void remove(Object key) {
map.remove(key);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java b/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
index 58d6894..6e8d1a3 100644
--- a/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/gridgain/client/integration/GridClientAbstractSelfTest.java
@@ -20,6 +20,7 @@ package org.gridgain.client.integration;
import junit.framework.*;
import net.sf.json.*;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.compute.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
@@ -32,7 +33,6 @@ import org.gridgain.client.*;
import org.gridgain.client.ssl.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.affinity.consistenthash.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.junits.common.*;
@@ -1564,33 +1564,29 @@ public abstract class GridClientAbstractSelfTest extends GridCommonAbstractTest
/**
* Simple HashMap based cache store emulation.
*/
- private static class HashMapStore extends GridCacheStoreAdapter<Object, Object> {
+ private static class HashMapStore extends CacheStoreAdapter<Object, Object> {
/** Map for cache store. */
private final Map<Object, Object> map = new HashMap<>();
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args) {
for (Map.Entry e : map.entrySet()) {
clo.apply(e.getKey(), e.getValue());
}
}
/** {@inheritDoc} */
- @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public Object load(Object key) {
return map.get(key);
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) throws IgniteCheckedException {
+ @Override public void put(Object key, @Nullable Object val) {
map.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public void remove(Object key) {
map.remove(key);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 2988005..30850e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -22,7 +22,6 @@ import org.apache.ignite.cache.query.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.jetbrains.annotations.*;
import javax.cache.*;
@@ -95,20 +94,20 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* @param p Optional predicate (may be {@code null}). If provided, will be used to
* filter values to be put into cache.
* @param args Optional user arguments to be passed into
- * {@link GridCacheStore#loadCache(IgniteBiInClosure, Object...)} method.
+ * {@link org.apache.ignite.cache.store.CacheStore#loadCache(IgniteBiInClosure, Object...)} method.
* @throws CacheException If loading failed.
*/
public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException;
/**
- * Delegates to {@link GridCacheStore#loadCache(IgniteBiInClosure,Object...)} method
+ * Delegates to {@link org.apache.ignite.cache.store.CacheStore#loadCache(IgniteBiInClosure,Object...)} method
* to load state from the underlying persistent storage. The loaded values
* will then be given to the optionally passed in predicate, and, if the predicate returns
* {@code true}, will be stored in cache. If predicate is {@code null}, then
* all loaded values will be stored in cache.
* <p>
* Note that this method does not receive keys as a parameter, so it is up to
- * {@link GridCacheStore} implementation to provide all the data to be loaded.
+ * {@link org.apache.ignite.cache.store.CacheStore} implementation to provide all the data to be loaded.
* <p>
* This method is not transactional and may end up loading a stale value into
* cache if another thread has updated the value immediately after it has been
@@ -118,7 +117,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* @param p Optional predicate (may be {@code null}). If provided, will be used to
* filter values to be put into cache.
* @param args Optional user arguments to be passed into
- * {@link GridCacheStore#loadCache(IgniteBiInClosure, Object...)} method.
+ * {@link org.apache.ignite.cache.store.CacheStore#loadCache(IgniteBiInClosure, Object...)} method.
* @throws CacheException If loading failed.
*/
public void localLoadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException;
@@ -130,14 +129,14 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putIfAbsent(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -164,8 +163,8 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* are acquired in undefined order, so it may cause a deadlock when used with
* other concurrent transactional updates.
* <p>
- * If write-through is enabled, the values will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#removeAll(IgniteTx, java.util.Collection)} method.
+ * If write-through is enabled, the values will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#removeAll(IgniteTx, java.util.Collection)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -319,13 +318,13 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putIf(Object, Object, IgnitePredicate)} should
* always be used instead of this one to avoid the overhead associated with returning of the previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -356,8 +355,8 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* value and, therefore, does not have any overhead associated with returning a value. It
* should be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -384,14 +383,14 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* caches, the value will be loaded from the primary node, which in its turn may load the value
* from the disk-based swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #removeIf(Object, IgnitePredicate)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -416,8 +415,8 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* This method will return {@code true} if remove did occur, which means that all optionally
* provided filters have passed and there was something to remove, {@code false} otherwise.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java
new file mode 100644
index 0000000..0d7a85b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLoadOnlyStoreAdapter.java
@@ -0,0 +1,325 @@
+/*
+ * 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.cache.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.cache.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import javax.cache.integration.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+import static java.util.concurrent.TimeUnit.*;
+
+/**
+ * This adepter designed to support stores with bulk loading from stream-like source.
+ * <p>
+ * This class processes input data in the following way:
+ * <ul>
+ * <li>
+ * Iterator of input record obtained from user-defined {@link #inputIterator(Object...)}.
+ * </li>
+ * <li>
+ * Iterator continuously queried for input records and they are grouped into batches of {@link #batchSize}.
+ * </li>
+ * <li>
+ * Batch is placed into processing queue and puled by one of {@link #threadsCnt} working threads.
+ * </li>
+ * <li>
+ * Each record in batch is passed to user-defined {@link #parse(Object, Object...)} method
+ * and result is stored into cache.
+ * </li>
+ * </ul>
+ * <p>
+ * Two methods should be implemented by inheritants:
+ * <ul>
+ * <li>
+ * {@link #inputIterator(Object...)}. It should open underlying data source
+ * and iterate all record available in it. Individual records could be in very raw form,
+ * like text lines for CSV files.
+ * </li>
+ * <li>
+ * {@link #parse(Object, Object...)}. This method should process input records
+ * and transform them into key-value pairs for cache.
+ * </li>
+ * </ul>
+ * <p>
+ *
+ * @param <K> Key type.
+ * @param <V> Value type.
+ * @param <I> Input type.
+ */
+public abstract class CacheLoadOnlyStoreAdapter<K, V, I> implements CacheStore<K, V> {
+ /**
+ * Default batch size (number of records read with {@link #inputIterator(Object...)}
+ * and then submitted to internal pool at a time).
+ */
+ public static final int DFLT_BATCH_SIZE = 100;
+
+ /** Default batch queue size (max batches count to limit memory usage). */
+ public static final int DFLT_BATCH_QUEUE_SIZE = 100;
+
+ /** Default number of working threads (equal to the number of available processors). */
+ public static final int DFLT_THREADS_COUNT = Runtime.getRuntime().availableProcessors();
+
+ /** Auto-injected logger. */
+ @IgniteLoggerResource
+ private IgniteLogger log;
+
+ /** Batch size. */
+ private int batchSize = DFLT_BATCH_SIZE;
+
+ /** Size of queue of batches to process. */
+ private int batchQueueSize = DFLT_BATCH_QUEUE_SIZE;
+
+ /** Number fo working threads. */
+ private int threadsCnt = DFLT_THREADS_COUNT;
+
+ /**
+ * Returns iterator of input records.
+ * <p>
+ * Note that returned iterator doesn't have to be thread-safe. Thus it could
+ * operate on raw streams, DB connections, etc. without additional synchronization.
+ *
+ * @param args Arguments passes into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
+ * @return Iterator over input records.
+ * @throws CacheLoaderException If iterator can't be created with the given arguments.
+ */
+ protected abstract Iterator<I> inputIterator(@Nullable Object... args) throws CacheLoaderException;
+
+ /**
+ * This method should transform raw data records into valid key-value pairs
+ * to be stored into cache.
+ * <p>
+ * If {@code null} is returned then this record will be just skipped.
+ *
+ * @param rec A raw data record.
+ * @param args Arguments passed into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
+ * @return Cache entry to be saved in cache or {@code null} if no entry could be produced from this record.
+ */
+ @Nullable protected abstract IgniteBiTuple<K, V> parse(I rec, @Nullable Object... args);
+
+ /** {@inheritDoc} */
+ @Override public void loadCache(IgniteBiInClosure<K, V> c, @Nullable Object... args) {
+ ExecutorService exec = new ThreadPoolExecutor(
+ threadsCnt,
+ threadsCnt,
+ 0L,
+ MILLISECONDS,
+ new ArrayBlockingQueue<Runnable>(batchQueueSize),
+ new BlockingRejectedExecutionHandler());
+
+ Iterator<I> iter = inputIterator(args);
+
+ Collection<I> buf = new ArrayList<>(batchSize);
+
+ try {
+ while (iter.hasNext()) {
+ if (Thread.currentThread().isInterrupted()) {
+ U.warn(log, "Working thread was interrupted while loading data.");
+
+ break;
+ }
+
+ buf.add(iter.next());
+
+ if (buf.size() == batchSize) {
+ exec.submit(new Worker(c, buf, args));
+
+ buf = new ArrayList<>(batchSize);
+ }
+ }
+
+ if (!buf.isEmpty())
+ exec.submit(new Worker(c, buf, args));
+ }
+ catch (RejectedExecutionException ignored) {
+ // Because of custom RejectedExecutionHandler.
+ assert false : "RejectedExecutionException was thrown while it shouldn't.";
+ }
+ finally {
+ exec.shutdown();
+
+ try {
+ exec.awaitTermination(Long.MAX_VALUE, MILLISECONDS);
+ }
+ catch (InterruptedException ignored) {
+ U.warn(log, "Working thread was interrupted while waiting for put operations to complete.");
+
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+
+ /**
+ * Returns batch size.
+ *
+ * @return Batch size.
+ */
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ /**
+ * Sets batch size.
+ *
+ * @param batchSize Batch size.
+ */
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ /**
+ * Returns batch queue size.
+ *
+ * @return Batch queue size.
+ */
+ public int getBatchQueueSize() {
+ return batchQueueSize;
+ }
+
+ /**
+ * Sets batch queue size.
+ *
+ * @param batchQueueSize Batch queue size.
+ */
+ public void setBatchQueueSize(int batchQueueSize) {
+ this.batchQueueSize = batchQueueSize;
+ }
+
+ /**
+ * Returns number of worker threads.
+ *
+ * @return Number of worker threads.
+ */
+ public int getThreadsCount() {
+ return threadsCnt;
+ }
+
+ /**
+ * Sets number of worker threads.
+ *
+ * @param threadsCnt Number of worker threads.
+ */
+ public void setThreadsCount(int threadsCnt) {
+ this.threadsCnt = threadsCnt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V load(K key) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> loadAll(Iterable<? extends K> keys) {
+ return Collections.emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Cache.Entry<? extends K, ? extends V> entry) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeAll(Collection<Cache.Entry<? extends K, ? extends V>> entries) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void delete(Object key) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void deleteAll(Collection<?> keys) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void txEnd(boolean commit) {
+ // No-op.
+ }
+
+ /**
+ * Worker.
+ */
+ private class Worker implements Runnable {
+ /** */
+ private final IgniteBiInClosure<K, V> c;
+
+ /** */
+ private final Collection<I> buf;
+
+ /** */
+ private final Object[] args;
+
+ /**
+ * @param c Closure for loaded entries.
+ * @param buf Set of input records to process.
+ * @param args Arguments passed into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
+ */
+ Worker(IgniteBiInClosure<K, V> c, Collection<I> buf, Object[] args) {
+ this.c = c;
+ this.buf = buf;
+ this.args = args;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ for (I rec : buf) {
+ IgniteBiTuple<K, V> entry = parse(rec, args);
+
+ if (entry != null)
+ c.apply(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ /**
+ * This handler blocks the caller thread until free space will be available in tasks queue.
+ * If the executor is shut down than it throws {@link RejectedExecutionException}.
+ * <p>
+ * It is save to apply this policy when:
+ * <ol>
+ * <li>{@code shutdownNow} is not used on the pool.</li>
+ * <li>{@code shutdown} is called from the thread where all submissions where performed.</li>
+ * </ol>
+ */
+ private class BlockingRejectedExecutionHandler implements RejectedExecutionHandler {
+ /** {@inheritDoc} */
+ @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ try {
+ if (executor.isShutdown())
+ throw new RejectedExecutionException();
+ else
+ executor.getQueue().put(r);
+ }
+ catch (InterruptedException ignored) {
+ U.warn(log, "Working thread was interrupted while loading data.");
+
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLocalStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLocalStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLocalStore.java
new file mode 100644
index 0000000..6fdec5a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheLocalStore.java
@@ -0,0 +1,31 @@
+/*
+ * 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.cache.store;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation for local {@link CacheStore} implementation. "Local" here means that there is no global
+ * database behind the grid but each node has an independent one.
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.TYPE})
+public @interface CacheLocalStore {
+ // No-op.
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
new file mode 100644
index 0000000..4cdfe5a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
@@ -0,0 +1,154 @@
+/*
+ * 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.cache.store;
+
+import org.apache.ignite.IgnitePortables;
+import org.apache.ignite.cache.store.jdbc.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.portables.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.*;
+import org.gridgain.grid.cache.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.integration.*;
+import java.sql.*;
+import java.util.*;
+import java.util.Date;
+
+import static javax.cache.Cache.*;
+
+/**
+ * API for cache persistent storage for read-through and write-through behavior.
+ * Persistent store is configured via {@link GridCacheConfiguration#getStore()}
+ * configuration property. If not provided, values will be only kept in cache memory
+ * or swap storage without ever being persisted to a persistent storage.
+ * <p>
+ * {@link CacheStoreAdapter} provides default implementation for bulk operations,
+ * such as {@link #loadAll(Iterable)},
+ * {@link #writeAll(Collection)}, and {@link #deleteAll(Collection)}
+ * by sequentially calling corresponding {@link #load(Object)},
+ * {@link #write(Entry)}, and {@link #delete(Object)}
+ * operations. Use this adapter whenever such behaviour is acceptable. However
+ * in many cases it maybe more preferable to take advantage of database batch update
+ * functionality, and therefore default adapter implementation may not be the best option.
+ * <p>
+ * Provided implementations may be used for test purposes:
+ * <ul>
+ * <li>{@gglink org.gridgain.grid.cache.store.hibernate.GridCacheHibernateBlobStore}</li>
+ * <li>{@link CacheJdbcBlobStore}</li>
+ * </ul>
+ * <p>
+ * All transactional operations of this API are provided with ongoing {@link IgniteTx},
+ * if any. As transaction is {@link GridMetadataAware}, you can attach any metadata to
+ * it, e.g. to recognize if several operations belong to the same transaction or not.
+ * Here is an example of how attach a JDBC connection as transaction metadata:
+ * <pre name="code" class="java">
+ * Connection conn = tx.meta("some.name");
+ *
+ * if (conn == null) {
+ * conn = ...; // Get JDBC connection.
+ *
+ * // Store connection in transaction metadata, so it can be accessed
+ * // for other operations on the same transaction.
+ * tx.addMeta("some.name", conn);
+ * }
+ * </pre>
+ * <h1 class="header">Working With Portable Objects</h1>
+ * When portables are enabled for cache by setting {@link GridCacheConfiguration#isPortableEnabled()} to
+ * {@code true}), all portable keys and values are converted to instances of {@link PortableObject}.
+ * Therefore, all cache store methods will take parameters in portable format. To avoid class
+ * cast exceptions, store must have signature compatible with portables. E.g., if you use {@link Integer}
+ * as a key and {@code Value} class as a value (which will be converted to portable format), cache store
+ * signature should be the following:
+ * <pre name="code" class="java">
+ * public class PortableCacheStore implements GridCacheStore<Integer, GridPortableObject> {
+ * public void put(@Nullable GridCacheTx tx, Integer key, GridPortableObject val) throws IgniteCheckedException {
+ * ...
+ * }
+ *
+ * ...
+ * }
+ * </pre>
+ * This behavior can be overridden by setting {@link GridCacheConfiguration#setKeepPortableInStore(boolean)}
+ * flag value to {@code false}. In this case, GridGain will deserialize keys and values stored in portable
+ * format before they are passed to cache store, so that you can use the following cache store signature instead:
+ * <pre name="code" class="java">
+ * public class ObjectsCacheStore implements GridCacheStore<Integer, Person> {
+ * public void put(@Nullable GridCacheTx tx, Integer key, Person val) throws GridException {
+ * ...
+ * }
+ *
+ * ...
+ * }
+ * </pre>
+ * Note that while this can simplify store implementation in some cases, it will cause performance degradation
+ * due to additional serializations and deserializations of portable objects. You will also need to have key
+ * and value classes on all nodes since portables will be deserialized when store is invoked.
+ * <p>
+ * Note that only portable classes are converted to {@link PortableObject} format. Following
+ * types are stored in cache without changes and therefore should not affect cache store signature:
+ * <ul>
+ * <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li>
+ * <li>Arrays of primitives (byte[], int[], ...)</li>
+ * <li>{@link String} and array of {@link String}s</li>
+ * <li>{@link UUID} and array of {@link UUID}s</li>
+ * <li>{@link Date} and array of {@link Date}s</li>
+ * <li>{@link Timestamp} and array of {@link Timestamp}s</li>
+ * <li>Enums and array of enums</li>
+ * <li>
+ * Maps, collections and array of objects (but objects inside
+ * them will still be converted if they are portable)
+ * </li>
+ * </ul>
+ *
+ * @see IgnitePortables
+ */
+public interface CacheStore<K, V> extends CacheLoader<K, V>, CacheWriter<K, V> {
+ /**
+ * Loads all values from underlying persistent storage. Note that keys are not
+ * passed, so it is up to implementation to figure out what to load. This method
+ * is called whenever {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)}
+ * method is invoked which is usually to preload the cache from persistent storage.
+ * <p>
+ * This method is optional, and cache implementation does not depend on this
+ * method to do anything. Default implementation of this method in
+ * {@link CacheStoreAdapter} does nothing.
+ * <p>
+ * For every loaded value method {@link org.apache.ignite.lang.IgniteBiInClosure#apply(Object, Object)}
+ * should be called on the passed in closure. The closure will then make sure
+ * that the loaded value is stored in cache.
+ *
+ * @param clo Closure for loaded values.
+ * @param args Arguments passes into
+ * {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
+ * @throws CacheLoaderException If loading failed.
+ */
+ public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) throws CacheLoaderException;
+
+ /**
+ * Tells store to commit or rollback a transaction depending on the value of the {@code 'commit'}
+ * parameter.
+ *
+ * @param commit {@code True} if transaction should commit, {@code false} for rollback.
+ * @throws CacheWriterException If commit or rollback failed. Note that commit failure in some cases
+ * may bring cache transaction into {@link IgniteTxState#UNKNOWN} which will
+ * consequently cause all transacted entries to be invalidated.
+ */
+ public void txEnd(boolean commit) throws CacheWriterException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java
new file mode 100644
index 0000000..4ec5cbf
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreAdapter.java
@@ -0,0 +1,116 @@
+/*
+ * 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.cache.store;
+
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.cache.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import java.util.*;
+
+/**
+ * Cache storage convenience adapter. It provides default implementation for bulk operations, such
+ * as {@link #loadAll(Iterable)},
+ * {@link #writeAll(Collection)}, and {@link #deleteAll(Collection)}
+ * by sequentially calling corresponding {@link #load(Object)},
+ * {@link #write(Cache.Entry)}, and {@link #delete(Object)}
+ * operations. Use this adapter whenever such behaviour is acceptable. However in many cases
+ * it maybe more preferable to take advantage of database batch update functionality, and therefore
+ * default adapter implementation may not be the best option.
+ * <p>
+ * Note that method {@link #loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} has empty
+ * implementation because it is essentially up to the user to invoke it with
+ * specific arguments.
+ */
+public abstract class CacheStoreAdapter<K, V> implements CacheStore<K, V> {
+ /** */
+ @IgniteCacheSessionResource
+ private CacheStoreSession ses;
+
+ /**
+ * Default empty implementation. This method needs to be overridden only if
+ * {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method
+ * is explicitly called.
+ *
+ * @param clo {@inheritDoc}
+ * @param args {@inheritDoc}
+ */
+ @Override public void loadCache(IgniteBiInClosure<K, V> clo, Object... args) {
+ /* No-op. */
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> loadAll(Iterable<? extends K> keys) {
+ assert keys != null;
+
+ Map<K, V> loaded = new HashMap<>();
+
+ for (K key : keys) {
+ V v = load(key);
+
+ if (v != null)
+ loaded.put(key, v);
+ }
+
+ return loaded;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeAll(Collection<Cache.Entry<? extends K, ? extends V>> entries) {
+ assert entries != null;
+
+ for (Cache.Entry<? extends K, ? extends V> e : entries)
+ write(e);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void deleteAll(Collection<?> keys) {
+ assert keys != null;
+
+ for (Object key : keys)
+ delete(key);
+ }
+
+ /**
+ * Default empty implementation for ending transactions. Note that if explicit cache
+ * transactions are not used, then transactions do not have to be explicitly ended -
+ * for all other cases this method should be overridden with custom commit/rollback logic.
+ *
+ * @param commit {@inheritDoc}
+ */
+ @Override public void txEnd(boolean commit) {
+ // No-op.
+ }
+
+ /**
+ * @return Current session.
+ */
+ @Nullable protected CacheStoreSession session() {
+ return ses;
+ }
+
+ /**
+ * @return Current transaction.
+ */
+ @Nullable protected IgniteTx transaction() {
+ return ses != null ? ses.transaction() : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreBalancingWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreBalancingWrapper.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreBalancingWrapper.java
new file mode 100644
index 0000000..c76d4ec
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreBalancingWrapper.java
@@ -0,0 +1,293 @@
+/*
+ * 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.cache.store;
+
+import org.apache.ignite.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.util.future.*;
+import org.gridgain.grid.util.typedef.*;
+import org.jdk8.backport.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.*;
+import javax.cache.integration.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+/**
+ * Cache store wrapper that ensures that there will be no more that one thread loading value from underlying store.
+ */
+public class CacheStoreBalancingWrapper<K, V> implements CacheStore<K, V> {
+ /** */
+ public static final int DFLT_LOAD_ALL_THRESHOLD = 5;
+
+ /** Delegate store. */
+ private CacheStore<K, V> delegate;
+
+ /** Pending cache store loads. */
+ private ConcurrentMap<K, LoadFuture> pendingLoads = new ConcurrentHashMap8<>();
+
+ /** Load all threshold. */
+ private int loadAllThreshold = DFLT_LOAD_ALL_THRESHOLD;
+
+ /**
+ * @param delegate Delegate store.
+ */
+ public CacheStoreBalancingWrapper(CacheStore<K, V> delegate) {
+ this.delegate = delegate;
+ }
+
+ /**
+ * @param delegate Delegate store.
+ * @param loadAllThreshold Load all threshold.
+ */
+ public CacheStoreBalancingWrapper(CacheStore<K, V> delegate, int loadAllThreshold) {
+ this.delegate = delegate;
+ this.loadAllThreshold = loadAllThreshold;
+ }
+
+ /**
+ * @return Load all threshold.
+ */
+ public int loadAllThreshold() {
+ return loadAllThreshold;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public V load(K key) {
+ LoadFuture fut = pendingLoads.get(key);
+
+ try {
+ if (fut != null)
+ return fut.get(key);
+
+ fut = new LoadFuture();
+
+ LoadFuture old = pendingLoads.putIfAbsent(key, fut);
+
+ if (old != null)
+ return old.get(key);
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheLoaderException(e);
+ }
+
+ try {
+ V val = delegate.load(key);
+
+ fut.onComplete(key, val);
+
+ return val;
+ }
+ catch (Throwable e) {
+ fut.onError(key, e);
+
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) {
+ delegate.loadCache(clo, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, V> loadAll(Iterable<? extends K> keys) throws CacheLoaderException {
+ return delegate.loadAll(keys);
+ }
+
+ /**
+ * @param keys Keys to load.
+ * @param c Closure for loaded values.
+ */
+ public void loadAll(Collection<? extends K> keys, final IgniteBiInClosure<K, V> c) {
+ assert keys.size() < loadAllThreshold;
+
+ Collection<K> needLoad = null;
+ Map<K, LoadFuture> pending = null;
+ LoadFuture span = null;
+
+ for (K key : keys) {
+ LoadFuture fut = pendingLoads.get(key);
+
+ if (fut != null) {
+ if (pending == null)
+ pending = new HashMap<>();
+
+ pending.put(key, fut);
+ }
+ else {
+ // Try to concurrently add pending future.
+ if (span == null)
+ span = new LoadFuture();
+
+ LoadFuture old = pendingLoads.putIfAbsent(key, span);
+
+ if (old != null) {
+ if (pending == null)
+ pending = new HashMap<>();
+
+ pending.put(key, old);
+ }
+ else {
+ if (needLoad == null)
+ needLoad = new ArrayList<>(keys.size());
+
+ needLoad.add(key);
+ }
+ }
+ }
+
+ if (needLoad != null) {
+ assert !needLoad.isEmpty();
+ assert span != null;
+
+ try {
+ Map<K, V> loaded = delegate.loadAll(needLoad);
+
+ for (Map.Entry<K, V> e : loaded.entrySet())
+ c.apply(e.getKey(), e.getValue());
+
+ span.onComplete(needLoad, loaded);
+ }
+ catch (Throwable e) {
+ span.onError(needLoad, e);
+
+ throw e;
+ }
+ }
+
+ if (pending != null) {
+ try {
+ for (Map.Entry<K, LoadFuture> e : pending.entrySet()) {
+ K key = e.getKey();
+
+ c.apply(key, e.getValue().get(key));
+ }
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheLoaderException(e);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Cache.Entry<? extends K, ? extends V> entry) {
+ delegate.write(entry);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeAll(Collection<Cache.Entry<? extends K, ? extends V>> entries) {
+ delegate.writeAll(entries);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void delete(Object key) throws CacheWriterException {
+ delegate.delete(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void deleteAll(Collection<?> keys) throws CacheWriterException {
+ delegate.deleteAll(keys);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void txEnd(boolean commit) {
+ delegate.txEnd(commit);
+ }
+
+ /**
+ *
+ */
+ private class LoadFuture extends GridFutureAdapter<Map<K, V>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Collection of keys for pending cleanup. */
+ private volatile Collection<K> keys;
+
+ /**
+ *
+ */
+ public LoadFuture() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onDone(@Nullable Map<K, V> res, @Nullable Throwable err) {
+ if (super.onDone(res, err)) {
+ assert keys != null;
+
+ for (K key : keys)
+ pendingLoads.remove(key, this);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * @param key Key.
+ * @param val Loaded value.
+ */
+ public void onComplete(K key, V val) {
+ onComplete(Collections.singletonList(key), F.asMap(key, val));
+ }
+
+ /**
+ * @param keys Keys.
+ * @param res Loaded values.
+ */
+ public void onComplete(Collection<K> keys, Map<K, V> res) {
+ this.keys = keys;
+
+ onDone(res);
+ }
+
+ /**
+ * @param key Key.
+ * @param err Error.
+ */
+ public void onError(K key, Throwable err) {
+
+ }
+
+ /**
+ * @param keys Keys.
+ * @param err Error.
+ */
+ public void onError(Collection<K> keys, Throwable err) {
+ this.keys = keys;
+
+ onDone(err);
+ }
+
+ /**
+ * Gets value loaded for key k.
+ *
+ * @param key Key to load.
+ * @return Loaded value (possibly {@code null}).
+ * @throws IgniteCheckedException If load failed.
+ */
+ public V get(K key) throws IgniteCheckedException {
+ return get().get(key);
+ }
+ }
+}
[4/5] incubator-ignite git commit: # ignite-42
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
new file mode 100644
index 0000000..8c13db9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcBlobStore.java
@@ -0,0 +1,573 @@
+/*
+ * 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.cache.store.jdbc;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.marshaller.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.*;
+import org.gridgain.grid.util.tostring.*;
+import org.gridgain.grid.util.typedef.*;
+import org.gridgain.grid.util.typedef.internal.*;
+import org.jdk8.backport.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.integration.*;
+import javax.sql.*;
+import java.sql.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ * {@link org.apache.ignite.cache.store.CacheStore} implementation backed by JDBC. This implementation
+ * stores objects in underlying database in {@code BLOB} format.
+ * <p>
+ * Store will create table {@code ENTRIES} in the database to store data.
+ * Table will have {@code key} and {@code val} fields.
+ * <p>
+ * If custom DDL and DML statements are provided, table and field names have
+ * to be consistent for all statements and sequence of parameters have to be
+ * preserved.
+ * <h2 class="header">Configuration</h2>
+ * Sections below describe mandatory and optional configuration settings as well
+ * as providing example using Java and Spring XML.
+ * <h3>Mandatory</h3>
+ * There are no mandatory configuration parameters.
+ * <h3>Optional</h3>
+ * <ul>
+ * <li>Data source (see {@link #setDataSource(DataSource)}</li>
+ * <li>Connection URL (see {@link #setConnectionUrl(String)})</li>
+ * <li>User name (see {@link #setUser(String)})</li>
+ * <li>Password (see {@link #setPassword(String)})</li>
+ * <li>Create table query (see {@link #setConnectionUrl(String)})</li>
+ * <li>Load entry query (see {@link #setLoadQuery(String)})</li>
+ * <li>Update entry query (see {@link #setUpdateQuery(String)})</li>
+ * <li>Insert entry query (see {@link #setInsertQuery(String)})</li>
+ * <li>Delete entry query (see {@link #setDeleteQuery(String)})</li>
+ * </ul>
+ * <h2 class="header">Java Example</h2>
+ * <pre name="code" class="java">
+ * ...
+ * GridCacheJdbcBlobStore<String, String> store = new GridCacheJdbcBlobStore<String, String>();
+ * ...
+ * </pre>
+ * <h2 class="header">Spring Example</h2>
+ * <pre name="code" class="xml">
+ * ...
+ * <bean id="cache.jdbc.store"
+ * class="org.gridgain.grid.cache.store.jdbc.GridCacheJdbcBlobStore">
+ * <property name="connectionUrl" value="jdbc:h2:mem:"/>
+ * <property name="createTableQuery"
+ * value="create table if not exists ENTRIES (key other, val other)"/>
+ * </bean>
+ * ...
+ * </pre>
+ * <p>
+ * <img src="http://www.gridgain.com/images/spring-small.png">
+ * <br>
+ * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
+ */
+public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> {
+ /** Default connection URL (value is <tt>jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1</tt>). */
+ public static final String DFLT_CONN_URL = "jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1";
+
+ /**
+ * Default create table query
+ * (value is <tt>create table if not exists ENTRIES (key other primary key, val other)</tt>).
+ */
+ public static final String DFLT_CREATE_TBL_QRY = "create table if not exists ENTRIES " +
+ "(key binary primary key, val binary)";
+
+ /** Default load entry query (value is <tt>select * from ENTRIES where key=?</tt>). */
+ public static final String DFLT_LOAD_QRY = "select * from ENTRIES where key=?";
+
+ /** Default update entry query (value is <tt>select * from ENTRIES where key=?</tt>). */
+ public static final String DFLT_UPDATE_QRY = "update ENTRIES set val=? where key=?";
+
+ /** Default insert entry query (value is <tt>insert into ENTRIES (key, val) values (?, ?)</tt>). */
+ public static final String DFLT_INSERT_QRY = "insert into ENTRIES (key, val) values (?, ?)";
+
+ /** Default delete entry query (value is <tt>delete from ENTRIES where key=?</tt>). */
+ public static final String DFLT_DEL_QRY = "delete from ENTRIES where key=?";
+
+ /** Connection attribute name. */
+ private static final String ATTR_CONN = "JDBC_STORE_CONNECTION";
+
+ /** Connection URL. */
+ private String connUrl = DFLT_CONN_URL;
+
+ /** Query to create table. */
+ private String createTblQry = DFLT_CREATE_TBL_QRY;
+
+ /** Query to load entry. */
+ private String loadQry = DFLT_LOAD_QRY;
+
+ /** Query to update entry. */
+ private String updateQry = DFLT_UPDATE_QRY;
+
+ /** Query to insert entries. */
+ private String insertQry = DFLT_INSERT_QRY;
+
+ /** Query to delete entries. */
+ private String delQry = DFLT_DEL_QRY;
+
+ /** User name for database access. */
+ private String user;
+
+ /** Password for database access. */
+ @GridToStringExclude
+ private String passwd;
+
+ /** Data source. */
+ private DataSource dataSrc;
+
+ /** Flag for schema initialization. */
+ private boolean initSchema = true;
+
+ /** Log. */
+ @IgniteLoggerResource
+ private IgniteLogger log;
+
+ /** Marshaller. */
+ @IgniteMarshallerResource
+ private IgniteMarshaller marsh;
+
+ /** Init guard. */
+ @GridToStringExclude
+ private final AtomicBoolean initGuard = new AtomicBoolean();
+
+ /** Init latch. */
+ @GridToStringExclude
+ private final CountDownLatch initLatch = new CountDownLatch(1);
+
+ /** Opened connections. */
+ @GridToStringExclude
+ private final LongAdder opened = new LongAdder();
+
+ /** Closed connections. */
+ @GridToStringExclude
+ private final LongAdder closed = new LongAdder();
+
+ /** Test mode flag. */
+ @GridToStringExclude
+ private boolean testMode;
+
+ /** Successful initialization flag. */
+ private boolean initOk;
+
+ /** {@inheritDoc} */
+ @Override public void txEnd(boolean commit) {
+ init();
+
+ IgniteTx tx = transaction();
+
+ Map<Object, Object> props = session().properties();
+
+ Connection conn = (Connection)props.remove(ATTR_CONN);
+
+ if (conn != null) {
+ try {
+ if (commit)
+ conn.commit();
+ else
+ conn.rollback();
+ }
+ catch (SQLException e) {
+ throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e);
+ }
+ finally {
+ closeConnection(conn);
+ }
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"RedundantTypeArguments"})
+ @Override public V load(K key) {
+ init();
+
+ IgniteTx tx = transaction();
+
+ if (log.isDebugEnabled())
+ log.debug("Store load [key=" + key + ", tx=" + tx + ']');
+
+ Connection conn = null;
+
+ PreparedStatement stmt = null;
+
+ try {
+ conn = connection(tx);
+
+ stmt = conn.prepareStatement(loadQry);
+
+ stmt.setObject(1, toBytes(key));
+
+ ResultSet rs = stmt.executeQuery();
+
+ if (rs.next())
+ return fromBytes(rs.getBytes(2));
+ }
+ catch (IgniteCheckedException | SQLException e) {
+ throw new CacheLoaderException("Failed to load object: " + key, e);
+ }
+ finally {
+ end(tx, conn, stmt);
+ }
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void put(K key, V val) {
+ init();
+
+ IgniteTx tx = transaction();
+
+ if (log.isDebugEnabled())
+ log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
+
+ Connection conn = null;
+
+ PreparedStatement stmt = null;
+
+ try {
+ conn = connection(tx);
+
+ stmt = conn.prepareStatement(updateQry);
+
+ stmt.setObject(1, toBytes(val));
+ stmt.setObject(2, toBytes(key));
+
+ if (stmt.executeUpdate() == 0) {
+ stmt.close();
+
+ stmt = conn.prepareStatement(insertQry);
+
+ stmt.setObject(1, toBytes(key));
+ stmt.setObject(2, toBytes(val));
+
+ stmt.executeUpdate();
+ }
+ }
+ catch (IgniteCheckedException | SQLException e) {
+ throw new CacheWriterException("Failed to put object [key=" + key + ", val=" + val + ']', e);
+ }
+ finally {
+ end(tx, conn, stmt);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(K key) {
+ init();
+
+ IgniteTx tx = transaction();
+
+ if (log.isDebugEnabled())
+ log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
+
+ Connection conn = null;
+
+ PreparedStatement stmt = null;
+
+ try {
+ conn = connection(tx);
+
+ stmt = conn.prepareStatement(delQry);
+
+ stmt.setObject(1, toBytes(key));
+
+ stmt.executeUpdate();
+ }
+ catch (IgniteCheckedException | SQLException e) {
+ throw new CacheWriterException("Failed to remove object: " + key, e);
+ }
+ finally {
+ end(tx, conn, stmt);
+ }
+ }
+
+ /**
+ * @param tx Cache transaction.
+ * @return Connection.
+ * @throws SQLException In case of error.
+ */
+ private Connection connection(@Nullable IgniteTx tx) throws SQLException {
+ if (tx != null) {
+ Map<Object, Object> props = session().properties();
+
+ Connection conn = (Connection)props.get(ATTR_CONN);
+
+ if (conn == null) {
+ conn = openConnection(false);
+
+ // Store connection in session properties, so it can be accessed
+ // for other operations on the same transaction.
+ props.put(ATTR_CONN, conn);
+ }
+
+ return conn;
+ }
+ // Transaction can be null in case of simple load operation.
+ else
+ return openConnection(true);
+ }
+
+ /**
+ * Closes allocated resources depending on transaction status.
+ *
+ * @param tx Active transaction, if any.
+ * @param conn Allocated connection.
+ * @param st Created statement,
+ */
+ private void end(@Nullable IgniteTx tx, Connection conn, Statement st) {
+ U.closeQuiet(st);
+
+ if (tx == null)
+ // Close connection right away if there is no transaction.
+ closeConnection(conn);
+ }
+
+ /**
+ * Gets connection from a pool.
+ *
+ * @param autocommit {@code true} If connection should use autocommit mode.
+ * @return Pooled connection.
+ * @throws SQLException In case of error.
+ */
+ private Connection openConnection(boolean autocommit) throws SQLException {
+ Connection conn = dataSrc != null ? dataSrc.getConnection() :
+ DriverManager.getConnection(connUrl, user, passwd);
+
+ if (testMode)
+ opened.increment();
+
+ conn.setAutoCommit(autocommit);
+
+ return conn;
+ }
+
+ /**
+ * Closes connection.
+ *
+ * @param conn Connection to close.
+ */
+ private void closeConnection(Connection conn) {
+ U.closeQuiet(conn);
+
+ if (testMode)
+ closed.increment();
+ }
+
+ /**
+ * Initializes store.
+ *
+ * @throws IgniteException If failed to initialize.
+ */
+ private void init() {
+ if (initLatch.getCount() > 0) {
+ if (initGuard.compareAndSet(false, true)) {
+ if (log.isDebugEnabled())
+ log.debug("Initializing cache store.");
+
+ if (F.isEmpty(connUrl))
+ throw new IgniteException("Failed to initialize cache store (connection URL is not provided).");
+
+ if (!initSchema) {
+ initLatch.countDown();
+
+ return;
+ }
+
+ if (F.isEmpty(createTblQry))
+ throw new IgniteException("Failed to initialize cache store (create table query is not provided).");
+
+ Connection conn = null;
+
+ Statement stmt = null;
+
+ try {
+ conn = openConnection(false);
+
+ stmt = conn.createStatement();
+
+ stmt.execute(createTblQry);
+
+ conn.commit();
+
+ initOk = true;
+ }
+ catch (SQLException e) {
+ throw new IgniteException("Failed to create database table.", e);
+ }
+ finally {
+ U.closeQuiet(stmt);
+
+ closeConnection(conn);
+
+ initLatch.countDown();
+ }
+ }
+ else {
+ try {
+ U.await(initLatch);
+ }
+ catch (GridInterruptedException e) {
+ throw new IgniteException(e);
+ }
+ }
+ }
+
+ if (!initOk)
+ throw new IgniteException("Cache store was not properly initialized.");
+ }
+
+ /**
+ * Flag indicating whether DB schema should be initialized by GridGain (default behaviour) or
+ * was explicitly created by user.
+ *
+ * @param initSchema {@code True} if DB schema should be initialized by GridGain (default behaviour),
+ * {code @false} if schema was explicitly created by user.
+ */
+ public void setInitSchema(boolean initSchema) {
+ this.initSchema = initSchema;
+ }
+
+ /**
+ * Sets connection URL.
+ *
+ * @param connUrl Connection URL.
+ */
+ public void setConnectionUrl(String connUrl) {
+ this.connUrl = connUrl;
+ }
+
+ /**
+ * Sets create table query.
+ *
+ * @param createTblQry Create table query.
+ */
+ public void setCreateTableQuery(String createTblQry) {
+ this.createTblQry = createTblQry;
+ }
+
+ /**
+ * Sets load query.
+ *
+ * @param loadQry Load query
+ */
+ public void setLoadQuery(String loadQry) {
+ this.loadQry = loadQry;
+ }
+
+ /**
+ * Sets update entry query.
+ *
+ * @param updateQry Update entry query.
+ */
+ public void setUpdateQuery(String updateQry) {
+ this.updateQry = updateQry;
+ }
+
+ /**
+ * Sets insert entry query.
+ *
+ * @param insertQry Insert entry query.
+ */
+ public void setInsertQuery(String insertQry) {
+ this.insertQry = insertQry;
+ }
+
+ /**
+ * Sets delete entry query.
+ *
+ * @param delQry Delete entry query.
+ */
+ public void setDeleteQuery(String delQry) {
+ this.delQry = delQry;
+ }
+
+ /**
+ * Sets user name for database access.
+ *
+ * @param user User name.
+ */
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ /**
+ * Sets password for database access.
+ *
+ * @param passwd Password.
+ */
+ public void setPassword(String passwd) {
+ this.passwd = passwd;
+ }
+
+ /**
+ * Sets data source. Data source should be fully configured and ready-to-use.
+ * <p>
+ * Note that if data source is provided, all connections will be
+ * acquired via this data source. If data source is not provided, a new connection
+ * will be created for each store call ({@code connectionUrl},
+ * {@code user} and {@code password} parameters will be used).
+ *
+ * @param dataSrc Data source.
+ */
+ public void setDataSource(DataSource dataSrc) {
+ this.dataSrc = dataSrc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(CacheJdbcBlobStore.class, this, "passwd", passwd != null ? "*" : null);
+ }
+
+ /**
+ * Serialize object to byte array using marshaller.
+ *
+ * @param obj Object to convert to byte array.
+ * @return Byte array.
+ * @throws IgniteCheckedException If failed to convert.
+ */
+ protected byte[] toBytes(Object obj) throws IgniteCheckedException {
+ return marsh.marshal(obj);
+ }
+
+ /**
+ * Deserialize object from byte array using marshaller.
+ *
+ * @param bytes Bytes to deserialize.
+ * @param <X> Result object type.
+ * @return Deserialized object.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
+ if (bytes == null || bytes.length == 0)
+ return null;
+
+ return marsh.unmarshal(bytes, getClass().getClassLoader());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/package.html b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/package.html
new file mode 100644
index 0000000..50755cd
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/package.html
@@ -0,0 +1,24 @@
+<!--
+ 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.
+ -->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<body>
+ <!-- Package description. -->
+ Contains reference JDBC-based cache store implementation.
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/apache/ignite/cache/store/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/package.html b/modules/core/src/main/java/org/apache/ignite/cache/store/package.html
new file mode 100644
index 0000000..8f597d7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/package.html
@@ -0,0 +1,23 @@
+<!--
+ 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.
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<body>
+ <!-- Package description. -->
+ Contains cache store interfaces.
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
index bc46201..95a002b 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCache.java
@@ -23,7 +23,6 @@ import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.affinity.*;
import org.gridgain.grid.cache.affinity.consistenthash.*;
import org.gridgain.grid.cache.datastructures.*;
-import org.gridgain.grid.cache.store.*;
import org.jetbrains.annotations.*;
import java.util.*;
@@ -187,14 +186,14 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {
public Iterator<Map.Entry<K, V>> offHeapIterator() throws IgniteCheckedException;
/**
- * Delegates to {@link GridCacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method
+ * Delegates to {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method
* to load state from the underlying persistent storage. The loaded values
* will then be given to the optionally passed in predicate, and, if the predicate returns
* {@code true}, will be stored in cache. If predicate is {@code null}, then
* all loaded values will be stored in cache.
* <p>
* Note that this method does not receive keys as a parameter, so it is up to
- * {@link GridCacheStore} implementation to provide all the data to be loaded.
+ * {@link org.apache.ignite.cache.store.CacheStore} implementation to provide all the data to be loaded.
* <p>
* This method is not transactional and may end up loading a stale value into
* cache if another thread has updated the value immediately after it has been
@@ -205,20 +204,20 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {
* filter values to be put into cache.
* @param ttl Time to live for loaded entries ({@code 0} for infinity).
* @param args Optional user arguments to be passed into
- * {@link GridCacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method.
+ * {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method.
* @throws IgniteCheckedException If loading failed.
*/
public void loadCache(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args) throws IgniteCheckedException;
/**
- * Asynchronously delegates to {@link GridCacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method
+ * Asynchronously delegates to {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} method
* to reload state from the underlying persistent storage. The reloaded values
* will then be given to the optionally passed in predicate, and if the predicate returns
* {@code true}, will be stored in cache. If predicate is {@code null}, then
* all reloaded values will be stored in cache.
* <p>
* Note that this method does not receive keys as a parameter, so it is up to
- * {@link GridCacheStore} implementation to provide all the data to be loaded.
+ * {@link org.apache.ignite.cache.store.CacheStore} implementation to provide all the data to be loaded.
* <p>
* This method is not transactional and may end up loading a stale value into
* cache if another thread has updated the value immediately after it has been
@@ -229,7 +228,7 @@ public interface GridCache<K, V> extends GridCacheProjection<K, V> {
* filter values to be put into cache.
* @param ttl Time to live for loaded entries ({@code 0} for infinity).
* @param args Optional user arguments to be passed into
- * {@link GridCacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method.
+ * {@link org.apache.ignite.cache.store.CacheStore#loadCache(org.apache.ignite.lang.IgniteBiInClosure,Object...)} method.
* @return Future to be completed whenever loading completes.
*/
public IgniteFuture<?> loadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, long ttl, @Nullable Object... args);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
index fe0deea..95e3523 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheConfiguration.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.cache;
import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.portables.PortableObject;
import org.apache.ignite.spi.indexing.*;
@@ -28,7 +29,6 @@ import org.gridgain.grid.cache.cloner.*;
import org.gridgain.grid.cache.datastructures.*;
import org.gridgain.grid.cache.eviction.*;
import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.jetbrains.annotations.*;
@@ -236,7 +236,7 @@ public class GridCacheConfiguration extends MutableConfiguration {
private GridCacheWriteSynchronizationMode writeSync;
/** */
- private GridCacheStore<?, ?> store;
+ private CacheStore<?, ?> store;
/** Node group resolver. */
private GridCacheAffinityFunction aff;
@@ -794,8 +794,8 @@ public class GridCacheConfiguration extends MutableConfiguration {
* @return Underlying persistent storage for read-through and write-through operations.
*/
@SuppressWarnings({"unchecked"})
- public <K, V> GridCacheStore<K, V> getStore() {
- return (GridCacheStore<K, V>)store;
+ public <K, V> CacheStore<K, V> getStore() {
+ return (CacheStore<K, V>)store;
}
/**
@@ -803,7 +803,7 @@ public class GridCacheConfiguration extends MutableConfiguration {
*
* @param store Persistent cache store.
*/
- public <K, V> void setStore(GridCacheStore<K, V> store) {
+ public <K, V> void setStore(CacheStore<K, V> store) {
this.store = store;
}
@@ -1241,8 +1241,8 @@ public class GridCacheConfiguration extends MutableConfiguration {
/**
* Maximum batch size for write-behind cache store operations. Store operations (get or remove)
* are combined in a batch of this size to be passed to
- * {@link GridCacheStore#putAll(IgniteTx, Map)} or
- * {@link GridCacheStore#removeAll(IgniteTx, Collection)} methods.
+ * {@link org.apache.ignite.cache.store.CacheStore#putAll(IgniteTx, Map)} or
+ * {@link org.apache.ignite.cache.store.CacheStore#removeAll(IgniteTx, Collection)} methods.
* <p/>
* If not provided, default value is {@link #DFLT_WRITE_BEHIND_BATCH_SIZE}.
*
@@ -1659,7 +1659,7 @@ public class GridCacheConfiguration extends MutableConfiguration {
}
/**
- * Flag indicating that {@link GridCacheStore} implementation
+ * Flag indicating that {@link org.apache.ignite.cache.store.CacheStore} implementation
* is working with portable objects instead of Java objects
* if portable mode for this cache is enabled ({@link #isPortableEnabled()}
* flag is {@code true}). Default value of this flag is {@code true},
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
index 6dbb607..5a4fb32 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/GridCacheProjection.java
@@ -23,7 +23,6 @@ import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.affinity.*;
import org.gridgain.grid.cache.query.*;
-import org.gridgain.grid.cache.store.*;
import org.jetbrains.annotations.*;
import java.sql.*;
@@ -378,7 +377,7 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
/**
* Reloads a single key from persistent storage. This method
- * delegates to {@link GridCacheStore#load(IgniteTx, Object)}
+ * delegates to {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)}
* method.
* <h2 class="header">Transactions</h2>
* This method does not participate in transactions, however it does not violate
@@ -392,7 +391,7 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
/**
* Asynchronously reloads a single key from persistent storage. This method
- * delegates to {@link GridCacheStore#load(IgniteTx, Object)}
+ * delegates to {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)}
* method.
* <h2 class="header">Transactions</h2>
* This method does not participate in transactions, however it does not violate
@@ -492,8 +491,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* <p>
* If the value is not present in cache, then it will be looked up from swap storage. If
* it's not present in swap, or if swap is disable, and if read-through is allowed, value
- * will be loaded from {@link GridCacheStore} persistent storage via
- * {@link GridCacheStore#load(IgniteTx, Object)} method.
+ * will be loaded from {@link org.apache.ignite.cache.store.CacheStore} persistent storage via
+ * {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -517,8 +516,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* <p>
* If the value is not present in cache, then it will be looked up from swap storage. If
* it's not present in swap, or if swap is disabled, and if read-through is allowed, value
- * will be loaded from {@link GridCacheStore} persistent storage via
- * {@link GridCacheStore#load(IgniteTx, Object)} method.
+ * will be loaded from {@link org.apache.ignite.cache.store.CacheStore} persistent storage via
+ * {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -541,8 +540,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* <p>
* If some value is not present in cache, then it will be looked up from swap storage. If
* it's not present in swap, or if swap is disabled, and if read-through is allowed, value
- * will be loaded from {@link GridCacheStore} persistent storage via
- * {@link GridCacheStore#loadAll(IgniteTx, Collection, org.apache.ignite.lang.IgniteBiInClosure)} method.
+ * will be loaded from {@link org.apache.ignite.cache.store.CacheStore} persistent storage via
+ * {@link org.apache.ignite.cache.store.CacheStore#loadAll(IgniteTx, Collection, org.apache.ignite.lang.IgniteBiInClosure)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -565,8 +564,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* <p>
* If some value is not present in cache, then it will be looked up from swap storage. If
* it's not present in swap, or if swap is disabled, and if read-through is allowed, value
- * will be loaded from {@link GridCacheStore} persistent storage via
- * {@link GridCacheStore#loadAll(IgniteTx, Collection, org.apache.ignite.lang.IgniteBiInClosure)} method.
+ * will be loaded from {@link org.apache.ignite.cache.store.CacheStore} persistent storage via
+ * {@link org.apache.ignite.cache.store.CacheStore#loadAll(IgniteTx, Collection, org.apache.ignite.lang.IgniteBiInClosure)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -588,13 +587,13 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} should
* always be used instead of this one to avoid the overhead associated with returning of the previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -623,17 +622,17 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* previously contained value for the given key, then this value is returned. Otherwise,
* in case of {@link GridCacheMode#REPLICATED} caches, the value will be loaded from swap
* and, if it's not there, and read-through is allowed, from the underlying
- * {@link GridCacheStore} storage. In case of {@link GridCacheMode#PARTITIONED} caches,
+ * {@link org.apache.ignite.cache.store.CacheStore} storage. In case of {@link GridCacheMode#PARTITIONED} caches,
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap and read-through is allowed,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])} should
* always be used instead of this one to avoid the overhead associated with returning of the previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -661,8 +660,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* value and, therefore, does not have any overhead associated with returning a value. It
* should be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -694,8 +693,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* value and, therefore, does not have any overhead associated with returning of a value. It
* should always be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -722,14 +721,14 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putxIfAbsent(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -753,14 +752,14 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #putxIfAbsentAsync(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -785,8 +784,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* value and, therefore, does not have any overhead associated with returning of a value. It
* should always be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -811,8 +810,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* value and, therefore, does not have any overhead associated with returning of a value. It
* should always be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -834,14 +833,14 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #replacex(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -864,14 +863,14 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* {@link GridCacheMode#PARTITIONED} caches, the value will be loaded from the primary node,
* which in its turn may load the value from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #replacex(Object, Object)} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -895,8 +894,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* value and, therefore, does not have any overhead associated with returning of a value. It
* should always be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -921,8 +920,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* value and, therefore, does not have any overhead associated with returning of a value. It
* should always be used whenever return value is not required.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -944,8 +943,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* <p>
* This method will return {@code true} if value is stored in cache and {@code false} otherwise.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -969,8 +968,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* <p>
* This method will return {@code true} if value is stored in cache and {@code false} otherwise.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -992,8 +991,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* be stored in cache only if they pass the filter. Note that filter check is atomic,
* so value stored in cache is guaranteed to be consistent with the filters.
* <p>
- * If write-through is enabled, the stored values will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#putAll(IgniteTx, Map)} method.
+ * If write-through is enabled, the stored values will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#putAll(IgniteTx, Map)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1015,8 +1014,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* be stored in cache only if they pass the filter. Note that filter check is atomic,
* so value stored in cache is guaranteed to be consistent with the filters.
* <p>
- * If write-through is enabled, the stored values will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#putAll(IgniteTx, Map)} method.
+ * If write-through is enabled, the stored values will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#putAll(IgniteTx, Map)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1404,14 +1403,14 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* caches, the value will be loaded from the primary node, which in its turn may load the value
* from the disk-based swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #removex(Object, org.apache.ignite.lang.IgnitePredicate[])} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1437,14 +1436,14 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* caches, the value will be loaded from the primary node, which in its turn may load the value
* from the swap storage, and consecutively, if it's not in swap,
* from the underlying persistent storage. If value has to be loaded from persistent
- * storage, {@link GridCacheStore#load(IgniteTx, Object)} method will be used.
+ * storage, {@link org.apache.ignite.cache.store.CacheStore#load(IgniteTx, Object)} method will be used.
* <p>
* If the returned value is not needed, method {@link #removex(Object, org.apache.ignite.lang.IgnitePredicate[])} should
* always be used instead of this one to avoid the overhead associated with returning of the
* previous value.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1467,8 +1466,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* This method will return {@code true} if remove did occur, which means that all optionally
* provided filters have passed and there was something to remove, {@code false} otherwise.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1494,8 +1493,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* This method will return {@code true} if remove did occur, which means that all optionally
* provided filters have passed and there was something to remove, {@code false} otherwise.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1518,8 +1517,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
/**
* Removes given key mapping from cache if one exists and value is equal to the passed in value.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1543,8 +1542,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* This method will return {@code true} if remove did occur, which means that all optionally
* provided filters have passed and there was something to remove, {@code false} otherwise.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1565,8 +1564,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* Removes given key mappings from cache for entries for which the optionally passed in filters do
* pass.
* <p>
- * If write-through is enabled, the values will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#removeAll(IgniteTx, Collection)} method.
+ * If write-through is enabled, the values will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#removeAll(IgniteTx, Collection)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1587,8 +1586,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* Asynchronously removes given key mappings from cache for entries for which the optionally
* passed in filters do pass.
* <p>
- * If write-through is enabled, the values will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#removeAll(IgniteTx, Collection)} method.
+ * If write-through is enabled, the values will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#removeAll(IgniteTx, Collection)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1616,8 +1615,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* are acquired in undefined order, so it may cause a deadlock when used with
* other concurrent transactional updates.
* <p>
- * If write-through is enabled, the values will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#removeAll(IgniteTx, Collection)} method.
+ * If write-through is enabled, the values will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#removeAll(IgniteTx, Collection)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -1641,8 +1640,8 @@ public interface GridCacheProjection<K, V> extends Iterable<GridCacheEntry<K, V>
* <b>USE WITH CARE</b> - if your cache has many entries that pass through the filter or if filter
* is empty, then transaction will quickly become very heavy and slow.
* <p>
- * If write-through is enabled, the values will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#removeAll(IgniteTx, Collection)} method.
+ * If write-through is enabled, the values will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#removeAll(IgniteTx, Collection)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapter.java b/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapter.java
deleted file mode 100644
index dcd7508..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapter.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store;
-
-import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-import static java.util.concurrent.TimeUnit.*;
-
-/**
- * This adepter designed to support stores with bulk loading from stream-like source.
- * <p>
- * This class processes input data in the following way:
- * <ul>
- * <li>
- * Iterator of input record obtained from user-defined {@link #inputIterator(Object...)}.
- * </li>
- * <li>
- * Iterator continuously queried for input records and they are grouped into batches of {@link #batchSize}.
- * </li>
- * <li>
- * Batch is placed into processing queue and puled by one of {@link #threadsCnt} working threads.
- * </li>
- * <li>
- * Each record in batch is passed to user-defined {@link #parse(Object, Object...)} method
- * and result is stored into cache.
- * </li>
- * </ul>
- * <p>
- * Two methods should be implemented by inheritants:
- * <ul>
- * <li>
- * {@link #inputIterator(Object...)}. It should open underlying data source
- * and iterate all record available in it. Individual records could be in very raw form,
- * like text lines for CSV files.
- * </li>
- * <li>
- * {@link #parse(Object, Object...)}. This method should process input records
- * and transform them into key-value pairs for cache.
- * </li>
- * </ul>
- * <p>
- *
- * @param <K> Key type.
- * @param <V> Value type.
- * @param <I> Input type.
- */
-public abstract class GridCacheLoadOnlyStoreAdapter<K, V, I> implements GridCacheStore<K, V> {
- /**
- * Default batch size (number of records read with {@link #inputIterator(Object...)}
- * and then submitted to internal pool at a time).
- */
- public static final int DFLT_BATCH_SIZE = 100;
-
- /** Default batch queue size (max batches count to limit memory usage). */
- public static final int DFLT_BATCH_QUEUE_SIZE = 100;
-
- /** Default number of working threads (equal to the number of available processors). */
- public static final int DFLT_THREADS_COUNT = Runtime.getRuntime().availableProcessors();
-
- /** Auto-injected logger. */
- @IgniteLoggerResource
- private IgniteLogger log;
-
- /** Batch size. */
- private int batchSize = DFLT_BATCH_SIZE;
-
- /** Size of queue of batches to process. */
- private int batchQueueSize = DFLT_BATCH_QUEUE_SIZE;
-
- /** Number fo working threads. */
- private int threadsCnt = DFLT_THREADS_COUNT;
-
- /**
- * Returns iterator of input records.
- * <p>
- * Note that returned iterator doesn't have to be thread-safe. Thus it could
- * operate on raw streams, DB connections, etc. without additional synchronization.
- *
- * @param args Arguments passes into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
- * @return Iterator over input records.
- * @throws IgniteCheckedException If iterator can't be created with the given arguments.
- */
- protected abstract Iterator<I> inputIterator(@Nullable Object... args) throws IgniteCheckedException;
-
- /**
- * This method should transform raw data records into valid key-value pairs
- * to be stored into cache.
- * <p>
- * If {@code null} is returned then this record will be just skipped.
- *
- * @param rec A raw data record.
- * @param args Arguments passed into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
- * @return Cache entry to be saved in cache or {@code null} if no entry could be produced from this record.
- */
- @Nullable protected abstract IgniteBiTuple<K, V> parse(I rec, @Nullable Object... args);
-
- /** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<K, V> c, @Nullable Object... args)
- throws IgniteCheckedException {
- ExecutorService exec = new ThreadPoolExecutor(
- threadsCnt,
- threadsCnt,
- 0L,
- MILLISECONDS,
- new ArrayBlockingQueue<Runnable>(batchQueueSize),
- new BlockingRejectedExecutionHandler());
-
- Iterator<I> iter = inputIterator(args);
-
- Collection<I> buf = new ArrayList<>(batchSize);
-
- try {
- while (iter.hasNext()) {
- if (Thread.currentThread().isInterrupted()) {
- U.warn(log, "Working thread was interrupted while loading data.");
-
- break;
- }
-
- buf.add(iter.next());
-
- if (buf.size() == batchSize) {
- exec.submit(new Worker(c, buf, args));
-
- buf = new ArrayList<>(batchSize);
- }
- }
-
- if (!buf.isEmpty())
- exec.submit(new Worker(c, buf, args));
- }
- catch (RejectedExecutionException ignored) {
- // Because of custom RejectedExecutionHandler.
- assert false : "RejectedExecutionException was thrown while it shouldn't.";
- }
- finally {
- exec.shutdown();
-
- try {
- exec.awaitTermination(Long.MAX_VALUE, MILLISECONDS);
- }
- catch (InterruptedException ignored) {
- U.warn(log, "Working thread was interrupted while waiting for put operations to complete.");
-
- Thread.currentThread().interrupt();
- }
- }
- }
-
- /**
- * Returns batch size.
- *
- * @return Batch size.
- */
- public int getBatchSize() {
- return batchSize;
- }
-
- /**
- * Sets batch size.
- *
- * @param batchSize Batch size.
- */
- public void setBatchSize(int batchSize) {
- this.batchSize = batchSize;
- }
-
- /**
- * Returns batch queue size.
- *
- * @return Batch queue size.
- */
- public int getBatchQueueSize() {
- return batchQueueSize;
- }
-
- /**
- * Sets batch queue size.
- *
- * @param batchQueueSize Batch queue size.
- */
- public void setBatchQueueSize(int batchQueueSize) {
- this.batchQueueSize = batchQueueSize;
- }
-
- /**
- * Returns number of worker threads.
- *
- * @return Number of worker threads.
- */
- public int getThreadsCount() {
- return threadsCnt;
- }
-
- /**
- * Sets number of worker threads.
- *
- * @param threadsCnt Number of worker threads.
- */
- public void setThreadsCount(int threadsCnt) {
- this.threadsCnt = threadsCnt;
- }
-
- /** {@inheritDoc} */
- @Override public V load(@Nullable IgniteTx tx, K key)
- throws IgniteCheckedException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx,
- @Nullable Collection<? extends K> keys, IgniteBiInClosure<K, V> c) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, K key, @Nullable V val) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, @Nullable Map<? extends K, ? extends V> map)
- throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx, @Nullable Collection<? extends K> keys)
- throws IgniteCheckedException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
- // No-op.
- }
-
- /**
- * Worker.
- */
- private class Worker implements Runnable {
- /** */
- private final IgniteBiInClosure<K, V> c;
-
- /** */
- private final Collection<I> buf;
-
- /** */
- private final Object[] args;
-
- /**
- * @param c Closure for loaded entries.
- * @param buf Set of input records to process.
- * @param args Arguments passed into {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
- */
- Worker(IgniteBiInClosure<K, V> c, Collection<I> buf, Object[] args) {
- this.c = c;
- this.buf = buf;
- this.args = args;
- }
-
- /** {@inheritDoc} */
- @Override public void run() {
- for (I rec : buf) {
- IgniteBiTuple<K, V> entry = parse(rec, args);
-
- if (entry != null)
- c.apply(entry.getKey(), entry.getValue());
- }
- }
- }
-
- /**
- * This handler blocks the caller thread until free space will be available in tasks queue.
- * If the executor is shut down than it throws {@link RejectedExecutionException}.
- * <p>
- * It is save to apply this policy when:
- * <ol>
- * <li>{@code shutdownNow} is not used on the pool.</li>
- * <li>{@code shutdown} is called from the thread where all submissions where performed.</li>
- * </ol>
- */
- private class BlockingRejectedExecutionHandler implements RejectedExecutionHandler {
- /** {@inheritDoc} */
- @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
- try {
- if (executor.isShutdown())
- throw new RejectedExecutionException();
- else
- executor.getQueue().put(r);
- }
- catch (InterruptedException ignored) {
- U.warn(log, "Working thread was interrupted while loading data.");
-
- Thread.currentThread().interrupt();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLocalStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLocalStore.java b/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLocalStore.java
deleted file mode 100644
index 31f3672..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheLocalStore.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store;
-
-import java.lang.annotation.*;
-
-/**
- * Annotation for local {@link GridCacheStore} implementation. "Local" here means that there is no global
- * database behind the grid but each node has an independent one.
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface GridCacheLocalStore {
- // No-op.
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStore.java b/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStore.java
deleted file mode 100644
index e2f4cc6..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStore.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store;
-
-import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.portables.*;
-import org.apache.ignite.transactions.*;
-import org.gridgain.grid.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.jdbc.*;
-import org.jetbrains.annotations.*;
-
-import java.sql.*;
-import java.util.*;
-import java.util.Date;
-
-/**
- * API for cache persistent storage for read-through and write-through behavior.
- * Persistent store is configured via {@link GridCacheConfiguration#getStore()}
- * configuration property. If not provided, values will be only kept in cache memory
- * or swap storage without ever being persisted to a persistent storage.
- * <p>
- * {@link GridCacheStoreAdapter} provides default implementation for bulk operations,
- * such as {@link #loadAll(IgniteTx, Collection, org.apache.ignite.lang.IgniteBiInClosure)},
- * {@link #putAll(IgniteTx, Map)}, and {@link #removeAll(IgniteTx, Collection)}
- * by sequentially calling corresponding {@link #load(IgniteTx, Object)},
- * {@link #put(IgniteTx, Object, Object)}, and {@link #remove(IgniteTx, Object)}
- * operations. Use this adapter whenever such behaviour is acceptable. However
- * in many cases it maybe more preferable to take advantage of database batch update
- * functionality, and therefore default adapter implementation may not be the best option.
- * <p>
- * Provided implementations may be used for test purposes:
- * <ul>
- * <li>{@gglink org.gridgain.grid.cache.store.hibernate.GridCacheHibernateBlobStore}</li>
- * <li>{@link GridCacheJdbcBlobStore}</li>
- * </ul>
- * <p>
- * All transactional operations of this API are provided with ongoing {@link IgniteTx},
- * if any. As transaction is {@link GridMetadataAware}, you can attach any metadata to
- * it, e.g. to recognize if several operations belong to the same transaction or not.
- * Here is an example of how attach a JDBC connection as transaction metadata:
- * <pre name="code" class="java">
- * Connection conn = tx.meta("some.name");
- *
- * if (conn == null) {
- * conn = ...; // Get JDBC connection.
- *
- * // Store connection in transaction metadata, so it can be accessed
- * // for other operations on the same transaction.
- * tx.addMeta("some.name", conn);
- * }
- * </pre>
- * <h1 class="header">Working With Portable Objects</h1>
- * When portables are enabled for cache by setting {@link GridCacheConfiguration#isPortableEnabled()} to
- * {@code true}), all portable keys and values are converted to instances of {@link PortableObject}.
- * Therefore, all cache store methods will take parameters in portable format. To avoid class
- * cast exceptions, store must have signature compatible with portables. E.g., if you use {@link Integer}
- * as a key and {@code Value} class as a value (which will be converted to portable format), cache store
- * signature should be the following:
- * <pre name="code" class="java">
- * public class PortableCacheStore implements GridCacheStore<Integer, GridPortableObject> {
- * public void put(@Nullable GridCacheTx tx, Integer key, GridPortableObject val) throws IgniteCheckedException {
- * ...
- * }
- *
- * ...
- * }
- * </pre>
- * This behavior can be overridden by setting {@link GridCacheConfiguration#setKeepPortableInStore(boolean)}
- * flag value to {@code false}. In this case, GridGain will deserialize keys and values stored in portable
- * format before they are passed to cache store, so that you can use the following cache store signature instead:
- * <pre name="code" class="java">
- * public class ObjectsCacheStore implements GridCacheStore<Integer, Person> {
- * public void put(@Nullable GridCacheTx tx, Integer key, Person val) throws GridException {
- * ...
- * }
- *
- * ...
- * }
- * </pre>
- * Note that while this can simplify store implementation in some cases, it will cause performance degradation
- * due to additional serializations and deserializations of portable objects. You will also need to have key
- * and value classes on all nodes since portables will be deserialized when store is invoked.
- * <p>
- * Note that only portable classes are converted to {@link PortableObject} format. Following
- * types are stored in cache without changes and therefore should not affect cache store signature:
- * <ul>
- * <li>All primitives (byte, int, ...) and there boxed versions (Byte, Integer, ...)</li>
- * <li>Arrays of primitives (byte[], int[], ...)</li>
- * <li>{@link String} and array of {@link String}s</li>
- * <li>{@link UUID} and array of {@link UUID}s</li>
- * <li>{@link Date} and array of {@link Date}s</li>
- * <li>{@link Timestamp} and array of {@link Timestamp}s</li>
- * <li>Enums and array of enums</li>
- * <li>
- * Maps, collections and array of objects (but objects inside
- * them will still be converted if they are portable)
- * </li>
- * </ul>
- *
- * @see org.apache.ignite.IgnitePortables
- */
-public interface GridCacheStore<K, V> {
- /**
- * Loads value for the key from underlying persistent storage.
- *
- * @param tx Cache transaction.
- * @param key Key to load.
- * @return Loaded value or {@code null} if value was not found.
- * @throws IgniteCheckedException If load failed.
- */
- @Nullable public V load(@Nullable IgniteTx tx, K key) throws IgniteCheckedException;
-
- /**
- * Loads all values from underlying persistent storage. Note that keys are not
- * passed, so it is up to implementation to figure out what to load. This method
- * is called whenever {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)}
- * method is invoked which is usually to preload the cache from persistent storage.
- * <p>
- * This method is optional, and cache implementation does not depend on this
- * method to do anything. Default implementation of this method in
- * {@link GridCacheStoreAdapter} does nothing.
- * <p>
- * For every loaded value method {@link org.apache.ignite.lang.IgniteBiInClosure#apply(Object, Object)}
- * should be called on the passed in closure. The closure will then make sure
- * that the loaded value is stored in cache.
- *
- * @param clo Closure for loaded values.
- * @param args Arguments passes into
- * {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method.
- * @throws IgniteCheckedException If loading failed.
- */
- public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) throws IgniteCheckedException;
-
- /**
- * Loads all values for given keys and passes every value to the provided closure.
- * <p>
- * For every loaded value method {@link org.apache.ignite.lang.IgniteInClosure#apply(Object)} should be called on
- * the passed in closure. The closure will then make sure that the loaded value is stored
- * in cache.
- *
- * @param tx Cache transaction.
- * @param keys Collection of keys to load.
- * @param c Closure to call for every loaded element.
- * @throws IgniteCheckedException If load failed.
- */
- public void loadAll(@Nullable IgniteTx tx, Collection<? extends K> keys, IgniteBiInClosure<K, V> c)
- throws IgniteCheckedException;
-
- /**
- * Stores a given value in persistent storage. Note that if write-behind is configured for a
- * particular cache, transaction object passed in the cache store will be always {@code null}.
- *
- * @param tx Cache transaction, if write-behind is not enabled, {@code null} otherwise.
- * @param key Key to put.
- * @param val Value to put.
- * @throws IgniteCheckedException If put failed.
- */
- public void put(@Nullable IgniteTx tx, K key, V val) throws IgniteCheckedException;
-
- /**
- * Stores given key value pairs in persistent storage. Note that if write-behind is configured
- * for a particular cache, transaction object passed in the cache store will be always {@code null}.
- *
- * @param tx Cache transaction, if write-behind is not enabled, {@code null} otherwise.
- * @param map Values to store.
- * @throws IgniteCheckedException If store failed.
- */
- public void putAll(@Nullable IgniteTx tx, Map<? extends K, ? extends V> map) throws IgniteCheckedException;
-
- /**
- * Removes the value identified by given key from persistent storage. Note that if write-behind is
- * configured for a particular cache, transaction object passed in the cache store will be always
- * {@code null}.
- *
- * @param tx Cache transaction, if write-behind is not enabled, {@code null} otherwise.
- * @param key Key to remove.
- * @throws IgniteCheckedException If remove failed.
- */
- public void remove(@Nullable IgniteTx tx, K key) throws IgniteCheckedException;
-
- /**
- * Removes all vales identified by given keys from persistent storage. Note that if write-behind
- * is configured for a particular cache, transaction object passed in the cache store will be
- * always {@code null}.
- *
- * @param tx Cache transaction, if write-behind is not enabled, {@code null} otherwise.
- * @param keys Keys to remove.
- * @throws IgniteCheckedException If remove failed.
- */
- public void removeAll(@Nullable IgniteTx tx, Collection<? extends K> keys) throws IgniteCheckedException;
-
- /**
- * Tells store to commit or rollback a transaction depending on the value of the {@code 'commit'}
- * parameter.
- *
- * @param tx Cache transaction being ended.
- * @param commit {@code True} if transaction should commit, {@code false} for rollback.
- * @throws IgniteCheckedException If commit or rollback failed. Note that commit failure in some cases
- * may bring cache transaction into {@link IgniteTxState#UNKNOWN} which will
- * consequently cause all transacted entries to be invalidated.
- */
- public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException;
-}
[3/5] incubator-ignite git commit: # ignite-42
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreAdapter.java b/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreAdapter.java
deleted file mode 100644
index c68eddb..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreAdapter.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * Cache storage convenience adapter. It provides default implementation for bulk operations, such
- * as {@link #loadAll(IgniteTx, Collection, org.apache.ignite.lang.IgniteBiInClosure)},
- * {@link #putAll(IgniteTx, Map)}, and {@link #removeAll(IgniteTx, Collection)}
- * by sequentially calling corresponding {@link #load(IgniteTx, Object)},
- * {@link #put(IgniteTx, Object, Object)}, and {@link #remove(IgniteTx, Object)}
- * operations. Use this adapter whenever such behaviour is acceptable. However in many cases
- * it maybe more preferable to take advantage of database batch update functionality, and therefore
- * default adapter implementation may not be the best option.
- * <p>
- * Note that method {@link #loadCache(org.apache.ignite.lang.IgniteBiInClosure, Object...)} has empty
- * implementation because it is essentially up to the user to invoke it with
- * specific arguments.
- */
-public abstract class GridCacheStoreAdapter<K, V> implements GridCacheStore<K, V> {
- /** */
- @IgniteCacheSessionResource
- private CacheStoreSession ses;
-
- /**
- * @return Current session.
- */
- protected CacheStoreSession session() {
- return ses;
- }
-
- /**
- * Default empty implementation. This method needs to be overridden only if
- * {@link GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method
- * is explicitly called.
- *
- * @param clo {@inheritDoc}
- * @param args {@inheritDoc}
- * @throws IgniteCheckedException {@inheritDoc}
- */
- @Override public void loadCache(IgniteBiInClosure<K, V> clo, Object... args)
- throws IgniteCheckedException {
- /* No-op. */
- }
-
- /** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx, Collection<? extends K> keys,
- IgniteBiInClosure<K, V> c) throws IgniteCheckedException {
- assert keys != null;
-
- for (K key : keys) {
- V v = load(tx, key);
-
- if (v != null)
- c.apply(key, v);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void putAll(IgniteTx tx, Map<? extends K, ? extends V> map)
- throws IgniteCheckedException {
- assert map != null;
-
- for (Map.Entry<? extends K, ? extends V> e : map.entrySet())
- put(tx, e.getKey(), e.getValue());
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll(IgniteTx tx, Collection<? extends K> keys)
- throws IgniteCheckedException {
- assert keys != null;
-
- for (K key : keys)
- remove(tx, key);
- }
-
- /**
- * Default empty implementation for ending transactions. Note that if explicit cache
- * transactions are not used, then transactions do not have to be explicitly ended -
- * for all other cases this method should be overridden with custom commit/rollback logic.
- *
- * @param tx {@inheritDoc}
- * @param commit {@inheritDoc}
- * @throws IgniteCheckedException {@inheritDoc}
- */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
- // No-op.
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreBalancingWrapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreBalancingWrapper.java b/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreBalancingWrapper.java
deleted file mode 100644
index 65d39b4..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/GridCacheStoreBalancingWrapper.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store;
-
-import org.apache.ignite.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.transactions.*;
-import org.gridgain.grid.util.future.*;
-import org.gridgain.grid.util.typedef.*;
-import org.jdk8.backport.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-/**
- * Cache store wrapper that ensures that there will be no more that one thread loading value from underlying store.
- */
-public class GridCacheStoreBalancingWrapper<K, V> implements GridCacheStore<K, V> {
- /** */
- public static final int DFLT_LOAD_ALL_THRESHOLD = 5;
-
- /** Delegate store. */
- private GridCacheStore<K, V> delegate;
-
- /** Pending cache store loads. */
- private ConcurrentMap<K, LoadFuture> pendingLoads = new ConcurrentHashMap8<>();
-
- /** Load all threshold. */
- private int loadAllThreshold = DFLT_LOAD_ALL_THRESHOLD;
-
- /**
- * @param delegate Delegate store.
- */
- public GridCacheStoreBalancingWrapper(GridCacheStore<K, V> delegate) {
- this.delegate = delegate;
- }
-
- /**
- * @param delegate Delegate store.
- * @param loadAllThreshold Load all threshold.
- */
- public GridCacheStoreBalancingWrapper(GridCacheStore<K, V> delegate, int loadAllThreshold) {
- this.delegate = delegate;
- this.loadAllThreshold = loadAllThreshold;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public V load(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
- LoadFuture fut = pendingLoads.get(key);
-
- if (fut != null)
- return fut.get(key);
-
- fut = new LoadFuture();
-
- LoadFuture old = pendingLoads.putIfAbsent(key, fut);
-
- if (old != null)
- return old.get(key);
-
- try {
- V val = delegate.load(tx, key);
-
- fut.onComplete(key, val);
-
- return val;
- }
- catch (Throwable e) {
- fut.onError(key, e);
-
- throw e;
- }
- }
-
- /** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) throws IgniteCheckedException {
- delegate.loadCache(clo, args);
- }
-
- /** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx, Collection<? extends K> keys, final IgniteBiInClosure<K, V> c)
- throws IgniteCheckedException {
- if (keys.size() > loadAllThreshold) {
- delegate.loadAll(tx, keys, c);
-
- return;
- }
-
- Collection<K> needLoad = null;
- Map<K, LoadFuture> pending = null;
- LoadFuture span = null;
-
- for (K key : keys) {
- LoadFuture fut = pendingLoads.get(key);
-
- if (fut != null) {
- if (pending == null)
- pending = new HashMap<>();
-
- pending.put(key, fut);
- }
- else {
- // Try to concurrently add pending future.
- if (span == null)
- span = new LoadFuture();
-
- LoadFuture old = pendingLoads.putIfAbsent(key, span);
-
- if (old != null) {
- if (pending == null)
- pending = new HashMap<>();
-
- pending.put(key, old);
- }
- else {
- if (needLoad == null)
- needLoad = new ArrayList<>(keys.size());
-
- needLoad.add(key);
- }
- }
- }
-
- if (needLoad != null) {
- assert !needLoad.isEmpty();
- assert span != null;
-
- final ConcurrentMap<K, V> loaded = new ConcurrentHashMap8<>();
-
- try {
- delegate.loadAll(tx, needLoad, new CI2<K, V>() {
- @Override public void apply(K k, V v) {
- if (v != null) {
- loaded.put(k, v);
-
- c.apply(k, v);
- }
- }
- });
-
- span.onComplete(needLoad, loaded);
- }
- catch (Throwable e) {
- span.onError(needLoad, e);
-
- throw e;
- }
- }
-
- if (pending != null) {
- for (Map.Entry<K, LoadFuture> e : pending.entrySet()) {
- K key = e.getKey();
-
- c.apply(key, e.getValue().get(key));
- }
- }
- }
-
- /** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, K key, V val) throws IgniteCheckedException {
- delegate.put(tx, key, val);
- }
-
- /** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, Map<? extends K, ? extends V> map) throws IgniteCheckedException {
- delegate.putAll(tx, map);
- }
-
- /** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
- delegate.remove(tx, key);
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx, Collection<? extends K> keys) throws IgniteCheckedException {
- delegate.removeAll(tx, keys);
- }
-
- /** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
- delegate.txEnd(tx, commit);
- }
-
- /**
- *
- */
- private class LoadFuture extends GridFutureAdapter<Map<K, V>> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Collection of keys for pending cleanup. */
- private volatile Collection<K> keys;
-
- /**
- *
- */
- public LoadFuture() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean onDone(@Nullable Map<K, V> res, @Nullable Throwable err) {
- if (super.onDone(res, err)) {
- assert keys != null;
-
- for (K key : keys)
- pendingLoads.remove(key, this);
-
- return true;
- }
-
- return false;
- }
-
- /**
- * @param key Key.
- * @param val Loaded value.
- */
- public void onComplete(K key, V val) {
- onComplete(Collections.singletonList(key), F.asMap(key, val));
- }
-
- /**
- * @param keys Keys.
- * @param res Loaded values.
- */
- public void onComplete(Collection<K> keys, Map<K, V> res) {
- this.keys = keys;
-
- onDone(res);
- }
-
- /**
- * @param key Key.
- * @param err Error.
- */
- public void onError(K key, Throwable err) {
-
- }
-
- /**
- * @param keys Keys.
- * @param err Error.
- */
- public void onError(Collection<K> keys, Throwable err) {
- this.keys = keys;
-
- onDone(err);
- }
-
- /**
- * Gets value loaded for key k.
- *
- * @param key Key to load.
- * @return Loaded value (possibly {@code null}).
- * @throws IgniteCheckedException If load failed.
- */
- public V get(K key) throws IgniteCheckedException {
- return get().get(key);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStore.java b/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStore.java
deleted file mode 100644
index e7f912e..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStore.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store.jdbc;
-
-import org.apache.ignite.*;
-import org.apache.ignite.marshaller.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
-import org.gridgain.grid.util.tostring.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.jdk8.backport.*;
-import org.jetbrains.annotations.*;
-
-import javax.sql.*;
-import java.sql.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * {@link GridCacheStore} implementation backed by JDBC. This implementation
- * stores objects in underlying database in {@code BLOB} format.
- * <p>
- * Store will create table {@code ENTRIES} in the database to store data.
- * Table will have {@code key} and {@code val} fields.
- * <p>
- * If custom DDL and DML statements are provided, table and field names have
- * to be consistent for all statements and sequence of parameters have to be
- * preserved.
- * <h2 class="header">Configuration</h2>
- * Sections below describe mandatory and optional configuration settings as well
- * as providing example using Java and Spring XML.
- * <h3>Mandatory</h3>
- * There are no mandatory configuration parameters.
- * <h3>Optional</h3>
- * <ul>
- * <li>Data source (see {@link #setDataSource(DataSource)}</li>
- * <li>Connection URL (see {@link #setConnectionUrl(String)})</li>
- * <li>User name (see {@link #setUser(String)})</li>
- * <li>Password (see {@link #setPassword(String)})</li>
- * <li>Create table query (see {@link #setConnectionUrl(String)})</li>
- * <li>Load entry query (see {@link #setLoadQuery(String)})</li>
- * <li>Update entry query (see {@link #setUpdateQuery(String)})</li>
- * <li>Insert entry query (see {@link #setInsertQuery(String)})</li>
- * <li>Delete entry query (see {@link #setDeleteQuery(String)})</li>
- * </ul>
- * <h2 class="header">Java Example</h2>
- * <pre name="code" class="java">
- * ...
- * GridCacheJdbcBlobStore<String, String> store = new GridCacheJdbcBlobStore<String, String>();
- * ...
- * </pre>
- * <h2 class="header">Spring Example</h2>
- * <pre name="code" class="xml">
- * ...
- * <bean id="cache.jdbc.store"
- * class="org.gridgain.grid.cache.store.jdbc.GridCacheJdbcBlobStore">
- * <property name="connectionUrl" value="jdbc:h2:mem:"/>
- * <property name="createTableQuery"
- * value="create table if not exists ENTRIES (key other, val other)"/>
- * </bean>
- * ...
- * </pre>
- * <p>
- * <img src="http://www.gridgain.com/images/spring-small.png">
- * <br>
- * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
- */
-public class GridCacheJdbcBlobStore<K, V> extends GridCacheStoreAdapter<K, V> {
- /** Default connection URL (value is <tt>jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1</tt>). */
- public static final String DFLT_CONN_URL = "jdbc:h2:mem:jdbcCacheStore;DB_CLOSE_DELAY=-1";
-
- /**
- * Default create table query
- * (value is <tt>create table if not exists ENTRIES (key other primary key, val other)</tt>).
- */
- public static final String DFLT_CREATE_TBL_QRY = "create table if not exists ENTRIES " +
- "(key binary primary key, val binary)";
-
- /** Default load entry query (value is <tt>select * from ENTRIES where key=?</tt>). */
- public static final String DFLT_LOAD_QRY = "select * from ENTRIES where key=?";
-
- /** Default update entry query (value is <tt>select * from ENTRIES where key=?</tt>). */
- public static final String DFLT_UPDATE_QRY = "update ENTRIES set val=? where key=?";
-
- /** Default insert entry query (value is <tt>insert into ENTRIES (key, val) values (?, ?)</tt>). */
- public static final String DFLT_INSERT_QRY = "insert into ENTRIES (key, val) values (?, ?)";
-
- /** Default delete entry query (value is <tt>delete from ENTRIES where key=?</tt>). */
- public static final String DFLT_DEL_QRY = "delete from ENTRIES where key=?";
-
- /** Connection attribute name. */
- private static final String ATTR_CONN = "JDBC_STORE_CONNECTION";
-
- /** Connection URL. */
- private String connUrl = DFLT_CONN_URL;
-
- /** Query to create table. */
- private String createTblQry = DFLT_CREATE_TBL_QRY;
-
- /** Query to load entry. */
- private String loadQry = DFLT_LOAD_QRY;
-
- /** Query to update entry. */
- private String updateQry = DFLT_UPDATE_QRY;
-
- /** Query to insert entries. */
- private String insertQry = DFLT_INSERT_QRY;
-
- /** Query to delete entries. */
- private String delQry = DFLT_DEL_QRY;
-
- /** User name for database access. */
- private String user;
-
- /** Password for database access. */
- @GridToStringExclude
- private String passwd;
-
- /** Data source. */
- private DataSource dataSrc;
-
- /** Flag for schema initialization. */
- private boolean initSchema = true;
-
- /** Log. */
- @IgniteLoggerResource
- private IgniteLogger log;
-
- /** Marshaller. */
- @IgniteMarshallerResource
- private IgniteMarshaller marsh;
-
- /** Init guard. */
- @GridToStringExclude
- private final AtomicBoolean initGuard = new AtomicBoolean();
-
- /** Init latch. */
- @GridToStringExclude
- private final CountDownLatch initLatch = new CountDownLatch(1);
-
- /** Opened connections. */
- @GridToStringExclude
- private final LongAdder opened = new LongAdder();
-
- /** Closed connections. */
- @GridToStringExclude
- private final LongAdder closed = new LongAdder();
-
- /** Test mode flag. */
- @GridToStringExclude
- private boolean testMode;
-
- /** Successful initialization flag. */
- private boolean initOk;
-
- /** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
- init();
-
- Connection conn = tx.removeMeta(ATTR_CONN);
-
- if (conn != null) {
- try {
- if (commit)
- conn.commit();
- else
- conn.rollback();
- }
- catch (SQLException e) {
- throw new IgniteCheckedException("Failed to end transaction [xid=" + tx.xid() + ", commit=" + commit + ']', e);
- }
- finally {
- closeConnection(conn);
- }
- }
-
- if (log.isDebugEnabled())
- log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings({"RedundantTypeArguments"})
- @Override public V load(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
- init();
-
- if (log.isDebugEnabled())
- log.debug("Store load [key=" + key + ", tx=" + tx + ']');
-
- Connection conn = null;
-
- PreparedStatement stmt = null;
-
- try {
- conn = connection(tx);
-
- stmt = conn.prepareStatement(loadQry);
-
- stmt.setObject(1, toBytes(key));
-
- ResultSet rs = stmt.executeQuery();
-
- if (rs.next())
- return fromBytes(rs.getBytes(2));
- }
- catch (SQLException e) {
- throw new IgniteCheckedException("Failed to load object: " + key, e);
- }
- finally {
- end(tx, conn, stmt);
- }
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, K key, V val) throws IgniteCheckedException {
- init();
-
- if (log.isDebugEnabled())
- log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
-
- Connection conn = null;
-
- PreparedStatement stmt = null;
-
- try {
- conn = connection(tx);
-
- stmt = conn.prepareStatement(updateQry);
-
- stmt.setObject(1, toBytes(val));
- stmt.setObject(2, toBytes(key));
-
- if (stmt.executeUpdate() == 0) {
- stmt.close();
-
- stmt = conn.prepareStatement(insertQry);
-
- stmt.setObject(1, toBytes(key));
- stmt.setObject(2, toBytes(val));
-
- stmt.executeUpdate();
- }
- }
- catch (SQLException e) {
- throw new IgniteCheckedException("Failed to put object [key=" + key + ", val=" + val + ']', e);
- }
- finally {
- end(tx, conn, stmt);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
- init();
-
- if (log.isDebugEnabled())
- log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
-
- Connection conn = null;
-
- PreparedStatement stmt = null;
-
- try {
- conn = connection(tx);
-
- stmt = conn.prepareStatement(delQry);
-
- stmt.setObject(1, toBytes(key));
-
- stmt.executeUpdate();
- }
- catch (SQLException e) {
- throw new IgniteCheckedException("Failed to remove object: " + key, e);
- }
- finally {
- end(tx, conn, stmt);
- }
- }
-
- /**
- * @param tx Cache transaction.
- * @return Connection.
- * @throws SQLException In case of error.
- */
- private Connection connection(@Nullable IgniteTx tx) throws SQLException {
- if (tx != null) {
- Connection conn = tx.meta(ATTR_CONN);
-
- if (conn == null) {
- conn = openConnection(false);
-
- // Store connection in transaction metadata, so it can be accessed
- // for other operations on the same transaction.
- tx.addMeta(ATTR_CONN, conn);
- }
-
- return conn;
- }
- // Transaction can be null in case of simple load operation.
- else
- return openConnection(true);
- }
-
- /**
- * Closes allocated resources depending on transaction status.
- *
- * @param tx Active transaction, if any.
- * @param conn Allocated connection.
- * @param st Created statement,
- */
- private void end(@Nullable IgniteTx tx, Connection conn, Statement st) {
- U.closeQuiet(st);
-
- if (tx == null)
- // Close connection right away if there is no transaction.
- closeConnection(conn);
- }
-
- /**
- * Gets connection from a pool.
- *
- * @param autocommit {@code true} If connection should use autocommit mode.
- * @return Pooled connection.
- * @throws SQLException In case of error.
- */
- private Connection openConnection(boolean autocommit) throws SQLException {
- Connection conn = dataSrc != null ? dataSrc.getConnection() :
- DriverManager.getConnection(connUrl, user, passwd);
-
- if (testMode)
- opened.increment();
-
- conn.setAutoCommit(autocommit);
-
- return conn;
- }
-
- /**
- * Closes connection.
- *
- * @param conn Connection to close.
- */
- private void closeConnection(Connection conn) {
- U.closeQuiet(conn);
-
- if (testMode)
- closed.increment();
- }
-
- /**
- * Initializes store.
- *
- * @throws IgniteCheckedException If failed to initialize.
- */
- private void init() throws IgniteCheckedException {
- if (initLatch.getCount() > 0) {
- if (initGuard.compareAndSet(false, true)) {
- if (log.isDebugEnabled())
- log.debug("Initializing cache store.");
-
- if (F.isEmpty(connUrl))
- throw new IgniteCheckedException("Failed to initialize cache store (connection URL is not provided).");
-
- if (!initSchema) {
- initLatch.countDown();
-
- return;
- }
-
- if (F.isEmpty(createTblQry))
- throw new IgniteCheckedException("Failed to initialize cache store (create table query is not provided).");
-
- Connection conn = null;
-
- Statement stmt = null;
-
- try {
- conn = openConnection(false);
-
- stmt = conn.createStatement();
-
- stmt.execute(createTblQry);
-
- conn.commit();
-
- initOk = true;
- }
- catch (SQLException e) {
- throw new IgniteCheckedException("Failed to create database table.", e);
- }
- finally {
- U.closeQuiet(stmt);
-
- closeConnection(conn);
-
- initLatch.countDown();
- }
- }
- else
- U.await(initLatch);
- }
-
- if (!initOk)
- throw new IgniteCheckedException("Cache store was not properly initialized.");
- }
-
- /**
- * Flag indicating whether DB schema should be initialized by GridGain (default behaviour) or
- * was explicitly created by user.
- *
- * @param initSchema {@code True} if DB schema should be initialized by GridGain (default behaviour),
- * {code @false} if schema was explicitly created by user.
- */
- public void setInitSchema(boolean initSchema) {
- this.initSchema = initSchema;
- }
-
- /**
- * Sets connection URL.
- *
- * @param connUrl Connection URL.
- */
- public void setConnectionUrl(String connUrl) {
- this.connUrl = connUrl;
- }
-
- /**
- * Sets create table query.
- *
- * @param createTblQry Create table query.
- */
- public void setCreateTableQuery(String createTblQry) {
- this.createTblQry = createTblQry;
- }
-
- /**
- * Sets load query.
- *
- * @param loadQry Load query
- */
- public void setLoadQuery(String loadQry) {
- this.loadQry = loadQry;
- }
-
- /**
- * Sets update entry query.
- *
- * @param updateQry Update entry query.
- */
- public void setUpdateQuery(String updateQry) {
- this.updateQry = updateQry;
- }
-
- /**
- * Sets insert entry query.
- *
- * @param insertQry Insert entry query.
- */
- public void setInsertQuery(String insertQry) {
- this.insertQry = insertQry;
- }
-
- /**
- * Sets delete entry query.
- *
- * @param delQry Delete entry query.
- */
- public void setDeleteQuery(String delQry) {
- this.delQry = delQry;
- }
-
- /**
- * Sets user name for database access.
- *
- * @param user User name.
- */
- public void setUser(String user) {
- this.user = user;
- }
-
- /**
- * Sets password for database access.
- *
- * @param passwd Password.
- */
- public void setPassword(String passwd) {
- this.passwd = passwd;
- }
-
- /**
- * Sets data source. Data source should be fully configured and ready-to-use.
- * <p>
- * Note that if data source is provided, all connections will be
- * acquired via this data source. If data source is not provided, a new connection
- * will be created for each store call ({@code connectionUrl},
- * {@code user} and {@code password} parameters will be used).
- *
- * @param dataSrc Data source.
- */
- public void setDataSource(DataSource dataSrc) {
- this.dataSrc = dataSrc;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridCacheJdbcBlobStore.class, this, "passwd", passwd != null ? "*" : null);
- }
-
- /**
- * Serialize object to byte array using marshaller.
- *
- * @param obj Object to convert to byte array.
- * @return Byte array.
- * @throws IgniteCheckedException If failed to convert.
- */
- protected byte[] toBytes(Object obj) throws IgniteCheckedException {
- return marsh.marshal(obj);
- }
-
- /**
- * Deserialize object from byte array using marshaller.
- *
- * @param bytes Bytes to deserialize.
- * @param <X> Result object type.
- * @return Deserialized object.
- * @throws IgniteCheckedException If failed.
- */
- protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
- if (bytes == null || bytes.length == 0)
- return null;
-
- return marsh.unmarshal(bytes, getClass().getClassLoader());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/package.html b/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/package.html
deleted file mode 100644
index 50755cd..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/jdbc/package.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--
- 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.
- -->
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<body>
- <!-- Package description. -->
- Contains reference JDBC-based cache store implementation.
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/cache/store/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/store/package.html b/modules/core/src/main/java/org/gridgain/grid/cache/store/package.html
deleted file mode 100644
index 8f597d7..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/cache/store/package.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- 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.
- -->
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<body>
- <!-- Package description. -->
- Contains cache store interfaces.
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheEntryImpl.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheEntryImpl.java
new file mode 100644
index 0000000..cae6265
--- /dev/null
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheEntryImpl.java
@@ -0,0 +1,60 @@
+/*
+ * 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.gridgain.grid.kernal.processors.cache;
+
+import javax.cache.*;
+
+/**
+ *
+ */
+public class CacheEntryImpl<K, V> implements Cache.Entry<K, V> {
+ /** */
+ private final K key;
+
+ /** */
+ private final V val;
+
+ /**
+ * @param key Key.
+ * @param val Value.
+ */
+ public CacheEntryImpl(K key, V val) {
+ this.key = key;
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public K getKey() {
+ return key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public V getValue() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T unwrap(Class<T> clazz) {
+ throw new IllegalArgumentException();
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "CacheEntry [key=" + key + ", val=" + val + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheLoaderWriterStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheLoaderWriterStore.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheLoaderWriterStore.java
index d787c94..69b1ea4 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheLoaderWriterStore.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheLoaderWriterStore.java
@@ -18,22 +18,19 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.lifecycle.*;
-import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
import org.jetbrains.annotations.*;
-import javax.cache.*;
+import javax.cache.Cache;
import javax.cache.integration.*;
import java.util.*;
/**
* Store implementation wrapping {@link CacheLoader} and {@link CacheWriter}.
*/
-class GridCacheLoaderWriterStore<K, V> implements GridCacheStore<K, V>, LifecycleAware {
+class GridCacheLoaderWriterStore<K, V> implements CacheStore<K, V>, LifecycleAware {
/** */
private final CacheLoader<K, V> ldr;
@@ -75,7 +72,7 @@ class GridCacheLoaderWriterStore<K, V> implements GridCacheStore<K, V>, Lifecycl
}
/** {@inheritDoc} */
- @Nullable @Override public V load(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
+ @Nullable @Override public V load(K key) {
if (ldr == null)
return null;
@@ -83,46 +80,31 @@ class GridCacheLoaderWriterStore<K, V> implements GridCacheStore<K, V>, Lifecycl
}
/** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx, Collection<? extends K> keys, IgniteBiInClosure<K, V> c)
- throws IgniteCheckedException {
+ @Override public Map<K, V> loadAll(Iterable<? extends K> keys) {
if (ldr == null)
- return;
-
- Map<K, V> map = ldr.loadAll(keys);
+ return Collections.emptyMap();
- if (map != null) {
- for (Map.Entry<K, V> e : map.entrySet())
- c.apply(e.getKey(), e.getValue());
- }
+ return ldr.loadAll(keys);
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, K key, V val) throws IgniteCheckedException {
+ @Override public void write(Cache.Entry<? extends K, ? extends V> entry) {
if (writer == null)
return;
- writer.write(new KeyValueEntry<>(key, val));
+ writer.write(entry);
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, Map<? extends K, ? extends V> map)
- throws IgniteCheckedException {
+ @Override public void writeAll(Collection<Cache.Entry<? extends K, ? extends V>> entries) {
if (writer == null)
return;
- Collection<Cache.Entry<? extends K, ? extends V>> col =
- F.viewReadOnly(map.entrySet(), new C1<Map.Entry<? extends K, ? extends V>, Cache.Entry<? extends K, ? extends V>>() {
- @Override
- public Cache.Entry<? extends K, ? extends V> apply(Map.Entry<? extends K, ? extends V> e) {
- return new MapEntry<>(e);
- }
- });
-
- writer.writeAll(col);
+ writer.writeAll(entries);
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
+ @Override public void delete(Object key) {
if (writer == null)
return;
@@ -130,7 +112,7 @@ class GridCacheLoaderWriterStore<K, V> implements GridCacheStore<K, V>, Lifecycl
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx, Collection<? extends K> keys) throws IgniteCheckedException {
+ @Override public void deleteAll(Collection<?> keys) {
if (writer == null)
return;
@@ -138,82 +120,7 @@ class GridCacheLoaderWriterStore<K, V> implements GridCacheStore<K, V>, Lifecycl
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
-
- /**
- *
- */
- private static class KeyValueEntry<K, V> implements Cache.Entry<K, V> {
- /** */
- private final K key;
-
- /** */
- private final V val;
-
- /**
- * @param key Key.
- * @param val Value.
- */
- KeyValueEntry(K key, V val) {
- this.key = key;
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public K getKey() {
- return key;
- }
-
- /** {@inheritDoc} */
- @Override public V getValue() {
- return val;
- }
-
- /** {@inheritDoc} */
- @Override public <T> T unwrap(Class<T> clazz) {
- throw new IllegalArgumentException();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(KeyValueEntry.class, this);
- }
- }
-
- /**
- *
- */
- static class MapEntry<K, V> implements Cache.Entry<K, V> {
- /** */
- private final Map.Entry<K, V> e;
-
- /**
- * @param e Entry.
- */
- MapEntry(Map.Entry<K, V> e) {
- this.e = e;
- }
-
- /** {@inheritDoc} */
- @Override public K getKey() {
- return e.getKey();
- }
-
- /** {@inheritDoc} */
- @Override public V getValue() {
- return e.getValue();
- }
-
- /** {@inheritDoc} */
- @Override public <T> T unwrap(Class<T> clazz) {
- throw new IllegalArgumentException();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(MapEntry.class, this);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
index 7809509..2602510 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProcessor.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.fs.*;
@@ -30,7 +31,6 @@ import org.gridgain.grid.cache.affinity.*;
import org.gridgain.grid.cache.affinity.consistenthash.*;
import org.gridgain.grid.cache.affinity.fair.*;
import org.gridgain.grid.cache.affinity.rendezvous.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.*;
import org.gridgain.grid.kernal.processors.cache.datastructures.*;
@@ -601,7 +601,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
GridCacheTtlManager ttlMgr = new GridCacheTtlManager();
GridCacheDrManager drMgr = ctx.createComponent(GridCacheDrManager.class);
- GridCacheStore store = cacheStore(ctx.gridName(), cfg);
+ CacheStore store = cacheStore(ctx.gridName(), cfg);
GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, store);
@@ -1811,7 +1811,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* or user-defined cache store.
*/
@SuppressWarnings({"unchecked"})
- private GridCacheStore cacheStore(String gridName, GridCacheConfiguration cfg) {
+ private CacheStore cacheStore(String gridName, GridCacheConfiguration cfg) {
if (cfg.getStore() == null || !cfg.isWriteBehindEnabled())
return cfg.getStore();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProjectionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProjectionEx.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProjectionEx.java
index 49077eb..df309e4 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProjectionEx.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheProjectionEx.java
@@ -21,7 +21,6 @@ import org.apache.ignite.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.processors.cache.dr.*;
import org.jetbrains.annotations.*;
@@ -193,8 +192,8 @@ public interface GridCacheProjectionEx<K, V> extends GridCacheProjection<K, V> {
* <p>
* This method will return {@code true} if value is stored in cache and {@code false} otherwise.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -218,8 +217,8 @@ public interface GridCacheProjectionEx<K, V> extends GridCacheProjection<K, V> {
* <p>
* This method will return {@code true} if value is stored in cache and {@code false} otherwise.
* <p>
- * If write-through is enabled, the stored value will be persisted to {@link GridCacheStore}
- * via {@link GridCacheStore#put(IgniteTx, Object, Object)} method.
+ * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#put(IgniteTx, Object, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -240,8 +239,8 @@ public interface GridCacheProjectionEx<K, V> extends GridCacheProjection<K, V> {
/**
* Removes given key mapping from cache if one exists and value is equal to the passed in value.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
@@ -264,8 +263,8 @@ public interface GridCacheProjectionEx<K, V> extends GridCacheProjection<K, V> {
* This method will return {@code true} if remove did occur, which means that all optionally
* provided filters have passed and there was something to remove, {@code false} otherwise.
* <p>
- * If write-through is enabled, the value will be removed from {@link GridCacheStore}
- * via {@link GridCacheStore#remove(IgniteTx, Object)} method.
+ * If write-through is enabled, the value will be removed from {@link org.apache.ignite.cache.store.CacheStore}
+ * via {@link org.apache.ignite.cache.store.CacheStore#remove(IgniteTx, Object)} method.
* <h2 class="header">Transactions</h2>
* This method is transactional and will enlist the entry into ongoing transaction
* if there is one.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
index 469671a..e943a11 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheStoreManager.java
@@ -23,14 +23,15 @@ import org.apache.ignite.lang.*;
import org.apache.ignite.lifecycle.*;
import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.interop.*;
import org.gridgain.grid.util.lang.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.jetbrains.annotations.*;
+import sun.nio.cs.*;
+import javax.cache.*;
import java.util.*;
/**
@@ -41,15 +42,18 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
private static final String SES_ATTR = "STORE_SES";
/** */
- private final GridCacheStore<K, Object> store;
+ private final CacheStore<K, Object> store;
/** */
- private final GridCacheStoreBalancingWrapper<K, Object> singleThreadGate;
+ private final CacheStoreBalancingWrapper<K, Object> singleThreadGate;
/** */
private final ThreadLocal<SessionData> sesHolder = new ThreadLocal<>();
/** */
+ private final boolean sesEnabled;
+
+ /** */
private final boolean locStore;
/** */
@@ -61,19 +65,24 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
* @throws IgniteCheckedException In case of error.
*/
@SuppressWarnings("unchecked")
- public GridCacheStoreManager(GridKernalContext ctx, @Nullable GridCacheStore<K, Object> store)
+ public GridCacheStoreManager(GridKernalContext ctx, @Nullable CacheStore<K, Object> store)
throws IgniteCheckedException {
this.store = store;
- singleThreadGate = store == null ? null : new GridCacheStoreBalancingWrapper<>(store);
+ singleThreadGate = store == null ? null : new CacheStoreBalancingWrapper<>(store);
if (store instanceof GridCacheWriteBehindStore)
store = ((GridCacheWriteBehindStore)store).store();
- if (store != null)
+ if (store != null) {
ctx.resource().injectBasicResource(store, IgniteCacheSessionResource.class, new ThreadLocalSession());
- locStore = U.hasAnnotation(store, GridCacheLocalStore.class);
+ sesEnabled = true; // TODO IGNITE-42.
+ }
+ else
+ sesEnabled = false;
+
+ locStore = U.hasAnnotation(store, CacheLocalStore.class);
}
/** {@inheritDoc} */
@@ -162,7 +171,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
boolean ses = initSession(tx);
try {
- val = convert(singleThreadGate.load(tx, key));
+ val = convert(singleThreadGate.load(key));
}
catch (ClassCastException e) {
handleClassCastException(e);
@@ -236,9 +245,13 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
boolean ses = initSession(tx);
try {
- singleThreadGate.loadAll(tx, keys0, new CI2<K, Object>() {
- @Override public void apply(K k, Object o) {
- V v = convert(o);
+ if (keys.size() > singleThreadGate.loadAllThreshold()) {
+ Map<K, Object> map = singleThreadGate.loadAll(keys0);
+
+ for (Map.Entry<K, Object> e : map.entrySet()) {
+ K k = e.getKey();
+
+ V v = convert(e.getValue());
if (cctx.portableEnabled()) {
k = (K)cctx.marshalToPortable(k);
@@ -247,7 +260,21 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
vis.apply(k, v);
}
- });
+ }
+ else {
+ singleThreadGate.loadAll(keys0, new CI2<K, Object>() {
+ @Override public void apply(K k, Object o) {
+ V v = convert(o);
+
+ if (cctx.portableEnabled()) {
+ k = (K)cctx.marshalToPortable(k);
+ v = (V)cctx.marshalToPortable(v);
+ }
+
+ vis.apply(k, v);
+ }
+ });
+ }
}
catch (ClassCastException e) {
handleClassCastException(e);
@@ -256,7 +283,8 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
throw U.cast(e);
}
finally {
- sesHolder.set(null);
+ if (ses)
+ sesHolder.set(null);
}
if (log.isDebugEnabled())
@@ -354,7 +382,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
boolean ses = initSession(tx);
try {
- store.put(tx, key, locStore ? F.t(val, ver) : val);
+ store.write(new CacheEntryImpl<>(key, locStore ? F.t(val, ver) : val));
}
catch (ClassCastException e) {
handleClassCastException(e);
@@ -414,18 +442,21 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
boolean ses = initSession(tx);
try {
- store.putAll(tx, locStore ? map0 : F.viewReadOnly(map0,
- new C1<IgniteBiTuple<V, GridCacheVersion>, Object>() {
- @Override public Object apply(IgniteBiTuple<V, GridCacheVersion> t) {
- return t.get1();
+ C1<Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>>, Cache.Entry<? extends K, ?>> c =
+ new C1<Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>>, Cache.Entry<? extends K, ?>>() {
+ @Override public Cache.Entry<? extends K, ?> apply(Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>> e) {
+ return new CacheEntryImpl<>(e.getKey(), locStore ? e.getValue() : e.getValue().get1());
}
- }));
+ };
+
+ store.writeAll(F.viewReadOnly(map.entrySet(), c));
}
catch (ClassCastException e) {
handleClassCastException(e);
}
finally {
- sesHolder.set(null);
+ if (ses)
+ sesHolder.set(null);
}
if (log.isDebugEnabled())
@@ -459,7 +490,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
boolean ses = initSession(tx);
try {
- store.remove(tx, key);
+ store.delete(key);
}
catch (ClassCastException e) {
handleClassCastException(e);
@@ -509,7 +540,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
boolean ses = initSession(tx);
try {
- store.removeAll(tx, keys0);
+ store.deleteAll(keys0);
}
catch (ClassCastException e) {
handleClassCastException(e);
@@ -531,7 +562,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
/**
* @return Store.
*/
- public GridCacheStore<K, Object> store() {
+ public CacheStore<K, Object> store() {
return store;
}
@@ -551,9 +582,18 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
assert store != null;
- tx.removeMeta(SES_ATTR);
+ boolean ses = initSession(tx);
+
+ try {
+ store.txEnd(commit);
+ }
+ finally {
+ if (ses) {
+ sesHolder.set(null);
- store.txEnd(tx, commit);
+ tx.removeMeta(SES_ATTR);
+ }
+ }
}
/**
@@ -577,7 +617,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> {
* @return {@code True} if
*/
private boolean initSession(@Nullable IgniteTx tx) {
- if (tx == null)
+ if (!sesEnabled || tx == null)
return false;
SessionData ses = tx.meta(SES_ATTR);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStore.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStore.java
index 9cdae01..fea67a9 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStore.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStore.java
@@ -18,13 +18,13 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.lifecycle.*;
import org.apache.ignite.thread.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.interop.*;
import org.gridgain.grid.util.typedef.*;
@@ -34,13 +34,14 @@ import org.gridgain.grid.util.worker.*;
import org.jdk8.backport.*;
import org.jetbrains.annotations.*;
+import javax.cache.integration.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
/**
- * Internal wrapper for a {@link GridCacheStore} that enables write-behind logic.
+ * Internal wrapper for a {@link org.apache.ignite.cache.store.CacheStore} that enables write-behind logic.
* <p/>
* The general purpose of this approach is to reduce cache store load under high
* store update rate. The idea is to cache all write and remove operations in a pending
@@ -55,7 +56,7 @@ import java.util.concurrent.locks.*;
* Since write operations to the cache store are deferred, transaction support is lost; no
* transaction objects are passed to the underlying store.
*/
-public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, LifecycleAware, GridInteropAware {
+public class GridCacheWriteBehindStore<K, V> implements CacheStore<K, V>, LifecycleAware, GridInteropAware {
/** Default write cache initial capacity. */
public static final int DFLT_INITIAL_CAPACITY = 1024;
@@ -93,7 +94,7 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
private String cacheName;
/** Underlying store. */
- private GridCacheStore<K, V> store;
+ private CacheStore<K, V> store;
/** Write cache. */
private ConcurrentLinkedHashMap<K, StatefulValue<V>> writeCache;
@@ -241,7 +242,7 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
* @param log Grid logger.
* @param store {@code GridCacheStore} that need to be wrapped.
*/
- public GridCacheWriteBehindStore(String gridName, String cacheName, IgniteLogger log, GridCacheStore<K, V> store) {
+ public GridCacheWriteBehindStore(String gridName, String cacheName, IgniteLogger log, CacheStore<K, V> store) {
this.gridName = gridName;
this.cacheName = cacheName;
this.log = log;
@@ -251,7 +252,7 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
/**
* @return Underlying store.
*/
- public GridCacheStore<K, V> store() {
+ public CacheStore<K, V> store() {
return store;
}
@@ -377,19 +378,16 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
*
* @param clo {@inheritDoc}
* @param args {@inheritDoc}
- * @throws IgniteCheckedException {@inheritDoc}
*/
- @Override public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) {
store.loadCache(clo, args);
}
/** {@inheritDoc} */
@SuppressWarnings({"NullableProblems"})
- @Override public void loadAll(@Nullable IgniteTx tx,
- @Nullable Collection<? extends K> keys, IgniteBiInClosure<K, V> c) throws IgniteCheckedException {
+ @Override public void loadAll(@Nullable Collection<? extends K> keys, IgniteBiInClosure<K, V> c) {
if (log.isDebugEnabled())
- log.debug("Store load all [keys=" + keys + ", tx=" + tx + ']');
+ log.debug("Store load all [keys=" + keys + ']');
Collection<K> remaining = new LinkedList<>();
@@ -425,13 +423,13 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
// For items that were not found in queue.
if (!remaining.isEmpty())
- store.loadAll(null, remaining, c);
+ store.loadAll(remaining, c);
}
/** {@inheritDoc} */
- @Override public V load(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
+ @Override public V load(K key) {
if (log.isDebugEnabled())
- log.debug("Store load [key=" + key + ", tx=" + tx + ']');
+ log.debug("Store load [key=" + key + ']');
StatefulValue<V> val = writeCache.get(key);
@@ -455,41 +453,49 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
}
}
- return store.load(null, key);
+ return store.load(key);
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, @Nullable Map<? extends K, ? extends V> map)
- throws IgniteCheckedException {
+ @Override public void putAll(Map<? extends K, ? extends V> map) {
for (Map.Entry<? extends K, ? extends V> e : map.entrySet())
- put(tx, e.getKey(), e.getValue());
+ put(e.getKey(), e.getValue());
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, K key, V val) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
+ @Override public void put(K key, V val) {
+ try {
+ if (log.isDebugEnabled())
+ log.debug("Store put [key=" + key + ", val=" + val + ']');
- updateCache(key, val, StoreOperation.PUT);
+ updateCache(key, val, StoreOperation.PUT);
+ }
+ catch (GridInterruptedException e) {
+ throw new CacheWriterException(e);
+ }
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx, @Nullable Collection<? extends K> keys)
- throws IgniteCheckedException {
+ @Override public void removeAll(Collection<? extends K> keys) {
for (K key : keys)
- remove(tx, key);
+ remove(key);
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, K key) throws IgniteCheckedException {
- if (log.isDebugEnabled())
- log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
+ @Override public void remove(K key) {
+ try {
+ if (log.isDebugEnabled())
+ log.debug("Store remove [key=" + key + ']');
- updateCache(key, null, StoreOperation.RMV);
+ updateCache(key, null, StoreOperation.RMV);
+ }
+ catch (GridInterruptedException e) {
+ throw new CacheWriterException(e);
+ }
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
@@ -678,12 +684,12 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
try {
switch (operation) {
case PUT:
- store.putAll(null, vals);
+ store.putAll(vals);
break;
case RMV:
- store.removeAll(null, vals.keySet());
+ store.removeAll(vals.keySet());
break;
@@ -693,7 +699,7 @@ public class GridCacheWriteBehindStore<K, V> implements GridCacheStore<K, V>, Li
return true;
}
- catch (IgniteCheckedException e) {
+ catch (Exception e) {
LT.warn(log, e, "Unable to update underlying store: " + store);
if (writeCache.sizex() > cacheCriticalSize || stopping.get()) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
new file mode 100644
index 0000000..1c60452
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
@@ -0,0 +1,243 @@
+/*
+ * 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.cache.store.jdbc;
+
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.transactions.*;
+import org.gridgain.grid.cache.*;
+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.gridgain.grid.util.typedef.internal.*;
+import org.gridgain.testframework.junits.common.*;
+import org.jdk8.backport.*;
+
+import java.lang.reflect.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
+import static org.gridgain.grid.cache.GridCacheMode.*;
+import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
+import static org.gridgain.grid.cache.GridCacheWriteSynchronizationMode.*;
+import static org.gridgain.testframework.GridTestUtils.*;
+
+/**
+ *
+ */
+public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Number of grids to start. */
+ private static final int GRID_CNT = 5;
+
+ /** Number of transactions. */
+ private static final int TX_CNT = 1000;
+
+ /** Cache store. */
+ private static CacheStore<Integer, String> store;
+
+ /** Distribution mode. */
+ private GridCacheDistributionMode mode;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ store = store();
+
+ mode = NEAR_PARTITIONED;
+
+ startGridsMultiThreaded(GRID_CNT - 2);
+
+ mode = NEAR_ONLY;
+
+ startGrid(GRID_CNT - 2);
+
+ mode = CLIENT_ONLY;
+
+ startGrid(GRID_CNT - 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration c = super.getConfiguration(gridName);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ c.setDiscoverySpi(disco);
+
+ GridCacheConfiguration cc = defaultCacheConfiguration();
+
+ cc.setCacheMode(PARTITIONED);
+ cc.setWriteSynchronizationMode(FULL_SYNC);
+ cc.setSwapEnabled(false);
+ cc.setAtomicityMode(TRANSACTIONAL);
+ cc.setBackups(1);
+ cc.setDistributionMode(mode);
+
+ cc.setStore(store);
+
+ c.setCacheConfiguration(cc);
+
+ return c;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultithreadedPut() throws Exception {
+ IgniteFuture<?> fut1 = runMultiThreadedAsync(new Callable<Object>() {
+ private final Random rnd = new Random();
+
+ @Override public Object call() throws Exception {
+ for (int i = 0; i < TX_CNT; i++) {
+ GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
+
+ cache.put(rnd.nextInt(1000), "value");
+ }
+
+ return null;
+ }
+ }, 4, "put");
+
+ IgniteFuture<?> fut2 = runMultiThreadedAsync(new Callable<Object>() {
+ private final Random rnd = new Random();
+
+ @Override public Object call() throws Exception {
+ for (int i = 0; i < TX_CNT; i++) {
+ GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
+
+ cache.putIfAbsent(rnd.nextInt(1000), "value");
+ }
+
+ return null;
+ }
+ }, 4, "putIfAbsent");
+
+ fut1.get();
+ fut2.get();
+
+ long opened = ((LongAdder)U.field(store, "opened")).sum();
+ long closed = ((LongAdder)U.field(store, "closed")).sum();
+
+ assert opened > 0;
+ assert closed > 0;
+
+ assertEquals(opened, closed);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultithreadedPutAll() throws Exception {
+ runMultiThreaded(new Callable<Object>() {
+ private final Random rnd = new Random();
+
+ @Override public Object call() throws Exception {
+ for (int i = 0; i < TX_CNT; i++) {
+ Map<Integer, String> map = new TreeMap<>();
+
+ for (int j = 0; j < 10; j++)
+ map.put(rnd.nextInt(1000), "value");
+
+ GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
+
+ cache.putAll(map);
+ }
+
+ return null;
+ }
+ }, 8, "putAll");
+
+ long opened = ((LongAdder)U.field(store, "opened")).sum();
+ long closed = ((LongAdder)U.field(store, "closed")).sum();
+
+ assert opened > 0;
+ assert closed > 0;
+
+ assertEquals(opened, closed);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMultithreadedExplicitTx() throws Exception {
+ runMultiThreaded(new Callable<Object>() {
+ private final Random rnd = new Random();
+
+ @Override public Object call() throws Exception {
+ for (int i = 0; i < TX_CNT; i++) {
+ GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
+
+ try (IgniteTx tx = cache.txStart()) {
+ cache.put(1, "value");
+ cache.put(2, "value");
+ cache.put(3, "value");
+
+ cache.get(1);
+ cache.get(4);
+
+ Map<Integer, String> map = new TreeMap<>();
+
+ map.put(5, "value");
+ map.put(6, "value");
+
+ cache.putAll(map);
+
+ tx.commit();
+ }
+ }
+
+ return null;
+ }
+ }, 8, "tx");
+
+ long opened = ((LongAdder)U.field(store, "opened")).sum();
+ long closed = ((LongAdder)U.field(store, "closed")).sum();
+
+ assert opened > 0;
+ assert closed > 0;
+
+ assertEquals(opened, closed);
+ }
+
+ /**
+ * @return New store.
+ * @throws Exception In case of error.
+ */
+ private CacheStore<Integer, String> store() throws Exception {
+ CacheStore<Integer, String> store = new CacheJdbcBlobStore<>();
+
+ Field f = store.getClass().getDeclaredField("testMode");
+
+ f.setAccessible(true);
+
+ f.set(store, true);
+
+ return store;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java
new file mode 100644
index 0000000..3011276
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.cache.store.jdbc;
+
+import org.gridgain.testframework.junits.cache.*;
+
+import java.sql.*;
+
+/**
+ * Cache store test.
+ */
+public class GridCacheJdbcBlobStoreSelfTest
+ extends GridAbstractCacheStoreSelfTest<CacheJdbcBlobStore<Object, Object>> {
+ /**
+ * @throws Exception If failed.
+ */
+ public GridCacheJdbcBlobStoreSelfTest() throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ try (Connection c = DriverManager.getConnection(CacheJdbcBlobStore.DFLT_CONN_URL, null, null)) {
+ try (Statement s = c.createStatement()) {
+ s.executeUpdate("drop table ENTRIES");
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheJdbcBlobStore<Object, Object> store() {
+ return new CacheJdbcBlobStore<>();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/package.html b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/package.html
new file mode 100644
index 0000000..1f85ff2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/package.html
@@ -0,0 +1,23 @@
+<!--
+ 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.
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<body>
+ <!-- Package description. -->
+ Contains internal tests or test related classes and interfaces.
+</body>
+</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
index 04390bc..9caba0b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
@@ -10,6 +10,7 @@
package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.marshaller.optimized.*;
@@ -18,7 +19,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.testframework.junits.common.*;
import org.jdk8.backport.*;
import org.jetbrains.annotations.*;
@@ -131,7 +131,7 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest {
/**
* @return Cache store.
*/
- protected GridCacheStore<?, ?> cacheStore() {
+ protected CacheStore<?, ?> cacheStore() {
return null;
}
@@ -210,7 +210,7 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest {
/**
*
*/
- public class TestStore extends GridCacheStoreAdapter<Object, Object> {
+ public class TestStore extends CacheStoreAdapter<Object, Object> {
/** {@inheritDoc} */
@Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args) {
for (Map.Entry<Object, Object> e : storeMap.entrySet())
@@ -218,17 +218,17 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public Object load(IgniteTx tx, Object key) {
+ @Override public Object load(Object key) {
return storeMap.get(key);
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Object key, @Nullable Object val) {
+ @Override public void put(Object key, @Nullable Object val) {
storeMap.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Object key) {
+ @Override public void remove(Object key) {
storeMap.remove(key);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java
index 2ff0468..3c775f8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java
@@ -9,14 +9,14 @@
package org.apache.ignite.internal.processors.cache;
-import org.gridgain.grid.cache.store.*;
+import org.apache.ignite.cache.store.*;
/**
*
*/
public class IgniteCacheAtomicLocalWithStoreInvokeTest extends IgniteCacheAtomicLocalInvokeTest {
/** {@inheritDoc} */
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return new TestStore();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java
index 5fa85e3..9556bcc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java
@@ -9,7 +9,7 @@
package org.apache.ignite.internal.processors.cache;
-import org.gridgain.grid.cache.store.*;
+import org.apache.ignite.cache.store.*;
/**
*
@@ -17,7 +17,7 @@ import org.gridgain.grid.cache.store.*;
public class IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest extends
IgniteCacheAtomicPrimaryWriteOrderInvokeTest {
/** {@inheritDoc} */
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return new IgniteCacheAbstractTest.TestStore();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java
index 5f55aaa..3fcdeaf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java
@@ -9,7 +9,7 @@
package org.apache.ignite.internal.processors.cache.expiry;
-import org.gridgain.grid.cache.store.*;
+import org.apache.ignite.cache.store.*;
/**
*
@@ -17,7 +17,7 @@ import org.gridgain.grid.cache.store.*;
public class IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest extends
IgniteCacheAtomicPrimaryWriteOrderExpiryPolicyTest{
/** {@inheritDoc} */
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return new TestStore();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java
index b64215b..b00354b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java
@@ -9,14 +9,14 @@
package org.apache.ignite.internal.processors.cache.expiry;
-import org.gridgain.grid.cache.store.*;
+import org.apache.ignite.cache.store.*;
/**
*
*/
public class IgniteCacheAtomicWithStoreExpiryPolicyTest extends IgniteCacheAtomicExpiryPolicyTest {
/** {@inheritDoc} */
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return new TestStore();
}
}
[2/5] incubator-ignite git commit: # ignite-42
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java
index 902d1dd..4876a6a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java
@@ -9,14 +9,14 @@
package org.apache.ignite.internal.processors.cache.expiry;
-import org.gridgain.grid.cache.store.*;
+import org.apache.ignite.cache.store.*;
/**
*
*/
public class IgniteCacheTxWithStoreExpiryPolicyTest extends IgniteCacheTxExpiryPolicyTest {
/** {@inheritDoc} */
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return new TestStore();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheBalancingStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheBalancingStoreSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheBalancingStoreSelfTest.java
index b736c68..262c419 100644
--- a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheBalancingStoreSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheBalancingStoreSelfTest.java
@@ -17,14 +17,15 @@
package org.gridgain.grid.cache.store;
-import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
-import org.apache.ignite.transactions.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.testframework.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
+import javax.cache.*;
+import javax.cache.integration.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
@@ -43,8 +44,8 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest {
final AtomicInteger cycles = new AtomicInteger();
final AtomicReference<Exception> err = new AtomicReference<>();
- final GridCacheStoreBalancingWrapper<Integer, Integer> w =
- new GridCacheStoreBalancingWrapper<>(new VerifyStore(range));
+ final CacheStoreBalancingWrapper<Integer, Integer> w =
+ new CacheStoreBalancingWrapper<>(new VerifyStore(range));
final AtomicBoolean finish = new AtomicBoolean();
@@ -54,12 +55,12 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
while (!finish.get()) {
- int cnt = rnd.nextInt(GridCacheStoreBalancingWrapper.DFLT_LOAD_ALL_THRESHOLD) + 1;
+ int cnt = rnd.nextInt(CacheStoreBalancingWrapper.DFLT_LOAD_ALL_THRESHOLD) + 1;
if (cnt == 1) {
int key = rnd.nextInt(range);
- assertEquals((Integer)key, w.load(null, key));
+ assertEquals((Integer)key, w.load(key));
}
else {
Collection<Integer> keys = new HashSet<>(cnt);
@@ -69,7 +70,7 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest {
final Map<Integer, Integer> loaded = new HashMap<>();
- w.loadAll(null, keys, new CI2<Integer, Integer>() {
+ w.loadAll(keys, new CI2<Integer, Integer>() {
@Override public void apply(Integer k, Integer v) {
loaded.put(k, v);
}
@@ -113,7 +114,7 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest {
/**
*
*/
- private static class VerifyStore implements GridCacheStore<Integer, Integer> {
+ private static class VerifyStore implements CacheStore<Integer, Integer> {
/** */
private Lock[] locks;
@@ -128,7 +129,7 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Nullable @Override public Integer load(@Nullable IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Nullable @Override public Integer load(Integer key) {
boolean res = locks[key].tryLock();
if (res) {
@@ -146,20 +147,20 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, @Nullable Object... args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, @Nullable Object... args) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx, Collection<? extends Integer> keys,
- IgniteBiInClosure<Integer, Integer> c) throws IgniteCheckedException {
+ @Override public Map<Integer, Integer> loadAll(Iterable<? extends Integer> keys) {
+ Map<Integer, Integer> loaded = new HashMap<>();
+
for (Integer key : keys) {
boolean res = locks[key].tryLock();
if (res) {
try {
- c.apply(key, key);
+ loaded.put(key, key);
}
finally {
locks[key].unlock();
@@ -168,32 +169,32 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest {
else
fail("Failed to acquire lock for key: " + key);
}
+
+ return loaded;
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Integer key, Integer val) throws IgniteCheckedException {
+ @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, Map<? extends Integer, ? extends Integer> map)
- throws IgniteCheckedException {
+ @Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends Integer>> entries) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Override public void delete(Object key) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx, Collection<? extends Integer> keys)
- throws IgniteCheckedException {
+ @Override public void deleteAll(Collection<?> keys) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
index 2414122..ebda034 100644
--- a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridCacheLoadOnlyStoreAdapterSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.cache.store;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.kernal.processors.cache.*;
@@ -67,10 +68,9 @@ public class GridCacheLoadOnlyStoreAdapterSelfTest extends GridCacheAbstractSelf
/**
*
*/
- private static class TestStore extends GridCacheLoadOnlyStoreAdapter<Integer, String, String> {
+ private static class TestStore extends CacheLoadOnlyStoreAdapter<Integer, String, String> {
/** {@inheritDoc} */
- @Override protected Iterator<String> inputIterator(@Nullable Object... args)
- throws IgniteCheckedException {
+ @Override protected Iterator<String> inputIterator(@Nullable Object... args) {
assertNotNull(args);
assertTrue(Arrays.equals(EXP_ARGS, args));
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/cache/store/GridGeneratingTestStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridGeneratingTestStore.java b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridGeneratingTestStore.java
index 4482f17..80aa5fe 100644
--- a/modules/core/src/test/java/org/gridgain/grid/cache/store/GridGeneratingTestStore.java
+++ b/modules/core/src/test/java/org/gridgain/grid/cache/store/GridGeneratingTestStore.java
@@ -17,19 +17,20 @@
package org.gridgain.grid.cache.store;
-import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.*;
import org.gridgain.grid.util.typedef.*;
import org.jetbrains.annotations.*;
+import javax.cache.*;
+import javax.cache.integration.*;
import java.util.*;
/**
* Test store that generates objects on demand.
*/
-public class GridGeneratingTestStore implements GridCacheStore<String, String> {
+public class GridGeneratingTestStore implements CacheStore<String, String> {
/** Number of entries to be generated. */
private static final int DFLT_GEN_CNT = 100;
@@ -38,14 +39,12 @@ public class GridGeneratingTestStore implements GridCacheStore<String, String> {
private String cacheName;
/** {@inheritDoc} */
- @Override public String load(@Nullable IgniteTx tx, String key)
- throws IgniteCheckedException {
+ @Override public String load(String key) {
return null;
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<String, String> clo,
- @Nullable Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<String, String> clo, @Nullable Object... args) {
if (args.length > 0) {
try {
int cnt = ((Number)args[0]).intValue();
@@ -57,7 +56,7 @@ public class GridGeneratingTestStore implements GridCacheStore<String, String> {
catch (Exception e) {
X.println("Unexpected exception in loadAll: " + e);
- throw new IgniteCheckedException(e);
+ throw new CacheLoaderException(e);
}
}
else {
@@ -67,38 +66,37 @@ public class GridGeneratingTestStore implements GridCacheStore<String, String> {
}
/** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx,
- @Nullable Collection<? extends String> keys, IgniteBiInClosure<String, String> c) throws IgniteCheckedException {
+ @Override public Map<String, String> loadAll(Iterable<? extends String> keys) {
+ Map<String, String> loaded = new HashMap<>();
+
for (String key : keys)
- c.apply(key, "val" + key);
+ loaded.put(key, "val" + key);
+
+ return loaded;
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, String key, @Nullable String val)
- throws IgniteCheckedException {
+ @Override public void write(Cache.Entry<? extends String, ? extends String> entry) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx,
- @Nullable Map<? extends String, ? extends String> map) throws IgniteCheckedException {
+ @Override public void writeAll(Collection<Cache.Entry<? extends String, ? extends String>> entries) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, String key)
- throws IgniteCheckedException {
+ @Override public void delete(Object key) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx,
- @Nullable Collection<? extends String> keys) throws IgniteCheckedException {
+ @Override public void deleteAll(Collection<?> keys) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
deleted file mode 100644
index b5acd49..0000000
--- a/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store.jdbc;
-
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
-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.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.testframework.junits.common.*;
-import org.jdk8.backport.*;
-
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
-import static org.gridgain.grid.cache.GridCacheMode.*;
-import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
-import static org.gridgain.grid.cache.GridCacheWriteSynchronizationMode.*;
-import static org.gridgain.testframework.GridTestUtils.*;
-
-/**
- *
- */
-public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstractTest {
- /** IP finder. */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** Number of grids to start. */
- private static final int GRID_CNT = 5;
-
- /** Number of transactions. */
- private static final int TX_CNT = 1000;
-
- /** Cache store. */
- private static GridCacheStore<Integer, String> store;
-
- /** Distribution mode. */
- private GridCacheDistributionMode mode;
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- store = store();
-
- mode = NEAR_PARTITIONED;
-
- startGridsMultiThreaded(GRID_CNT - 2);
-
- mode = NEAR_ONLY;
-
- startGrid(GRID_CNT - 2);
-
- mode = CLIENT_ONLY;
-
- startGrid(GRID_CNT - 1);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration c = super.getConfiguration(gridName);
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setIpFinder(IP_FINDER);
-
- c.setDiscoverySpi(disco);
-
- GridCacheConfiguration cc = defaultCacheConfiguration();
-
- cc.setCacheMode(PARTITIONED);
- cc.setWriteSynchronizationMode(FULL_SYNC);
- cc.setSwapEnabled(false);
- cc.setAtomicityMode(TRANSACTIONAL);
- cc.setBackups(1);
- cc.setDistributionMode(mode);
-
- cc.setStore(store);
-
- c.setCacheConfiguration(cc);
-
- return c;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMultithreadedPut() throws Exception {
- IgniteFuture<?> fut1 = runMultiThreadedAsync(new Callable<Object>() {
- private final Random rnd = new Random();
-
- @Override public Object call() throws Exception {
- for (int i = 0; i < TX_CNT; i++) {
- GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
-
- cache.put(rnd.nextInt(1000), "value");
- }
-
- return null;
- }
- }, 4, "put");
-
- IgniteFuture<?> fut2 = runMultiThreadedAsync(new Callable<Object>() {
- private final Random rnd = new Random();
-
- @Override public Object call() throws Exception {
- for (int i = 0; i < TX_CNT; i++) {
- GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
-
- cache.putIfAbsent(rnd.nextInt(1000), "value");
- }
-
- return null;
- }
- }, 4, "putIfAbsent");
-
- fut1.get();
- fut2.get();
-
- long opened = ((LongAdder)U.field(store, "opened")).sum();
- long closed = ((LongAdder)U.field(store, "closed")).sum();
-
- assert opened > 0;
- assert closed > 0;
-
- assertEquals(opened, closed);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMultithreadedPutAll() throws Exception {
- runMultiThreaded(new Callable<Object>() {
- private final Random rnd = new Random();
-
- @Override public Object call() throws Exception {
- for (int i = 0; i < TX_CNT; i++) {
- Map<Integer, String> map = new TreeMap<>();
-
- for (int j = 0; j < 10; j++)
- map.put(rnd.nextInt(1000), "value");
-
- GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
-
- cache.putAll(map);
- }
-
- return null;
- }
- }, 8, "putAll");
-
- long opened = ((LongAdder)U.field(store, "opened")).sum();
- long closed = ((LongAdder)U.field(store, "closed")).sum();
-
- assert opened > 0;
- assert closed > 0;
-
- assertEquals(opened, closed);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMultithreadedExplicitTx() throws Exception {
- runMultiThreaded(new Callable<Object>() {
- private final Random rnd = new Random();
-
- @Override public Object call() throws Exception {
- for (int i = 0; i < TX_CNT; i++) {
- GridCache<Integer, String> cache = cache(rnd.nextInt(GRID_CNT));
-
- try (IgniteTx tx = cache.txStart()) {
- cache.put(1, "value");
- cache.put(2, "value");
- cache.put(3, "value");
-
- cache.get(1);
- cache.get(4);
-
- Map<Integer, String> map = new TreeMap<>();
-
- map.put(5, "value");
- map.put(6, "value");
-
- cache.putAll(map);
-
- tx.commit();
- }
- }
-
- return null;
- }
- }, 8, "tx");
-
- long opened = ((LongAdder)U.field(store, "opened")).sum();
- long closed = ((LongAdder)U.field(store, "closed")).sum();
-
- assert opened > 0;
- assert closed > 0;
-
- assertEquals(opened, closed);
- }
-
- /**
- * @return New store.
- * @throws Exception In case of error.
- */
- private GridCacheStore<Integer, String> store() throws Exception {
- GridCacheStore<Integer, String> store = new GridCacheJdbcBlobStore<>();
-
- Field f = store.getClass().getDeclaredField("testMode");
-
- f.setAccessible(true);
-
- f.set(store, true);
-
- return store;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java
deleted file mode 100644
index c294bfd..0000000
--- a/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/GridCacheJdbcBlobStoreSelfTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.gridgain.grid.cache.store.jdbc;
-
-import org.gridgain.testframework.junits.cache.*;
-
-import java.sql.*;
-
-/**
- * Cache store test.
- */
-public class GridCacheJdbcBlobStoreSelfTest
- extends GridAbstractCacheStoreSelfTest<GridCacheJdbcBlobStore<Object, Object>> {
- /**
- * @throws Exception If failed.
- */
- public GridCacheJdbcBlobStoreSelfTest() throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- try (Connection c = DriverManager.getConnection(GridCacheJdbcBlobStore.DFLT_CONN_URL, null, null)) {
- try (Statement s = c.createStatement()) {
- s.executeUpdate("drop table ENTRIES");
- }
- }
- }
-
- /** {@inheritDoc} */
- @Override protected GridCacheJdbcBlobStore<Object, Object> store() {
- return new GridCacheJdbcBlobStore<>();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/package.html
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/package.html b/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/package.html
deleted file mode 100644
index 1f85ff2..0000000
--- a/modules/core/src/test/java/org/gridgain/grid/cache/store/jdbc/package.html
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
- 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.
- -->
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-<body>
- <!-- Package description. -->
- Contains internal tests or test related classes and interfaces.
-</body>
-</html>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFlagsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFlagsTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFlagsTest.java
index 40265d8..ae6b538 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFlagsTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFlagsTest.java
@@ -17,9 +17,9 @@
package org.gridgain.grid.kernal.processors.cache;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
@@ -56,7 +56,7 @@ public abstract class GridCacheAbstractFlagsTest extends GridCacheAbstractSelfTe
}
/** {@inheritDoc} */
- @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Override protected CacheStore<?, ?> cacheStore() {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
index d4008f7..2a07f73 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
@@ -27,7 +28,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.util.lang.*;
import org.gridgain.grid.util.typedef.*;
@@ -274,23 +274,23 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
/**
* @return Write through storage emulator.
*/
- protected GridCacheStore<?, ?> cacheStore() {
- return new GridCacheStoreAdapter<Object, Object>() {
+ protected CacheStore<?, ?> cacheStore() {
+ return new CacheStoreAdapter<Object, Object>() {
@Override public void loadCache(IgniteBiInClosure<Object, Object> clo,
Object... args) {
for (Map.Entry<Object, Object> e : map.entrySet())
clo.apply(e.getKey(), e.getValue());
}
- @Override public Object load(IgniteTx tx, Object key) {
+ @Override public Object load(Object key) {
return map.get(key);
}
- @Override public void put(IgniteTx tx, Object key, @Nullable Object val) {
+ @Override public void put(Object key, @Nullable Object val) {
map.put(key, val);
}
- @Override public void remove(IgniteTx tx, Object key) {
+ @Override public void remove(Object key) {
map.remove(key);
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
index 7a075bf..7f619b9 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreAbstractTest.java
@@ -476,7 +476,7 @@ public abstract class GridCacheBasicStoreAbstractTest extends GridCommonAbstract
}
for (int i = 1; i <= 10; i++)
- store.put(null, i, "reloaded-" + i);
+ store.put(i, "reloaded-" + i);
cache.reloadAll(vals.keySet());
@@ -543,7 +543,7 @@ public abstract class GridCacheBasicStoreAbstractTest extends GridCommonAbstract
}
for (int i = 1; i <= 10; i++)
- store.put(null, i, "reloaded-" + i);
+ store.put(i, "reloaded-" + i);
store.resetLastMethod();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
index e89cfc8..c6d932a 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheBasicStoreMultithreadedAbstractTest.java
@@ -17,10 +17,10 @@
package org.gridgain.grid.kernal.processors.cache;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.gridgain.testframework.junits.common.*;
@@ -36,7 +36,7 @@ import static org.gridgain.grid.cache.GridCacheWriteSynchronizationMode.*;
*/
public abstract class GridCacheBasicStoreMultithreadedAbstractTest extends GridCommonAbstractTest {
/** Cache store. */
- private GridCacheStore<Integer, Integer> store;
+ private CacheStore<Integer, Integer> store;
/**
*
@@ -89,18 +89,18 @@ public abstract class GridCacheBasicStoreMultithreadedAbstractTest extends GridC
public void testConcurrentGet() throws Exception {
final AtomicInteger cntr = new AtomicInteger();
- store = new GridCacheStoreAdapter<Integer, Integer>() {
- @Override public Integer load(@Nullable IgniteTx tx, Integer key) {
+ store = new CacheStoreAdapter<Integer, Integer>() {
+ @Override public Integer load(Integer key) {
return cntr.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Integer key, @Nullable Integer val) {
+ @Override public void put(Integer key, @Nullable Integer val) {
assert false;
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) {
+ @Override public void remove(Integer key) {
assert false;
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
index b1ffd17..0281403 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
@@ -31,7 +32,6 @@ import org.gridgain.grid.cache.eviction.*;
import org.gridgain.grid.cache.eviction.fifo.*;
import org.gridgain.grid.cache.eviction.lru.*;
import org.gridgain.grid.cache.eviction.random.*;
-import org.gridgain.grid.cache.store.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -41,6 +41,8 @@ import org.gridgain.testframework.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
+import javax.cache.*;
+import javax.cache.integration.*;
import java.util.*;
import java.util.concurrent.*;
@@ -991,51 +993,44 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac
}
/** */
- private static class TestStore implements GridCacheStore<Object,Object> {
+ private static class TestStore implements CacheStore<Object,Object> {
/** {@inheritDoc} */
- @Nullable @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Nullable @Override public Object load(Object key) {
return null;
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Object, Object> clo,
- @Nullable Object... args) throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, @Nullable Object... args) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx,
- @Nullable Collection<?> keys, IgniteBiInClosure<Object, Object> c) throws IgniteCheckedException {
- // No-op.
+ @Override public Map<Object, Object> loadAll(Iterable<?> keys) throws CacheLoaderException {
+ return Collections.emptyMap();
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) throws IgniteCheckedException {
+ @Override public void write(Cache.Entry<?, ?> entry) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, @Nullable Map<?, ?> map)
- throws IgniteCheckedException {
+ @Override public void writeAll(Collection<Cache.Entry<?, ?>> entries) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public void delete(Object key) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx,
- @Nullable Collection<?> keys) throws IgniteCheckedException {
+ @Override public void deleteAll(Collection<?> keys) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGenericTestStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGenericTestStore.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGenericTestStore.java
index 7eb4987..a7bd958 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGenericTestStore.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGenericTestStore.java
@@ -18,21 +18,26 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
+import org.gridgain.grid.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.jetbrains.annotations.*;
+import javax.cache.*;
+import javax.cache.integration.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
+import static javax.cache.Cache.*;
+
/**
* Test store.
*/
@SuppressWarnings({"TypeParameterExtendsFinalClass"})
-public class GridCacheGenericTestStore<K, V> implements GridCacheStore<K, V> {
+public class GridCacheGenericTestStore<K, V> implements CacheStore<K, V> {
/** Store. */
private final Map<K, V> map = new ConcurrentHashMap<>();
@@ -42,16 +47,16 @@ public class GridCacheGenericTestStore<K, V> implements GridCacheStore<K, V> {
/** */
private long ts = System.currentTimeMillis();
- /** {@link #put(IgniteTx, Object, Object)} method call counter .*/
+ /** {@link #write(Entry)} method call counter .*/
private AtomicInteger putCnt = new AtomicInteger();
- /** {@link #putAll(IgniteTx, Map)} method call counter .*/
+ /** {@link #writeAll(Collection)} method call counter .*/
private AtomicInteger putAllCnt = new AtomicInteger();
- /** {@link #remove(IgniteTx, Object)} method call counter. */
+ /** {@link #delete(Object)} method call counter. */
private AtomicInteger rmvCnt = new AtomicInteger();
- /** {@link #removeAll(IgniteTx, Collection)} method call counter. */
+ /** {@link #deleteAll(Collection)} method call counter. */
private AtomicInteger rmvAllCnt = new AtomicInteger();
/** Flag indicating if methods of this store should fail. */
@@ -141,35 +146,35 @@ public class GridCacheGenericTestStore<K, V> implements GridCacheStore<K, V> {
}
/**
- * @return Count of {@link #put(IgniteTx, Object, Object)} method calls since last reset.
+ * @return Count of {@link #write(Entry)} method calls since last reset.
*/
public int getPutCount() {
return putCnt.get();
}
/**
- * @return Count of {@link #putAll(IgniteTx, Map)} method calls since last reset.
+ * @return Count of {@link #writeAll(Collection)} method calls since last reset.
*/
public int getPutAllCount() {
return putAllCnt.get();
}
/**
- * @return Number of {@link #remove(IgniteTx, Object)} method calls since last reset.
+ * @return Number of {@link #delete(Object)} method calls since last reset.
*/
public int getRemoveCount() {
return rmvCnt.get();
}
/**
- * @return Number of {@link #removeAll(IgniteTx, Collection)} method calls since last reset.
+ * @return Number of {@link #deleteAll(Collection)} method calls since last reset.
*/
public int getRemoveAllCount() {
return rmvAllCnt.get();
}
/** {@inheritDoc} */
- @Override public V load(IgniteTx tx, K key) throws IgniteCheckedException {
+ @Override public V load(K key) {
lastMtd = "load";
checkOperation();
@@ -178,54 +183,55 @@ public class GridCacheGenericTestStore<K, V> implements GridCacheStore<K, V> {
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<K, V> clo, Object[] args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<K, V> clo, Object[] args) {
lastMtd = "loadAllFull";
checkOperation();
}
/** {@inheritDoc} */
- @Override public void loadAll(IgniteTx tx, Collection<? extends K> keys,
- IgniteBiInClosure<K, V> c) throws IgniteCheckedException {
+ @Override public Map<K, V> loadAll(Iterable<? extends K> keys) {
lastMtd = "loadAll";
+ Map<K, V> loaded = new HashMap<>();
+
for (K key : keys) {
V val = map.get(key);
if (val != null)
- c.apply(key, val);
+ loaded.put(key, val);
}
checkOperation();
+
+ return loaded;
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, K key, V val)
- throws IgniteCheckedException {
+ @Override public void write(Cache.Entry<? extends K, ? extends V> e) {
lastMtd = "put";
checkOperation();
- map.put(key, val);
+ map.put(e.getKey(), e.getValue());
putCnt.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void putAll(IgniteTx tx, Map<? extends K, ? extends V> map)
- throws IgniteCheckedException {
+ @Override public void writeAll(Collection<Cache.Entry<? extends K, ? extends V>> entries) {
lastMtd = "putAll";
checkOperation();
- this.map.putAll(map);
+ for (Cache.Entry<? extends K, ? extends V> e : entries)
+ this.map.put(e.getKey(), e.getValue());
putAllCnt.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, K key) throws IgniteCheckedException {
+ @Override public void delete(Object key) {
lastMtd = "remove";
checkOperation();
@@ -236,34 +242,37 @@ public class GridCacheGenericTestStore<K, V> implements GridCacheStore<K, V> {
}
/** {@inheritDoc} */
- @Override public void removeAll(IgniteTx tx, Collection<? extends K> keys)
- throws IgniteCheckedException {
+ @Override public void deleteAll(Collection<?> keys) {
lastMtd = "removeAll";
checkOperation();
- for (K key : keys)
+ for (Object key : keys)
map.remove(key);
rmvAllCnt.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
/**
* Checks the flag and throws exception if it is set. Checks operation delay and sleeps
* for specified amount of time, if needed.
- *
- * @throws IgniteCheckedException Always if flag is set.
*/
- private void checkOperation() throws IgniteCheckedException {
+ private void checkOperation() {
if (shouldFail)
- throw new IgniteCheckedException("Store exception");
-
- if (operationDelay > 0)
- U.sleep(operationDelay);
+ throw new IgniteException("Store exception");
+
+ if (operationDelay > 0) {
+ try {
+ U.sleep(operationDelay);
+ }
+ catch(GridInterruptedException e) {
+ throw new IgniteException(e);
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGroupLockAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGroupLockAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGroupLockAbstractSelfTest.java
index c4a7471..51d782f 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGroupLockAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheGroupLockAbstractSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.events.*;
import org.apache.ignite.lang.*;
@@ -25,7 +26,6 @@ import org.apache.ignite.spi.communication.tcp.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -1247,7 +1247,7 @@ public abstract class GridCacheGroupLockAbstractSelfTest extends GridCommonAbstr
}
/** Test store that accumulates values into map. */
- private static class TestStore extends GridCacheStoreAdapter<Object, Object> {
+ private static class TestStore extends CacheStoreAdapter<Object, Object> {
/** */
private ConcurrentMap<Object, Object> storeMap = new ConcurrentHashMap8<>();
@@ -1255,30 +1255,26 @@ public abstract class GridCacheGroupLockAbstractSelfTest extends GridCommonAbstr
private AtomicInteger putCnt = new AtomicInteger();
/** {@inheritDoc} */
- @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public Object load(Object key) {
return null;
}
/** {@inheritDoc} */
- @Override public void putAll(IgniteTx tx,
- Map<?, ?> map) throws IgniteCheckedException {
+ @Override public void putAll(Map<?, ?> map) {
storeMap.putAll(map);
putCnt.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) throws IgniteCheckedException {
+ @Override public void put(Object key, @Nullable Object val) {
storeMap.put(key, val);
putCnt.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public void remove(Object key) {
storeMap.remove(key);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
index 0d11f58..bed5aa4 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheLifecycleAwareSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
@@ -28,10 +29,11 @@ import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.affinity.*;
import org.gridgain.grid.cache.cloner.*;
import org.gridgain.grid.cache.eviction.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
+import javax.cache.*;
+import javax.cache.integration.*;
import java.util.*;
import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
@@ -52,7 +54,7 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS
/**
*/
- private static class TestStore extends TestLifecycleAware implements GridCacheStore {
+ private static class TestStore extends TestLifecycleAware implements CacheStore {
/**
*/
TestStore() {
@@ -60,7 +62,7 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS
}
/** {@inheritDoc} */
- @Nullable @Override public Object load(@Nullable IgniteTx tx, Object key) {
+ @Nullable @Override public Object load(Object key) {
return null;
}
@@ -70,35 +72,32 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS
}
/** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx, @Nullable Collection keys,
- IgniteBiInClosure c) {
- // No-op.
+ @Override public Map loadAll(Iterable keys) throws CacheLoaderException {
+ return Collections.emptyMap();
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) {
+ @Override public void write(Cache.Entry entry) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, @Nullable Map map) {
+ @Override public void writeAll(Collection collection) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key) {
+ @Override public void delete(Object key) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx,
- @Nullable Collection keys) {
+ @Override public void deleteAll(Collection keys) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
index c013558..e6f30c0 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheMultinodeUpdateAbstractSelfTest.java
@@ -18,8 +18,8 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.testframework.*;
import org.jetbrains.annotations.*;
@@ -44,7 +44,7 @@ public abstract class GridCacheMultinodeUpdateAbstractSelfTest extends GridCache
}
/** {@inheritDoc} */
- @Nullable @Override protected GridCacheStore<?, ?> cacheStore() {
+ @Nullable @Override protected CacheStore<?, ?> cacheStore() {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCachePartitionedWritesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCachePartitionedWritesTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCachePartitionedWritesTest.java
index 4cc8672..7925e7c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCachePartitionedWritesTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCachePartitionedWritesTest.java
@@ -17,10 +17,10 @@
package org.gridgain.grid.kernal.processors.cache;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.gridgain.testframework.junits.common.*;
@@ -39,7 +39,7 @@ import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
@SuppressWarnings({"unchecked"})
public class GridCachePartitionedWritesTest extends GridCommonAbstractTest {
/** Cache store. */
- private GridCacheStore store;
+ private CacheStore store;
/** {@inheritDoc} */
@Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception {
@@ -78,19 +78,18 @@ public class GridCachePartitionedWritesTest extends GridCommonAbstractTest {
final AtomicInteger putCnt = new AtomicInteger();
final AtomicInteger rmvCnt = new AtomicInteger();
- store = new GridCacheStoreAdapter() {
- @Override public Object load(@Nullable IgniteTx tx, Object key) {
+ store = new CacheStoreAdapter() {
+ @Override public Object load(Object key) {
info(">>> Get [key=" + key + ']');
return null;
}
- @Override public void put(@Nullable IgniteTx tx, Object key,
- @Nullable Object val) {
+ @Override public void put(Object key, @Nullable Object val) {
putCnt.incrementAndGet();
}
- @Override public void remove(@Nullable IgniteTx tx, Object key) {
+ @Override public void remove(Object key) {
rmvCnt.incrementAndGet();
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
index 437d4ba..49810af 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheReloadSelfTest.java
@@ -18,11 +18,11 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
import org.gridgain.grid.cache.eviction.lru.*;
-import org.gridgain.grid.cache.store.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.gridgain.testframework.junits.common.*;
@@ -79,17 +79,16 @@ public class GridCacheReloadSelfTest extends GridCommonAbstractTest {
cacheCfg.setCacheMode(cacheMode);
cacheCfg.setEvictionPolicy(new GridCacheLruEvictionPolicy(MAX_CACHE_ENTRIES));
cacheCfg.setDistributionMode(nearEnabled ? NEAR_PARTITIONED : PARTITIONED_ONLY);
- cacheCfg.setStore(new GridCacheStoreAdapter<Integer, Integer>() {
- @Override public Integer load(@Nullable IgniteTx tx, Integer key) {
+ cacheCfg.setStore(new CacheStoreAdapter<Integer, Integer>() {
+ @Override public Integer load(Integer key) {
return key;
}
- @Override public void put(@Nullable IgniteTx tx, Integer key,
- @Nullable Integer val) {
+ @Override public void put(Integer key, @Nullable Integer val) {
//No-op.
}
- @Override public void remove(@Nullable IgniteTx tx, Integer key) {
+ @Override public void remove(Integer key) {
//No-op.
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheStorePutxSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheStorePutxSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheStorePutxSelfTest.java
index e5edfad..b9c046b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheStorePutxSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheStorePutxSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.spi.discovery.tcp.*;
@@ -25,10 +26,11 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.testframework.junits.common.*;
import org.jetbrains.annotations.*;
+import javax.cache.*;
+import javax.cache.integration.*;
import java.util.*;
import java.util.concurrent.atomic.*;
@@ -108,52 +110,46 @@ public class GridCacheStorePutxSelfTest extends GridCommonAbstractTest {
}
/** */
- private static class TestStore implements GridCacheStore<Integer, Integer> {
+ private static class TestStore implements CacheStore<Integer, Integer> {
/** {@inheritDoc} */
- @Nullable @Override public Integer load(@Nullable IgniteTx tx, Integer key) throws IgniteCheckedException {
+ @Nullable @Override public Integer load(Integer key) {
loads.incrementAndGet();
return null;
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, @Nullable Object... args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, @Nullable Object... args) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx, Collection<? extends Integer> keys,
- IgniteBiInClosure<Integer, Integer> c) throws IgniteCheckedException {
- // No-op.
+ @Override public Map<Integer, Integer> loadAll(Iterable<? extends Integer> keys) {
+ return Collections.emptyMap();
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Integer key,
- @Nullable Integer val) throws IgniteCheckedException {
+ @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx,
- Map<? extends Integer, ? extends Integer> map) throws IgniteCheckedException {
+ @Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends Integer>> entries) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Integer key)
- throws IgniteCheckedException {
+ @Override public void delete(Object key) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx, Collection<? extends Integer> keys)
- throws IgniteCheckedException {
+ @Override public void deleteAll(Collection<?> keys) {
// No-op.
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapReloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapReloadSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapReloadSelfTest.java
index 0ee61d6..2880d60 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapReloadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapReloadSelfTest.java
@@ -18,6 +18,7 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.events.*;
import org.apache.ignite.lang.*;
@@ -28,7 +29,6 @@ import org.apache.ignite.spi.swapspace.*;
import org.apache.ignite.spi.swapspace.file.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
@@ -210,7 +210,7 @@ public class GridCacheSwapReloadSelfTest extends GridCommonAbstractTest {
/**
* Test store.
*/
- private static class TestStore extends GridCacheStoreAdapter<Object, Object> {
+ private static class TestStore extends CacheStoreAdapter<Object, Object> {
/** */
private Map<Object, Object> map = new ConcurrentHashMap<>();
@@ -220,19 +220,17 @@ public class GridCacheSwapReloadSelfTest extends GridCommonAbstractTest {
}
/** {@inheritDoc} */
- @Override public Object load(@Nullable IgniteTx tx, Object key)
- throws IgniteCheckedException {
+ @Override public Object load(Object key) {
return map.get(key);
}
/** {@inheritDoc} */
- @Override public void put(IgniteTx tx, Object key, @Nullable Object val)
- throws IgniteCheckedException {
+ @Override public void put(Object key, Object val) {
map.put(key, val);
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Object key) throws IgniteCheckedException {
+ @Override public void remove(Object key) {
map.remove(key);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
index 1bcc0af..73f9f54 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheTestStore.java
@@ -18,14 +18,18 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
import org.apache.ignite.transactions.*;
-import org.gridgain.grid.cache.store.*;
+import org.gridgain.grid.*;
import org.gridgain.grid.kernal.processors.cache.transactions.*;
import org.gridgain.grid.util.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.jetbrains.annotations.*;
+import javax.cache.*;
+import javax.cache.integration.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
@@ -33,7 +37,11 @@ import java.util.concurrent.atomic.*;
/**
* Test store.
*/
-public final class GridCacheTestStore implements GridCacheStore<Integer, String> {
+public final class GridCacheTestStore implements CacheStore<Integer, String> {
+ /** */
+ @IgniteCacheSessionResource
+ private CacheStoreSession ses;
+
/** Store. */
private final Map<Integer, String> map;
@@ -46,13 +54,13 @@ public final class GridCacheTestStore implements GridCacheStore<Integer, String>
/** */
private long ts = System.currentTimeMillis();
- /** {@link #load(IgniteTx, Object)} method call counter .*/
+ /** {@link #load(Object)} method call counter .*/
private AtomicInteger loadCnt = new AtomicInteger();
- /** {@link #put(IgniteTx, Object, Object)} method call counter .*/
+ /** {@link #write(Cache.Entry)} method call counter .*/
private AtomicInteger putCnt = new AtomicInteger();
- /** {@link #putAll(IgniteTx, Map)} method call counter .*/
+ /** {@link #writeAll(Collection)} method call counter .*/
private AtomicInteger putAllCnt = new AtomicInteger();
/** Flag indicating if methods of this store should fail. */
@@ -164,29 +172,29 @@ public final class GridCacheTestStore implements GridCacheStore<Integer, String>
}
/**
- * @return Count of {@link #load(IgniteTx, Object)} method calls since last reset.
+ * @return Count of {@link #load(Object)} method calls since last reset.
*/
public int getLoadCount() {
return loadCnt.get();
}
/**
- * @return Count of {@link #put(IgniteTx, Object, Object)} method calls since last reset.
+ * @return Count of {@link #write(Cache.Entry)} method calls since last reset.
*/
public int getPutCount() {
return putCnt.get();
}
/**
- * @return Count of {@link #putAll(IgniteTx, Map)} method calls since last reset.
+ * @return Count of {@link #writeAll(Collection)} method calls since last reset.
*/
public int getPutAllCount() {
return putAllCnt.get();
}
/** {@inheritDoc} */
- @Override public String load(IgniteTx tx, Integer key) throws IgniteCheckedException {
- checkTx(tx);
+ @Override public String load(Integer key) {
+ checkTx(session());
lastMtd = "load";
@@ -198,8 +206,7 @@ public final class GridCacheTestStore implements GridCacheStore<Integer, String>
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Integer, String> clo, Object[] args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Integer, String> clo, Object[] args) {
lastMtd = "loadAllFull";
checkOperation();
@@ -216,53 +223,57 @@ public final class GridCacheTestStore implements GridCacheStore<Integer, String>
}
/** {@inheritDoc} */
- @Override public void loadAll(IgniteTx tx, Collection<? extends Integer> keys,
- IgniteBiInClosure<Integer, String> c) throws IgniteCheckedException {
- checkTx(tx);
+ @Override public Map<Integer, String> loadAll(Iterable<? extends Integer> keys) {
+ checkTx(session());
lastMtd = "loadAll";
checkOperation();
+ Map<Integer, String> loaded = new HashMap<>();
+
for (Integer key : keys) {
String val = map.get(key);
if (val != null)
- c.apply(key, val);
+ loaded.put(key, val);
}
+
+ return loaded;
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Integer key, String val)
- throws IgniteCheckedException {
- checkTx(tx);
+ @Override public void write(Cache.Entry<? extends Integer, ? extends String> e)
+ throws CacheWriterException {
+ checkTx(session());
lastMtd = "put";
checkOperation();
- map.put(key, val);
+ map.put(e.getKey(), e.getValue());
putCnt.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void putAll(IgniteTx tx, Map<? extends Integer, ? extends String> map)
- throws IgniteCheckedException {
- checkTx(tx);
+ @Override public void writeAll(Collection<Cache.Entry<? extends Integer, ? extends String>> entries)
+ throws CacheWriterException {
+ checkTx(session());
lastMtd = "putAll";
checkOperation();
- this.map.putAll(map);
+ for (Cache.Entry<? extends Integer, ? extends String> e : entries)
+ this.map.put(e.getKey(), e.getValue());
putAllCnt.incrementAndGet();
}
/** {@inheritDoc} */
- @Override public void remove(IgniteTx tx, Integer key) throws IgniteCheckedException {
- checkTx(tx);
+ @Override public void delete(Object key) throws CacheWriterException {
+ checkTx(session());
lastMtd = "remove";
@@ -272,42 +283,47 @@ public final class GridCacheTestStore implements GridCacheStore<Integer, String>
}
/** {@inheritDoc} */
- @Override public void removeAll(IgniteTx tx, Collection<? extends Integer> keys)
- throws IgniteCheckedException {
- checkTx(tx);
+ @Override public void deleteAll(Collection<?> keys)
+ throws CacheWriterException {
+ checkTx(session());
lastMtd = "removeAll";
checkOperation();
- for (Integer key : keys)
+ for (Object key : keys)
map.remove(key);
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) {
+ @Override public void txEnd(boolean commit) {
// No-op.
}
/**
* Checks the flag and throws exception if it is set. Checks operation delay and sleeps
* for specified amount of time, if needed.
- *
- * @throws IgniteCheckedException Always if flag is set.
*/
- private void checkOperation() throws IgniteCheckedException {
+ private void checkOperation() {
if (shouldFail)
- throw new IgniteCheckedException("Store exception.");
-
- if (operationDelay > 0)
- U.sleep(operationDelay);
+ throw new IgniteException("Store exception.");
+
+ if (operationDelay > 0) {
+ try {
+ U.sleep(operationDelay);
+ }
+ catch (GridInterruptedException e) {
+ throw new IgniteException(e);
+ }
+ }
}
/**
- * @param tx Checks transaction.
- * @throws IgniteCheckedException If transaction is incorrect.
+ * @param ses Session.
*/
- private void checkTx(IgniteTx tx) throws IgniteCheckedException {
+ private void checkTx(@Nullable CacheStoreSession ses) {
+ IgniteTx tx = ses != null ? ses.transaction() : null;
+
if (tx == null)
return;
@@ -316,9 +332,16 @@ public final class GridCacheTestStore implements GridCacheStore<Integer, String>
IgniteTxEx tx0 = (IgniteTxEx)tx;
if (!tx0.local())
- throw new IgniteCheckedException("Tx is not local: " + tx);
+ throw new IgniteException("Tx is not local: " + tx);
if (tx0.dht())
- throw new IgniteCheckedException("Tx is DHT: " + tx);
+ throw new IgniteException("Tx is DHT: " + tx);
+ }
+
+ /**
+ * @return Current session.
+ */
+ @Nullable private CacheStoreSession session() {
+ return ses;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java
index 9a6d490..c67048f 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractSelfTest.java
@@ -17,7 +17,6 @@
package org.gridgain.grid.kernal.processors.cache;
-import org.apache.ignite.*;
import org.apache.ignite.lang.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.gridgain.testframework.junits.common.*;
@@ -127,7 +126,7 @@ public abstract class GridCacheWriteBehindStoreAbstractSelfTest extends GridComm
switch (op) {
case 0:
- store.put(null, key, "val" + key);
+ store.put(key, "val" + key);
set.add(key);
operations.incrementAndGet();
@@ -135,7 +134,7 @@ public abstract class GridCacheWriteBehindStoreAbstractSelfTest extends GridComm
break;
case 1:
- store.remove(null, key);
+ store.remove(key);
set.remove(key);
operations.incrementAndGet();
@@ -144,13 +143,13 @@ public abstract class GridCacheWriteBehindStoreAbstractSelfTest extends GridComm
case 2:
default:
- store.put(null, key, "broken");
+ store.put(key, "broken");
- String val = store.load(null, key);
+ String val = store.load(key);
assertEquals("Invalid intermediate value: " + val, "broken", val);
- store.put(null, key, "val" + key);
+ store.put(key, "val" + key);
set.add(key);
@@ -163,7 +162,7 @@ public abstract class GridCacheWriteBehindStoreAbstractSelfTest extends GridComm
}
}
}
- catch (IgniteCheckedException e) {
+ catch (Exception e) {
error("Unexpected exception in put thread", e);
assert false;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
index 0dbcf6e..b3c8ce7 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreSelfTest.java
@@ -17,9 +17,7 @@
package org.gridgain.grid.kernal.processors.cache;
-import org.apache.ignite.*;
import org.apache.ignite.lang.*;
-import org.apache.ignite.transactions.*;
import org.gridgain.grid.util.typedef.*;
import org.gridgain.grid.util.typedef.internal.*;
import org.jdk8.backport.*;
@@ -47,8 +45,8 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
initStore(2);
try {
- store.put(null, 1, "val1");
- store.put(null, 2, "val2");
+ store.put(1, "val1");
+ store.put(2, "val2");
}
finally {
shutdownStore();
@@ -73,24 +71,18 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
initStore(2);
try {
- IgniteTx tx = null;
+ store.put(1, "v1");
+ store.put(2, "v2");
- store.put(tx, 1, "v1");
- store.put(tx, 2, "v2");
+ assertEquals("v1", store.load(1));
+ assertEquals("v2", store.load(2));
+ assertNull(store.load(3));
- store.txEnd(tx, true);
+ store.remove(1);
- assertEquals("v1", store.load(null, 1));
- assertEquals("v2", store.load(null, 2));
- assertNull(store.load(null, 3));
-
- store.remove(tx, 1);
-
- store.txEnd(tx, true);
-
- assertNull(store.load(null, 1));
- assertEquals("v2", store.load(null, 2));
- assertNull(store.load(null, 3));
+ assertNull(store.load(1));
+ assertEquals("v2", store.load(2));
+ assertNull(store.load(3));
}
finally {
shutdownStore();
@@ -109,12 +101,12 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
try {
for (int i = 0; i < CACHE_SIZE * 2; i++)
- store.put(null, i, "val" + i);
+ store.put(i, "val" + i);
U.sleep(200);
for (int i = 0; i < CACHE_SIZE; i++) {
- String val = delegate.load(null, i);
+ String val = delegate.load(i);
assertNotNull("Value for [key= " + i + "] was not written in store", val);
assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
@@ -123,7 +115,7 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
U.sleep(FLUSH_FREQUENCY + 300);
for (int i = CACHE_SIZE; i < CACHE_SIZE * 2; i++) {
- String val = delegate.load(null, i);
+ String val = delegate.load(i);
assertNotNull("Value for [key= " + i + "] was not written in store", val);
assertEquals("Invalid value [key=" + i + "]", "val" + i, val);
@@ -153,17 +145,17 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
try {
while (running.get()) {
for (int i = 0; i < CACHE_SIZE; i++) {
- store.put(null, i, "val-0");
+ store.put(i, "val-0");
actualPutCnt.incrementAndGet();
- store.put(null, i, "val" + i);
+ store.put(i, "val" + i);
actualPutCnt.incrementAndGet();
}
}
}
- catch (IgniteCheckedException e) {
+ catch (Exception e) {
error("Unexpected exception in put thread", e);
assert false;
@@ -213,13 +205,13 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
try {
while (running.get()) {
for (int i = 0; i < CACHE_SIZE; i++) {
- store.put(null, i, "val-0");
+ store.put(i, "val-0");
- store.put(null, i, "val" + i);
+ store.put(i, "val" + i);
}
}
}
- catch (IgniteCheckedException e) {
+ catch (Exception e) {
error("Unexpected exception in put thread", e);
assert false;
@@ -259,7 +251,7 @@ public class GridCacheWriteBehindStoreSelfTest extends GridCacheWriteBehindStore
try {
for (int i = 0; i < CACHE_SIZE; i++) {
- store.put(null, i, "val" + i);
+ store.put(i, "val" + i);
intList.add(i);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
index 5731a86..c1448d7 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/IgniteTxStoreExceptionAbstractSelfTest.java
@@ -18,18 +18,19 @@
package org.gridgain.grid.kernal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.cluster.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.transactions.*;
import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.grid.kernal.*;
import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
import org.gridgain.testframework.*;
import org.jetbrains.annotations.*;
import javax.cache.*;
+import javax.cache.integration.*;
import javax.cache.processor.*;
import java.util.*;
import java.util.concurrent.*;
@@ -591,7 +592,7 @@ public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAb
/**
*
*/
- private static class TestStore implements GridCacheStore<Object, Object> {
+ private static class TestStore implements CacheStore<Object, Object> {
/** Fail flag. */
private volatile boolean fail;
@@ -603,50 +604,49 @@ public abstract class IgniteTxStoreExceptionAbstractSelfTest extends GridCacheAb
}
/** {@inheritDoc} */
- @Nullable @Override public Object load(@Nullable IgniteTx tx, Object key) throws IgniteCheckedException {
+ @Nullable @Override public Object load(Object key) {
return null;
}
/** {@inheritDoc} */
- @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, @Nullable Object... args)
- throws IgniteCheckedException {
+ @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, @Nullable Object... args) {
if (fail)
- throw new IgniteCheckedException("Store exception");
+ throw new CacheLoaderException("Store exception");
}
/** {@inheritDoc} */
- @Override public void loadAll(@Nullable IgniteTx tx, Collection<?> keys, IgniteBiInClosure<Object, Object> c)
- throws IgniteCheckedException {
+ @Override public Map<Object, Object> loadAll(Iterable<?> keys) throws CacheLoaderException {
+ return Collections.emptyMap();
}
/** {@inheritDoc} */
- @Override public void put(@Nullable IgniteTx tx, Object key, Object val) throws IgniteCheckedException {
+ @Override public void write(Cache.Entry<?, ?> entry) {
if (fail)
- throw new IgniteCheckedException("Store exception");
+ throw new CacheWriterException("Store exception");
}
/** {@inheritDoc} */
- @Override public void putAll(@Nullable IgniteTx tx, Map<?, ?> map) throws IgniteCheckedException {
+ @Override public void writeAll(Collection<Cache.Entry<?, ?>> entries) {
if (fail)
- throw new IgniteCheckedException("Store exception");
+ throw new CacheWriterException("Store exception");
}
/** {@inheritDoc} */
- @Override public void remove(@Nullable IgniteTx tx, Object key) throws IgniteCheckedException {
+ @Override public void delete(Object key) throws CacheWriterException {
if (fail)
- throw new IgniteCheckedException("Store exception");
+ throw new CacheWriterException("Store exception");
}
/** {@inheritDoc} */
- @Override public void removeAll(@Nullable IgniteTx tx, Collection<?> keys) throws IgniteCheckedException {
+ @Override public void deleteAll(Collection<?> keys) throws CacheWriterException {
if (fail)
- throw new IgniteCheckedException("Store exception");
+ throw new CacheWriterException("Store exception");
}
/** {@inheritDoc} */
- @Override public void txEnd(IgniteTx tx, boolean commit) throws IgniteCheckedException {
+ @Override public void txEnd(boolean commit) {
if (fail && commit)
- throw new IgniteCheckedException("Store exception");
+ throw new CacheWriterException("Store exception");
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4b8ec5f2/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
index 76405cd..aa8809b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/datastructures/GridCacheAtomicReferenceApiSelfAbstractTest.java
@@ -18,13 +18,13 @@
package org.gridgain.grid.kernal.processors.cache.datastructures;
import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
import org.apache.ignite.configuration.*;
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.gridgain.grid.cache.*;
import org.gridgain.grid.cache.datastructures.*;
-import org.gridgain.grid.cache.store.*;
import org.gridgain.testframework.junits.common.*;
import org.mockito.*;
@@ -74,7 +74,7 @@ public abstract class GridCacheAtomicReferenceApiSelfAbstractTest extends GridCo
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setDistributionMode(NEAR_PARTITIONED);
- ccfg.setStore(Mockito.mock(GridCacheStore.class));
+ ccfg.setStore(Mockito.mock(CacheStore.class));
return ccfg;
}