# 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/eafa1141 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/eafa1141 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/eafa1141 Branch: refs/heads/ignite-107 Commit: eafa11412dcf4181f3235b5fa353267af3f6451c Parents: 2bbf624 Author: sboikov <sboi...@gridgain.com> Authored: Mon Jan 19 14:05:52 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Mon Jan 19 15:45:21 2015 +0300 ---------------------------------------------------------------------- config/fabric/default-config.xml | 6 +- config/hadoop/default-config.xml | 8 +-- .../store/CacheNodeWithStoreStartup.java | 15 ++++- .../store/dummy/CacheDummyPersonStore.java | 11 ++++ .../clients/src/test/resources/spring-cache.xml | 2 +- .../src/test/resources/spring-server-node.xml | 2 +- .../test/resources/spring-server-ssl-node.xml | 2 +- .../java/org/apache/ignite/IgniteCache.java | 8 +-- .../apache/ignite/cache/CacheConfiguration.java | 22 +------- .../cache/store/CacheLoadOnlyStoreAdapter.java | 2 +- .../apache/ignite/cache/store/CacheStore.java | 22 ++++++-- .../ignite/cache/store/CacheStoreAdapter.java | 25 +-------- .../cache/store/CacheStoreBalancingWrapper.java | 2 +- .../cache/store/jdbc/CacheJdbcBlobStore.java | 9 +++ .../processors/cache/IgniteCacheProxy.java | 45 ++++++++++++++- .../resources/IgniteCacheSessionResource.java | 29 ---------- .../cache/CacheStorePartialUpdateException.java | 48 ++++++++++++++++ .../processors/cache/GridCacheContext.java | 7 --- .../cache/GridCacheLoaderWriterStore.java | 2 +- .../processors/cache/GridCacheStoreManager.java | 58 +++++++++++++++----- .../kernal/processors/cache/GridCacheUtils.java | 2 +- .../cache/GridCacheWriteBehindStore.java | 2 +- .../dht/atomic/GridDhtAtomicCache.java | 9 +++ .../cache/transactions/IgniteTxAdapter.java | 3 +- .../processors/resource/GridResourceIoc.java | 33 +++-------- .../resource/GridResourceProcessor.java | 20 ------- .../cache/VisorCacheStoreConfiguration.java | 2 +- .../spring-cache-client-benchmark-1.xml | 2 +- .../spring-cache-client-benchmark-2.xml | 2 +- .../spring-cache-client-benchmark-3.xml | 2 +- .../core/src/test/config/spring-multicache.xml | 2 +- ...CacheJdbcBlobStoreMultithreadedSelfTest.java | 55 ++++++++++--------- .../cache/IgniteCacheAbstractTest.java | 1 - .../IgniteCacheLoaderWriterAbstractTest.java | 3 + .../store/GridCacheBalancingStoreSelfTest.java | 2 +- .../cache/store/GridGeneratingTestStore.java | 2 +- .../cache/GridCacheAbstractSelfTest.java | 1 - ...idCacheConfigurationConsistencySelfTest.java | 6 +- .../cache/GridCacheGenericTestStore.java | 2 +- .../GridCacheGroupLockAbstractSelfTest.java | 6 +- .../GridCacheInterceptorAbstractSelfTest.java | 2 +- .../cache/GridCacheLifecycleAwareSelfTest.java | 25 ++++++--- .../cache/GridCachePartitionedWritesTest.java | 7 ++- .../cache/GridCacheReloadSelfTest.java | 11 +++- .../cache/GridCacheStorePutxSelfTest.java | 18 +++--- .../cache/GridCacheSwapReloadSelfTest.java | 5 +- .../processors/cache/GridCacheTestStore.java | 13 +---- .../GridCacheWriteBehindStoreAbstractTest.java | 6 +- ...BehindStorePartitionedMultiNodeSelfTest.java | 10 +++- .../IgniteTxExceptionAbstractSelfTest.java | 2 +- .../IgniteTxStoreExceptionAbstractSelfTest.java | 8 ++- ...actQueueFailoverDataConsistencySelfTest.java | 2 +- ...CacheAtomicReferenceApiSelfAbstractTest.java | 30 ++++++++-- .../GridCacheSetFailoverAbstractSelfTest.java | 2 +- .../GridCacheClientModesAbstractSelfTest.java | 2 +- ...heExpiredEntriesPreloadAbstractSelfTest.java | 2 +- ...chePartitionedReloadAllAbstractSelfTest.java | 12 +++- ...xOriginatingNodeFailureAbstractSelfTest.java | 2 +- ...cOriginatingNodeFailureAbstractSelfTest.java | 2 +- .../IgniteTxPreloadAbstractTest.java | 2 +- ...heAbstractTransformWriteThroughSelfTest.java | 6 +- .../dht/GridCacheColocatedDebugTest.java | 11 +++- .../near/GridCacheGetStoreErrorSelfTest.java | 10 +++- .../near/GridCacheNearMultiNodeSelfTest.java | 6 +- .../near/GridCacheNearOneNodeSelfTest.java | 7 ++- .../GridCacheNearPartitionedClearSelfTest.java | 6 +- ...ePartitionedBasicStoreMultiNodeSelfTest.java | 6 +- .../GridCachePartitionedLoadCacheSelfTest.java | 16 ++++-- ...achePartitionedPreloadLifecycleSelfTest.java | 2 +- .../GridCachePartitionedStorePutSelfTest.java | 6 +- .../near/GridPartitionedBackupLoadSelfTest.java | 6 +- ...CacheReplicatedPreloadLifecycleSelfTest.java | 2 +- .../GridCacheBatchEvictUnswapSelfTest.java | 11 +++- .../GridCacheEmptyEntriesAbstractSelfTest.java | 10 +++- .../GridCacheEvictionTouchSelfTest.java | 11 +++- .../local/GridCacheLocalLoadAllSelfTest.java | 14 +++-- ...ridCacheContinuousQueryAbstractSelfTest.java | 6 +- .../GridCacheWriteBehindStoreLoadTest.java | 5 +- .../capacity/spring-capacity-cache.xml | 2 +- .../loadtests/colocation/spring-colocation.xml | 2 +- .../swap/GridSwapEvictAllBenchmark.java | 9 ++- .../gridgain/testframework/GridTestUtils.java | 39 +++++++++++++ .../cache/GridAbstractCacheStoreSelfTest.java | 5 +- .../core/src/test/webapp/META-INF/gg-config.xml | 2 +- .../hibernate/GridCacheHibernateBlobStore.java | 9 +++ .../cache/GridCacheAbstractQuerySelfTest.java | 8 ++- .../cache/GridCacheQueryLoadSelfTest.java | 14 +++-- 87 files changed, 572 insertions(+), 304 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/config/fabric/default-config.xml ---------------------------------------------------------------------- diff --git a/config/fabric/default-config.xml b/config/fabric/default-config.xml index eb8ca17..28ef291 100644 --- a/config/fabric/default-config.xml +++ b/config/fabric/default-config.xml @@ -40,7 +40,7 @@ <!-- Local cache configuration. --> - <bean class="org.apache.ignite.cache.GridCacheConfiguration"> + <bean class="org.apache.ignite.cache.CacheConfiguration"> <property name="name" value="partitioned"/> <property name="cacheMode" value="PARTITIONED"/> </bean> @@ -48,7 +48,7 @@ <!-- Replicated cache configuration. --> - <bean class="org.apache.ignite.cache.GridCacheConfiguration"> + <bean class="org.apache.ignite.cache.CacheConfiguration"> <property name="name" value="replicated"/> <property name="cacheMode" value="REPLICATED"/> </bean> @@ -56,7 +56,7 @@ <!-- Partitioned cache configuration. --> - <bean class="org.apache.ignite.cache.GridCacheConfiguration"> + <bean class="org.apache.ignite.cache.CacheConfiguration"> <property name="name" value="local"/> <property name="cacheMode" value="LOCAL"/> </bean> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/config/hadoop/default-config.xml ---------------------------------------------------------------------- diff --git a/config/hadoop/default-config.xml b/config/hadoop/default-config.xml index cb51ff1..90c4259 100644 --- a/config/hadoop/default-config.xml +++ b/config/hadoop/default-config.xml @@ -64,7 +64,7 @@ <!-- Abstract cache configuration for GGFS file data to be used as a template. --> - <bean id="dataCacheCfgBase" class="org.apache.ignite.cache.GridCacheConfiguration" abstract="true"> + <bean id="dataCacheCfgBase" class="org.apache.ignite.cache.CacheConfiguration" abstract="true"> <property name="cacheMode" value="PARTITIONED"/> <property name="atomicityMode" value="TRANSACTIONAL"/> <property name="writeSynchronizationMode" value="FULL_SYNC"/> @@ -80,7 +80,7 @@ <!-- Abstract cache configuration for GGFS metadata to be used as a template. --> - <bean id="metaCacheCfgBase" class="org.apache.ignite.cache.GridCacheConfiguration" abstract="true"> + <bean id="metaCacheCfgBase" class="org.apache.ignite.cache.CacheConfiguration" abstract="true"> <property name="cacheMode" value="REPLICATED"/> <property name="atomicityMode" value="TRANSACTIONAL"/> <property name="writeSynchronizationMode" value="FULL_SYNC"/> @@ -135,12 +135,12 @@ <property name="cacheConfiguration"> <list> <!-- File system metadata cache. --> - <bean class="org.apache.ignite.cache.GridCacheConfiguration" parent="metaCacheCfgBase"> + <bean class="org.apache.ignite.cache.CacheConfiguration" parent="metaCacheCfgBase"> <property name="name" value="ggfs-meta"/> </bean> <!-- File system files data cache. --> - <bean class="org.apache.ignite.cache.GridCacheConfiguration" parent="dataCacheCfgBase"> + <bean class="org.apache.ignite.cache.CacheConfiguration" parent="dataCacheCfgBase"> <property name="name" value="ggfs-data"/> </bean> </list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/examples/src/main/java/org/gridgain/examples/datagrid/store/CacheNodeWithStoreStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/gridgain/examples/datagrid/store/CacheNodeWithStoreStartup.java b/examples/src/main/java/org/gridgain/examples/datagrid/store/CacheNodeWithStoreStartup.java index 6b77a14..1176215 100644 --- a/examples/src/main/java/org/gridgain/examples/datagrid/store/CacheNodeWithStoreStartup.java +++ b/examples/src/main/java/org/gridgain/examples/datagrid/store/CacheNodeWithStoreStartup.java @@ -19,12 +19,14 @@ package org.gridgain.examples.datagrid.store; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; import org.gridgain.examples.datagrid.store.dummy.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; +import javax.cache.configuration.*; import java.util.*; import static org.gridgain.grid.cache.GridCacheAtomicityMode.*; @@ -49,6 +51,7 @@ public class CacheNodeWithStoreStartup { * @return Grid configuration. * @throws IgniteCheckedException If failed. */ + @SuppressWarnings("unchecked") public static IgniteConfiguration configure() throws IgniteCheckedException { IgniteConfiguration cfg = new IgniteConfiguration(); @@ -68,10 +71,16 @@ public class CacheNodeWithStoreStartup { // Set atomicity as transaction, since we are showing transactions in example. cacheCfg.setAtomicityMode(TRANSACTIONAL); + CacheStore store; + // Uncomment other cache stores to try them. - cacheCfg.setStore(new CacheDummyPersonStore()); - // cacheCfg.setStore(new CacheJdbcPersonStore()); - // cacheCfg.setStore(new CacheHibernatePersonStore()); + store = new CacheDummyPersonStore(); + // store = new CacheJdbcPersonStore(); + // store = new CacheHibernatePersonStore(); + + cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); cfg.setDiscoverySpi(discoSpi); cfg.setCacheConfiguration(cacheCfg); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 59ccb23..1b87275 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 @@ -24,6 +24,7 @@ import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; import org.gridgain.examples.datagrid.store.*; import org.gridgain.grid.cache.*; +import org.jetbrains.annotations.*; import javax.cache.*; import java.util.*; @@ -100,4 +101,14 @@ public class CacheDummyPersonStore extends CacheStoreAdapter<Long, Person> { } } } + + /** + * @return Current transaction. + */ + @Nullable + private IgniteTx transaction() { + CacheStoreSession ses = session(); + + return ses != null ? ses.transaction() : null; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/clients/src/test/resources/spring-cache.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-cache.xml b/modules/clients/src/test/resources/spring-cache.xml index d0f5d7b..720a042 100644 --- a/modules/clients/src/test/resources/spring-cache.xml +++ b/modules/clients/src/test/resources/spring-cache.xml @@ -55,7 +55,7 @@ <property name="cacheConfiguration"> <!-- Specify list of cache configurations here. Any property from - GridCacheConfiguration interface can be configured here. + CacheConfiguration interface can be configured here. Note that absolutely all configuration properties are optional. --> <list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/clients/src/test/resources/spring-server-node.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-server-node.xml b/modules/clients/src/test/resources/spring-server-node.xml index 8ce35cb..d1de998 100644 --- a/modules/clients/src/test/resources/spring-server-node.xml +++ b/modules/clients/src/test/resources/spring-server-node.xml @@ -107,7 +107,7 @@ <property name="cacheConfiguration"> <!-- Specify list of cache configurations here. Any property from - GridCacheConfiguration interface can be configured here. + CacheConfiguration interface can be configured here. --> <list> <!-- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/clients/src/test/resources/spring-server-ssl-node.xml ---------------------------------------------------------------------- diff --git a/modules/clients/src/test/resources/spring-server-ssl-node.xml b/modules/clients/src/test/resources/spring-server-ssl-node.xml index e8dfc2d..b03ee79 100644 --- a/modules/clients/src/test/resources/spring-server-ssl-node.xml +++ b/modules/clients/src/test/resources/spring-server-ssl-node.xml @@ -91,7 +91,7 @@ <property name="cacheConfiguration"> <!-- Specify list of cache configurations here. Any property from - GridCacheConfiguration interface can be configured here. + CacheConfiguration interface can be configured here. --> <list> <!-- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 926706b..b5c9d54 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -226,7 +226,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * that entry will be evicted only if it's not used (not * participating in any locks or transactions). * <p> - * If {@link org.apache.ignite.cache.CacheConfiguration#isSwapEnabled()} is set to {@code true} and + * If {@link CacheConfiguration#isSwapEnabled()} is set to {@code true} and * {@link org.gridgain.grid.cache.GridCacheFlag#SKIP_SWAP} is not enabled, the evicted entry will * be swapped to offheap, and then to disk. * <h2 class="header">Cache Flags</h2> @@ -246,7 +246,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * This method does not participate in any transactions, however, it will * peek at transactional value according to the {@link org.gridgain.grid.cache.GridCachePeekMode#SMART} mode * semantics. If you need to look at global cached value even from within transaction, - * you can use {@link org.gridgain.grid.cache.GridCache#peek(Object, java.util.Collection)} method. + * you can use {@link GridCache#peek(Object, java.util.Collection)} method. * * @param key Entry key. * @return Peeked value. @@ -273,7 +273,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * Clears an entry from this cache and swap storage only if the entry * is not currently locked, and is not participating in a transaction. * <p> - * If {@link org.apache.ignite.cache.CacheConfiguration#isSwapEnabled()} is set to {@code true} and + * If {@link CacheConfiguration#isSwapEnabled()} is set to {@code true} and * {@link org.gridgain.grid.cache.GridCacheFlag#SKIP_SWAP} is not enabled, the evicted entries will * also be cleared from swap. * <p> @@ -477,7 +477,7 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * </pre> * <p> * Note that this method makes sense only if cache is working in portable mode - * ({@link org.apache.ignite.cache.CacheConfiguration#isPortableEnabled()} returns {@code true}. If not, + * ({@link CacheConfiguration#isPortableEnabled()} returns {@code true}. If not, * this method is no-op and will return current projection. * * @return Projection for portable objects. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java index 083ee79..c0c76c4 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheConfiguration.java @@ -789,26 +789,8 @@ public class CacheConfiguration extends MutableConfiguration { } /** - * Gets underlying persistent storage for read-through and write-through operations. - * If not provided, cache will not exhibit read-through or write-through behavior. + * Gets factory for underlying persistent storage for read-through and write-through operations. * - * @return Underlying persistent storage for read-through and write-through operations. - */ - @SuppressWarnings({"unchecked"}) - public <K, V> CacheStore<K, V> getStore() { - return null;//(CacheStore<K, V>)store; - } - - /** - * Sets persistent storage for cache data. - * - * @param store Persistent cache store. - */ - public <K, V> void setStore(CacheStore<K, V> store) { - //this.store = store; - } - - /** * @return Cache store factory. */ @SuppressWarnings("unchecked") @@ -817,6 +799,8 @@ public class CacheConfiguration extends MutableConfiguration { } /** + * Sets factory fpr persistent storage for cache data. + * @param storeFactory Cache store factory. */ @SuppressWarnings("unchecked") http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 index 0d7a85b..85aee26 100644 --- 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 @@ -70,7 +70,7 @@ import static java.util.concurrent.TimeUnit.*; * @param <V> Value type. * @param <I> Input type. */ -public abstract class CacheLoadOnlyStoreAdapter<K, V, I> implements CacheStore<K, V> { +public abstract class CacheLoadOnlyStoreAdapter<K, V, I> extends CacheStore<K, V> { /** * Default batch size (number of records read with {@link #inputIterator(Object...)} * and then submitted to internal pool at a time). http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 index 7d845e6..0b0832e 100644 --- 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 @@ -17,8 +17,8 @@ package org.apache.ignite.cache.store; -import org.apache.ignite.IgnitePortables; -import org.apache.ignite.cache.CacheConfiguration; +import org.apache.ignite.*; +import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.jdbc.*; import org.apache.ignite.lang.*; import org.apache.ignite.portables.*; @@ -121,7 +121,10 @@ import static javax.cache.Cache.*; * @see IgnitePortables * @see CacheStoreSession */ -public interface CacheStore<K, V> extends CacheLoader<K, V>, CacheWriter<K, V> { +public abstract class CacheStore<K, V> implements CacheLoader<K, V>, CacheWriter<K, V> { + /** */ + private CacheStoreSession ses; + /** * 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 @@ -141,7 +144,7 @@ public interface CacheStore<K, V> extends CacheLoader<K, V>, CacheWriter<K, V> { * {@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; + public abstract 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'} @@ -152,5 +155,14 @@ public interface CacheStore<K, V> extends CacheLoader<K, V>, CacheWriter<K, V> { * 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; + public abstract void txEnd(boolean commit) throws CacheWriterException; + + /** + * Gets session for current cache operation. Returns {@code null} if store is used with atomic cache. + * + * @return Session for current cache operation. + */ + @Nullable public CacheStoreSession session() { + return ses; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 index 4ec5cbf..232cf9d 100644 --- 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 @@ -18,10 +18,7 @@ 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.*; @@ -36,15 +33,11 @@ import java.util.*; * 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 + * Note that method {@link #loadCache(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; - +public abstract class CacheStoreAdapter<K, V> extends CacheStore<K, V> { /** * Default empty implementation. This method needs to be overridden only if * {@link GridCache#loadCache(IgniteBiPredicate, long, Object...)} method @@ -99,18 +92,4 @@ public abstract class CacheStoreAdapter<K, V> implements CacheStore<K, V> { @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/eafa1141/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 index e8430aa..eadc5e0 100644 --- 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 @@ -33,7 +33,7 @@ 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 class CacheStoreBalancingWrapper<K, V> extends CacheStore<K, V> { /** */ public static final int DFLT_LOAD_ALL_THRESHOLD = 5; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 index 394a5ed..29571c7 100644 --- 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 @@ -574,4 +574,13 @@ public class CacheJdbcBlobStore<K, V> extends CacheStoreAdapter<K, V> { return marsh.unmarshal(bytes, getClass().getClassLoader()); } + + /** + * @return Current transaction. + */ + @Nullable private IgniteTx transaction() { + CacheStoreSession ses = session(); + + return ses != null ? ses.transaction() : null; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index b152ab8..2cd714b 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -926,7 +926,45 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements /** {@inheritDoc} */ @Override public Iterator<Cache.Entry<K, V>> iterator() { // TODO IGNITE-1. - throw new UnsupportedOperationException(); + GridCacheProjectionImpl<K, V> prev = gate.enter(prj); + + try { + final Iterator<GridCacheEntry<K, V>> it = delegate.iterator(); + + return new Iterator<Entry<K, V>>() { + private CacheEntryImpl e; + + @Override + public boolean hasNext() { + return it.hasNext(); + } + + @Override + public Entry<K, V> next() { + if (!hasNext()) + throw new NoSuchElementException(); + + GridCacheEntry<K, V> e0 = it.next(); + + e = new CacheEntryImpl(e0.getKey(), e0.getValue()); + + return e; + } + + @Override + public void remove() { + if (e == null) + throw new IllegalStateException(); + + IgniteCacheProxy.this.remove((K) e.getKey()); + + e = null; + } + }; + } + finally { + gate.leave(prev); + } } /** {@inheritDoc} */ @@ -1038,6 +1076,11 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements * @return Cache exception. */ private CacheException cacheException(IgniteCheckedException e) { + Throwable[] suppressed = e.getSuppressed(); + + if (e.getCause() instanceof CacheException) + return (CacheException)e.getCause(); + if (e instanceof GridCachePartialUpdateException) return new CachePartialUpdateException((GridCachePartialUpdateException)e); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/apache/ignite/resources/IgniteCacheSessionResource.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/resources/IgniteCacheSessionResource.java b/modules/core/src/main/java/org/apache/ignite/resources/IgniteCacheSessionResource.java deleted file mode 100644 index c892dd7..0000000 --- a/modules/core/src/main/java/org/apache/ignite/resources/IgniteCacheSessionResource.java +++ /dev/null @@ -1,29 +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.apache.ignite.resources; - -import java.lang.annotation.*; - -/** - * TODO - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.FIELD}) -public @interface IgniteCacheSessionResource { - // No-op. -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheStorePartialUpdateException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheStorePartialUpdateException.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheStorePartialUpdateException.java new file mode 100644 index 0000000..06b868a --- /dev/null +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheStorePartialUpdateException.java @@ -0,0 +1,48 @@ +/* + * 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 org.apache.ignite.*; + +import java.util.*; + +/** + * + */ +public class CacheStorePartialUpdateException extends IgniteCheckedException { + /** */ + private Collection<Object> failedKeys; + + /** + * @param failedKeys Keys that were not successfully updated. + * @param cause Cause. + */ + @SuppressWarnings("unchecked") + CacheStorePartialUpdateException(Collection failedKeys, Exception cause) { + super(cause); + + this.failedKeys = failedKeys; + } + + /** + * @return Keys that were not successfully updated. + */ + public Collection<Object> failedKeys() { + return failedKeys; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java index e05a7c1..c0f34b6 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java @@ -1399,13 +1399,6 @@ public class GridCacheContext<K, V> implements Externalizable { } /** - * @return {@code True} if store is enabled. - */ - public boolean isStoreEnabled() { - return cacheCfg.getStore() != null && !hasFlag(SKIP_STORE); - } - - /** * @return {@code True} if store read-through mode is enabled. */ public boolean readThrough() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 69b1ea4..70a7880 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 @@ -30,7 +30,7 @@ import java.util.*; /** * Store implementation wrapping {@link CacheLoader} and {@link CacheWriter}. */ -class GridCacheLoaderWriterStore<K, V> implements CacheStore<K, V>, LifecycleAware { +class GridCacheLoaderWriterStore<K, V> extends CacheStore<K, V> implements LifecycleAware { /** */ private final CacheLoader<K, V> ldr; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 9649ba5..7391328 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 @@ -22,18 +22,19 @@ import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.lang.*; import org.apache.ignite.lifecycle.*; -import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; import org.gridgain.grid.*; -import org.gridgain.grid.cache.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.processors.interop.*; +import org.gridgain.grid.util.*; import org.gridgain.grid.util.lang.*; import org.gridgain.grid.util.typedef.*; import org.gridgain.grid.util.typedef.internal.*; import org.jetbrains.annotations.*; import javax.cache.*; +import javax.cache.integration.*; +import java.lang.reflect.*; import java.util.*; import static org.gridgain.grid.cache.GridCacheAtomicityMode.*; @@ -78,16 +79,26 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { CacheConfiguration cfg) throws IgniteCheckedException { this.cfgStore = cfgStore; - store = cacheStoreWrapper(ctx.gridName(), cfgStore, cfg); + store = cacheStoreWrapper(ctx, cfgStore, cfg); singleThreadGate = store == null ? null : new CacheStoreBalancingWrapper<>(store); - boolean sesEnabled0 = false; + if (cfgStore != null && cfg.getAtomicityMode() == TRANSACTIONAL) { + try { + Field sesField = CacheStore.class.getDeclaredField("ses"); + + sesField.setAccessible(true); - if (cfgStore != null && cfg.getAtomicityMode() == TRANSACTIONAL) - sesEnabled0 = ctx.resource().injectStoreSession(cfgStore, new ThreadLocalSession()); + sesField.set(cfgStore, new ThreadLocalSession()); - sesEnabled = sesEnabled0; + sesEnabled = true; + } + catch (IllegalAccessException | NoSuchFieldException e) { + throw new IgniteCheckedException(e); + } + } + else + sesEnabled = true; locStore = U.hasAnnotation(cfgStore, CacheLocalStore.class); } @@ -102,20 +113,22 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { /** * Creates a wrapped cache store if write-behind cache is configured. * - * @param gridName Grid name. + * @param ctx Kernal context. * @param cfgStore Store provided in configuration. * @param cfg Cache configuration. * @return Instance if {@link GridCacheWriteBehindStore} if write-behind store is configured, * or user-defined cache store. */ @SuppressWarnings({"unchecked"}) - private CacheStore cacheStoreWrapper(String gridName, @Nullable CacheStore cfgStore, CacheConfiguration cfg) { + private CacheStore cacheStoreWrapper(GridKernalContext ctx, + @Nullable CacheStore cfgStore, + CacheConfiguration cfg) { if (cfgStore == null || !cfg.isWriteBehindEnabled()) return cfgStore; - GridCacheWriteBehindStore store = new GridCacheWriteBehindStore(gridName, + GridCacheWriteBehindStore store = new GridCacheWriteBehindStore(ctx.gridName(), cfg.getName(), - log, + ctx.log(GridCacheWriteBehindStore.class), cfgStore); store.setFlushSize(cfg.getWriteBehindFlushSize()); @@ -485,6 +498,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { boolean ses = initSession(tx); try { + /* 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) { @@ -492,7 +506,15 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { } }; - store.writeAll(F.viewReadOnly(map.entrySet(), c)); + + Collection<Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>>> col = map.entrySet(); + */ + Collection<Cache.Entry<? extends K, ? extends Object>> entries = new ArrayList<>(map.size()); + + for (Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>> e : map.entrySet()) + entries.add(new CacheEntryImpl<>(e.getKey(), locStore ? e.getValue() : e.getValue().get1())); + + store.writeAll(entries); } catch (ClassCastException e) { handleClassCastException(e); @@ -588,6 +610,12 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { catch (ClassCastException e) { handleClassCastException(e); } + catch (Exception e) { + //if (!keys.isEmpty()) + //throw new CacheStorePartialUpdateException(keys0, e); + + throw new IgniteCheckedException(e); + } finally { if (ses) sesHolder.set(null); @@ -705,7 +733,7 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { */ private Map<Object, Object> properties() { if (props == null) - props = U.newHashMap(1); + props = new GridLeanMap<>(); return props; } @@ -724,10 +752,10 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { /** {@inheritDoc} */ @SuppressWarnings("unchecked") - @Override public <K, V> Map<K, V> properties() { + @Override public <K1, V1> Map<K1, V1> properties() { SessionData ses0 = sesHolder.get(); - return ses0 != null ? (Map<K, V>)ses0.properties() : null; + return ses0 != null ? (Map<K1, V1>)ses0.properties() : null; } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java index 7452e2f..fb4a49f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheUtils.java @@ -1506,7 +1506,7 @@ public class GridCacheUtils { cache.setEvictionPolicy(null); cache.setSwapEnabled(false); cache.setQueryIndexEnabled(false); - cache.setStore(null); + cache.setCacheStoreFactory(null); cache.setEagerTtl(true); cache.setPreloadMode(SYNC); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 d680144..9fb9ac2 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 @@ -58,7 +58,7 @@ import static javax.cache.Cache.Entry; * 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 CacheStore<K, V>, LifecycleAware, GridInteropAware { +public class GridCacheWriteBehindStore<K, V> extends CacheStore<K, V> implements LifecycleAware, GridInteropAware { /** Default write cache initial capacity. */ public static final int DFLT_INITIAL_CAPACITY = 1024; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index 8064b46..b01778a 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -1870,6 +1870,15 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { rmvKeys; ctx.store().removeAllFromStore(null, storeKeys); + /* + try { + ctx.store().removeAllFromStore(null, storeKeys); + } + catch (CacheStorePartialUpdateException e) { + if (e.failedKeys().size() == storeKeys.size()) + + } + */ op = DELETE; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java index 6ab424a..4a23f73 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/transactions/IgniteTxAdapter.java @@ -1186,7 +1186,8 @@ public abstract class IgniteTxAdapter<K, V> extends GridMetadataAwareAdapter assert cacheCtx != null; if (isSystemInvalidate()) - return F.t(cacheCtx.isStoreEnabled() ? RELOAD : DELETE, null, null); + return F.t(cacheCtx.writeThrough() ? RELOAD : DELETE, null, null); + if (F.isEmpty(txEntry.entryProcessors())) return F.t(txEntry.op(), txEntry.value(), txEntry.valueBytes()); else { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java index 4232cbb..d142648 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceIoc.java @@ -99,10 +99,8 @@ class GridResourceIoc { * @param dep Deployment. * @param depCls Deployment class. * @throws IgniteCheckedException Thrown in case of any errors during injection. - * @return {@code True} if resource was injected. */ - @SuppressWarnings("SimplifiableIfStatement") - boolean inject(Object target, Class<? extends Annotation> annCls, GridResourceInjector injector, + void inject(Object target, Class<? extends Annotation> annCls, GridResourceInjector injector, @Nullable GridDeployment dep, @Nullable Class<?> depCls) throws IgniteCheckedException { assert target != null; assert annCls != null; @@ -110,9 +108,7 @@ class GridResourceIoc { if (isAnnotationPresent(target, annCls, dep)) // Use identity hash set to compare via referential equality. - return injectInternal(target, annCls, injector, dep, depCls, new GridIdentityHashSet<>(3)); - - return false; + injectInternal(target, annCls, injector, dep, depCls, new GridIdentityHashSet<>(3)); } /** @@ -123,9 +119,8 @@ class GridResourceIoc { * @param depCls Deployment class. * @param checkedObjs Set of already inspected objects to avoid indefinite recursion. * @throws IgniteCheckedException Thrown in case of any errors during injection. - * @return {@code True} if resource was injected. */ - private boolean injectInternal(Object target, Class<? extends Annotation> annCls, GridResourceInjector injector, + private void injectInternal(Object target, Class<? extends Annotation> annCls, GridResourceInjector injector, @Nullable GridDeployment dep, @Nullable Class<?> depCls, Set<Object> checkedObjs) throws IgniteCheckedException { assert target != null; assert annCls != null; @@ -138,18 +133,16 @@ class GridResourceIoc { // Skip this class if it does not need to be injected. if (skipClss != null && skipClss.contains(targetCls)) - return false; + return; // Check if already inspected to avoid indefinite recursion. if (checkedObjs.contains(target)) - return false; + return; checkedObjs.add(target); int annCnt = 0; - boolean injected = false; - for (GridResourceField field : getFieldsWithAnnotation(dep, targetCls, annCls)) { Field f = field.getField(); @@ -159,32 +152,24 @@ class GridResourceIoc { try { Object obj = f.get(target); - if (obj != null) { + if (obj != null) // Recursion. - boolean injected0 = injectInternal(obj, annCls, injector, dep, depCls, checkedObjs); - - injected |= injected0; - } + injectInternal(obj, annCls, injector, dep, depCls, checkedObjs); } catch (IllegalAccessException e) { throw new IgniteCheckedException("Failed to inject resource [field=" + f.getName() + ", target=" + target + ']', e); } } - else { + else injector.inject(field, target, depCls, dep); - injected = true; - } - annCnt++; } for (GridResourceMethod mtd : getMethodsWithAnnotation(dep, targetCls, annCls)) { injector.inject(mtd, target, depCls, dep); - injected = true; - annCnt++; } @@ -196,8 +181,6 @@ class GridResourceIoc { skipClss.add(targetCls); } - - return injected; } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java index 6299569..998fb8f 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/resource/GridResourceProcessor.java @@ -18,7 +18,6 @@ package org.gridgain.grid.kernal.processors.resource; import org.apache.ignite.*; -import org.apache.ignite.cache.store.*; import org.apache.ignite.compute.*; import org.apache.ignite.configuration.*; import org.apache.ignite.lifecycle.*; @@ -283,25 +282,6 @@ public class GridResourceProcessor extends GridProcessorAdapter { } /** - * Injects cache store session into given object. - * - * @param obj Object. - * @param ses Session to inject. - * @throws IgniteCheckedException If failed to inject. - */ - public boolean injectStoreSession(Object obj, CacheStoreSession ses) throws IgniteCheckedException { - assert obj != null; - - if (log.isDebugEnabled()) - log.debug("Injecting cache store session: " + ses); - - // Unwrap Proxy object. - obj = unwrapTarget(obj); - - return ioc.inject(obj, IgniteCacheSessionResource.class, new GridResourceBasicInjector<>(ses), null, null); - } - - /** * @param obj Object to inject. * @throws IgniteCheckedException If failed to inject. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheStoreConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheStoreConfiguration.java b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheStoreConfiguration.java index db8d62e..659aa04 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheStoreConfiguration.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/visor/cache/VisorCacheStoreConfiguration.java @@ -45,7 +45,7 @@ public class VisorCacheStoreConfiguration implements Serializable { public static VisorCacheStoreConfiguration from(CacheConfiguration ccfg) { VisorCacheStoreConfiguration cfg = new VisorCacheStoreConfiguration(); - cfg.store(compactClass(ccfg.getStore())); + cfg.store(compactClass(ccfg.getCacheStoreFactory())); cfg.valueBytes(ccfg.isStoreValueBytes()); return cfg; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-1.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-1.xml b/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-1.xml index f98f9e6..9da4bc8 100644 --- a/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-1.xml +++ b/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-1.xml @@ -55,7 +55,7 @@ <property name="cacheConfiguration"> <!-- Specify list of cache configurations here. Any property from - GridCacheConfiguration interface can be configured here. + CacheConfiguration interface can be configured here. Note that absolutely all configuration properties are optional. --> <list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-2.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-2.xml b/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-2.xml index 6446bf6..1763b91 100644 --- a/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-2.xml +++ b/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-2.xml @@ -53,7 +53,7 @@ <property name="cacheConfiguration"> <!-- Specify list of cache configurations here. Any property from - GridCacheConfiguration interface can be configured here. + CacheConfiguration interface can be configured here. Note that absolutely all configuration properties are optional. --> <list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-3.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-3.xml b/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-3.xml index 36dbf77..31bf21f 100644 --- a/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-3.xml +++ b/modules/core/src/test/config/benchmark/spring-cache-client-benchmark-3.xml @@ -53,7 +53,7 @@ <property name="cacheConfiguration"> <!-- Specify list of cache configurations here. Any property from - GridCacheConfiguration interface can be configured here. + CacheConfiguration interface can be configured here. Note that absolutely all configuration properties are optional. --> <list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/test/config/spring-multicache.xml ---------------------------------------------------------------------- diff --git a/modules/core/src/test/config/spring-multicache.xml b/modules/core/src/test/config/spring-multicache.xml index 9efe4d8..ca7093e 100644 --- a/modules/core/src/test/config/spring-multicache.xml +++ b/modules/core/src/test/config/spring-multicache.xml @@ -55,7 +55,7 @@ <property name="cacheConfiguration"> <!-- Specify list of cache configurations here. Any property from - GridCacheConfiguration interface can be configured here. + CacheConfiguration interface can be configured here. Note that absolutely all configuration properties are optional. --> <list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 index 05ec90b..8075172 100644 --- 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 @@ -17,6 +17,7 @@ package org.apache.ignite.cache.store.jdbc; +import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; @@ -26,6 +27,8 @@ 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.kernal.*; +import org.gridgain.grid.kernal.processors.cache.*; import org.gridgain.grid.util.typedef.internal.*; import org.gridgain.testframework.junits.common.*; import org.jdk8.backport.*; @@ -54,16 +57,11 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr /** 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); @@ -102,7 +100,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr cc.setBackups(1); cc.setDistributionMode(mode); - cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store())); cc.setReadThrough(true); cc.setWriteThrough(true); @@ -146,13 +144,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr 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); + checkOpenedClosedCount(); } /** @@ -178,13 +170,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr } }, 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); + checkOpenedClosedCount(); } /** @@ -221,13 +207,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr } }, 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); + checkOpenedClosedCount(); } /** @@ -245,4 +225,25 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr return store; } + + /** + * + */ + private void checkOpenedClosedCount() { + assertEquals(GRID_CNT, Ignition.allGrids().size()); + + for (Ignite ignite : Ignition.allGrids()) { + GridCacheContext cctx = ((GridKernal)ignite).internalCache().context(); + + CacheStore store = cctx.store().configuredStore(); + + 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); + } + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 9b14223..b6bf1e3 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 @@ -124,7 +124,6 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest { if (store != null) { cfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); - cfg.setReadThrough(true); cfg.setWriteThrough(true); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java index c9f5634..8da0d01 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java @@ -48,6 +48,9 @@ public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbs * */ static class TestLoader implements CacheLoader<Integer, Integer> { + /** */ + private volatile Map<String, Object> lastOp; + /** {@inheritDoc} */ @Override public Integer load(Integer key) { return null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 262c419..a4ed706 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 @@ -114,7 +114,7 @@ public class GridCacheBalancingStoreSelfTest extends GridCommonAbstractTest { /** * */ - private static class VerifyStore implements CacheStore<Integer, Integer> { + private static class VerifyStore extends CacheStore<Integer, Integer> { /** */ private Lock[] locks; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 80aa5fe..5837af4 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 @@ -30,7 +30,7 @@ import java.util.*; /** * Test store that generates objects on demand. */ -public class GridGeneratingTestStore implements CacheStore<String, String> { +public class GridGeneratingTestStore extends CacheStore<String, String> { /** Number of entries to be generated. */ private static final int DFLT_GEN_CNT = 100; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 e534c1a..4860f4d 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 @@ -237,7 +237,6 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest { if (store != null) { cfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); - cfg.setReadThrough(true); cfg.setWriteThrough(true); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 aaff1c5..d54cd41 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 @@ -744,9 +744,7 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac cfg.setEvictionPolicy(new GridCacheFifoEvictionPolicy()); cfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new TestStore())); - cfg.setReadThrough(true); - cfg.setWriteThrough(true); return null; @@ -825,9 +823,7 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac cc.setDistributionMode(PARTITIONED_ONLY); cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new TestStore())); - cc.setReadThrough(true); - cc.setWriteThrough(true); return null; @@ -1031,7 +1027,7 @@ public class GridCacheConfigurationConsistencySelfTest extends GridCommonAbstrac } /** */ - private static class TestStore implements CacheStore<Object,Object> { + private static class TestStore extends CacheStore<Object,Object> { /** {@inheritDoc} */ @Nullable @Override public Object load(Object key) { return null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 a7bd958..b3e39bf 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 @@ -37,7 +37,7 @@ import static javax.cache.Cache.*; * Test store. */ @SuppressWarnings({"TypeParameterExtendsFinalClass"}) -public class GridCacheGenericTestStore<K, V> implements CacheStore<K, V> { +public class GridCacheGenericTestStore<K, V> extends CacheStore<K, V> { /** Store. */ private final Map<K, V> map = new ConcurrentHashMap<>(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 9155971..5e0298f 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 @@ -38,6 +38,7 @@ import org.gridgain.testframework.junits.common.*; import org.jdk8.backport.*; import javax.cache.*; +import javax.cache.configuration.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; @@ -73,6 +74,7 @@ public abstract class GridCacheGroupLockAbstractSelfTest extends GridCommonAbstr protected abstract GridCacheMode cacheMode(); /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -83,7 +85,9 @@ public abstract class GridCacheGroupLockAbstractSelfTest extends GridCommonAbstr cacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC); cacheCfg.setAtomicityMode(TRANSACTIONAL); - cacheCfg.setStore(store); + cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); cfg.setCacheConfiguration(cacheCfg); cfg.setCacheSanityCheckEnabled(sanityCheckEnabled()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheInterceptorAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheInterceptorAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheInterceptorAbstractSelfTest.java index 3ed86d0..9272800 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheInterceptorAbstractSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheInterceptorAbstractSelfTest.java @@ -95,7 +95,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst } if (!storeEnabled()) - ccfg.setStore(null); + ccfg.setCacheStoreFactory(null); return ccfg; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 4613f3e..4857e7b 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 @@ -33,6 +33,7 @@ import org.gridgain.testframework.junits.common.*; import org.jetbrains.annotations.*; import javax.cache.*; +import javax.cache.configuration.*; import javax.cache.integration.*; import java.util.*; @@ -54,11 +55,18 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS /** */ - private static class TestStore extends TestLifecycleAware implements CacheStore { - /** - */ - TestStore() { - super(CACHE_NAME); + private static class TestStore extends CacheStore implements LifecycleAware { + /** */ + private final TestLifecycleAware lifecycleAware = new TestLifecycleAware(CACHE_NAME); + + /** {@inheritDoc} */ + @Override public void start() throws IgniteCheckedException { + lifecycleAware.start(); + } + + /** {@inheritDoc} */ + @Override public void stop() throws IgniteCheckedException { + lifecycleAware.stop(); } /** {@inheritDoc} */ @@ -247,6 +255,7 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS } /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -266,9 +275,11 @@ public class GridCacheLifecycleAwareSelfTest extends GridAbstractLifecycleAwareS TestStore store = new TestStore(); - ccfg.setStore(store); + ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + ccfg.setReadThrough(true); + ccfg.setWriteThrough(true); - lifecycleAwares.add(store); + lifecycleAwares.add(store.lifecycleAware); TestAffinityFunction affinity = new TestAffinityFunction(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 5292630..f068e6d 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 @@ -27,6 +27,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.gridgain.testframework.junits.common.*; import javax.cache.*; +import javax.cache.configuration.*; import java.util.concurrent.atomic.*; import static org.gridgain.grid.cache.GridCacheAtomicityMode.*; @@ -60,7 +61,11 @@ public class GridCachePartitionedWritesTest extends GridCommonAbstractTest { cc.setAtomicityMode(TRANSACTIONAL); cc.setDistributionMode(NEAR_PARTITIONED); - cc.setStore(store); + assert store != null; + + cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + cc.setReadThrough(true); + cc.setWriteThrough(true); c.setCacheConfiguration(cc); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 4988d90..5c29b01 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 @@ -28,6 +28,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.gridgain.testframework.junits.common.*; import javax.cache.*; +import javax.cache.configuration.*; import java.util.*; import static org.gridgain.grid.cache.GridCacheMode.*; @@ -60,6 +61,7 @@ public class GridCacheReloadSelfTest extends GridCommonAbstractTest { } /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); @@ -79,7 +81,8 @@ 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 CacheStoreAdapter<Integer, Integer>() { + + final CacheStore store = new CacheStoreAdapter<Integer, Integer>() { @Override public Integer load(Integer key) { return key; } @@ -91,7 +94,11 @@ public class GridCacheReloadSelfTest extends GridCommonAbstractTest { @Override public void delete(Object key) { //No-op. } - }); + }; + + cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); if (cacheMode == PARTITIONED) cacheCfg.setBackups(1); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 a70362b..ab2d284 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 @@ -30,6 +30,7 @@ import org.gridgain.testframework.junits.common.*; import org.jetbrains.annotations.*; import javax.cache.*; +import javax.cache.configuration.*; import java.util.*; import java.util.concurrent.atomic.*; @@ -49,17 +50,20 @@ public class GridCacheStorePutxSelfTest extends GridCommonAbstractTest { private static AtomicInteger loads; /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); - CacheConfiguration cache = new CacheConfiguration(); + CacheConfiguration ccfg = new CacheConfiguration(); - cache.setCacheMode(PARTITIONED); - cache.setAtomicityMode(TRANSACTIONAL); - cache.setWriteSynchronizationMode(FULL_SYNC); - cache.setStore(new TestStore()); + ccfg.setCacheMode(PARTITIONED); + ccfg.setAtomicityMode(TRANSACTIONAL); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new TestStore())); + ccfg.setReadThrough(true); + ccfg.setWriteThrough(true); - cfg.setCacheConfiguration(cache); + cfg.setCacheConfiguration(ccfg); TcpDiscoverySpi disco = new TcpDiscoverySpi(); @@ -109,7 +113,7 @@ public class GridCacheStorePutxSelfTest extends GridCommonAbstractTest { } /** */ - private static class TestStore implements CacheStore<Integer, Integer> { + private static class TestStore extends CacheStore<Integer, Integer> { /** {@inheritDoc} */ @Nullable @Override public Integer load(Integer key) { loads.incrementAndGet(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 77817fd..b0f6cb8 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 @@ -33,6 +33,7 @@ import org.gridgain.grid.util.typedef.internal.*; import org.gridgain.testframework.junits.common.*; import javax.cache.*; +import javax.cache.configuration.*; import java.util.*; import java.util.concurrent.*; @@ -69,7 +70,9 @@ public class GridCacheSwapReloadSelfTest extends GridCommonAbstractTest { cacheCfg.setCacheMode(REPLICATED); cacheCfg.setSwapEnabled(true); cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cacheCfg.setStore(new TestStore()); + cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(new TestStore())); + cacheCfg.setReadThrough(true); + cacheCfg.setWriteThrough(true); cfg.setCacheConfiguration(cacheCfg); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eafa1141/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 73f9f54..0203f75 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 @@ -37,11 +37,7 @@ import java.util.concurrent.atomic.*; /** * Test store. */ -public final class GridCacheTestStore implements CacheStore<Integer, String> { - /** */ - @IgniteCacheSessionResource - private CacheStoreSession ses; - +public final class GridCacheTestStore extends CacheStore<Integer, String> { /** Store. */ private final Map<Integer, String> map; @@ -337,11 +333,4 @@ public final class GridCacheTestStore implements CacheStore<Integer, String> { if (tx0.dht()) 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/eafa1141/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java index b42cef9..cad9ae2 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheWriteBehindStoreAbstractTest.java @@ -29,6 +29,7 @@ import org.gridgain.grid.util.typedef.internal.*; import org.gridgain.testframework.junits.common.*; import org.jetbrains.annotations.*; +import javax.cache.configuration.*; import java.util.*; import java.util.concurrent.*; import java.util.concurrent.atomic.*; @@ -74,6 +75,7 @@ public abstract class GridCacheWriteBehindStoreAbstractTest extends GridCommonAb protected abstract GridCacheMode cacheMode(); /** {@inheritDoc} */ + @SuppressWarnings("unchecked") @Override protected final IgniteConfiguration getConfiguration() throws Exception { IgniteConfiguration c = super.getConfiguration(); @@ -91,7 +93,9 @@ public abstract class GridCacheWriteBehindStoreAbstractTest extends GridCommonAb cc.setAtomicityMode(TRANSACTIONAL); cc.setDistributionMode(NEAR_PARTITIONED); - cc.setStore(store); + cc.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + cc.setReadThrough(true); + cc.setWriteThrough(true); cc.setWriteBehindEnabled(true); cc.setWriteBehindFlushFrequency(WRITE_FROM_BEHIND_FLUSH_FREQUENCY);