IGNITE-96 - Fixed lifecycle aware test.

Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/4383923b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4383923b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4383923b

Branch: refs/heads/sprint-1
Commit: 4383923b884897fe20fec36bfa97a6091e32a6c4
Parents: 7a4711c
Author: Alexey Goncharuk <agoncha...@gridgain.com>
Authored: Wed Feb 11 15:06:48 2015 -0800
Committer: Alexey Goncharuk <agoncha...@gridgain.com>
Committed: Wed Feb 11 15:06:48 2015 -0800

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    |  5 +-
 .../processors/cache/GridCacheStoreManager.java | 55 ++++----------------
 .../GridAbstractLifecycleAwareSelfTest.java     |  6 +--
 3 files changed, 15 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4383923b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 81a271e..c7f739c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1431,7 +1431,8 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
                     mgr.stop(cancel);
             }
 
-            U.stopLifecycleAware(log, lifecycleAwares(cache.configuration(), 
ctx.jta().tmLookup()));
+            U.stopLifecycleAware(log, lifecycleAwares(cache.configuration(), 
ctx.jta().tmLookup(),
+                ctx.store().configuredStore()));
 
             if (log.isInfoEnabled())
                 log.info("Stopped cache: " + cache.name());
@@ -1640,7 +1641,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
         if (sysCaches.contains(name))
             throw new IllegalStateException("Failed to get cache because it is 
system cache: " + name);
 
-        IgniteCacheProxy<K, V> cache = (IgniteCacheProxy<K, 
V>)jCacheProxies.get(name);
+        IgniteCache<K,V> cache = (IgniteCache<K, V>)jCacheProxies.get(name);
 
         if (cache == null)
             throw new IllegalArgumentException("Cache is not configured: " + 
name);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4383923b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
index e301d84..f885cf2 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
@@ -30,7 +30,6 @@ import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
-import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.transactions.*;
 import org.jetbrains.annotations.*;
 
@@ -42,6 +41,7 @@ import java.util.*;
 /**
  * Store manager.
  */
+@SuppressWarnings("AssignmentToCatchBlockParameter")
 public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> 
{
     /** */
     private static final String SES_ATTR = "STORE_SES";
@@ -80,7 +80,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      */
     @SuppressWarnings("unchecked")
     public GridCacheStoreManager(GridKernalContext ctx,
-        IdentityHashMap<CacheStore, ThreadLocal> sesHolders,
+        Map<CacheStore, ThreadLocal> sesHolders,
         @Nullable CacheStore<K, Object> cfgStore,
         CacheConfiguration cfg) throws IgniteCheckedException {
         this.cfgStore = cfgStore;
@@ -89,10 +89,10 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
         singleThreadGate = store == null ? null : new 
CacheStoreBalancingWrapper<>(store);
 
-        ThreadLocal<SessionData> sesHolder0 = null;
-
         writeThrough = cfg.isWriteThrough();
 
+        ThreadLocal<SessionData> sesHolder0 = null;
+
         if (cfgStore != null) {
             try {
                 if (!sesHolders.containsKey(cfgStore)) {
@@ -166,23 +166,6 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
     /** {@inheritDoc} */
     @Override protected void start0() throws IgniteCheckedException {
-        if (store instanceof LifecycleAware) {
-            try {
-                // Avoid second start() call on store in case when near cache 
is enabled.
-                if (cctx.config().isWriteBehindEnabled()) {
-                    if (!cctx.isNear())
-                        ((LifecycleAware)store).start();
-                }
-                else {
-                    if (cctx.isNear() || !CU.isNearEnabled(cctx))
-                        ((LifecycleAware)store).start();
-                }
-            }
-            catch (Exception e) {
-                throw new IgniteCheckedException("Failed to start cache store: 
" + e, e);
-            }
-        }
-
         boolean convertPortable = !cctx.keepPortableInStore();
 
         if (cctx.portableEnabled())
@@ -206,26 +189,6 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         this.convertPortable = convertPortable;
     }
 
-    /** {@inheritDoc} */
-    @Override protected void stop0(boolean cancel) {
-        if (store instanceof LifecycleAware) {
-            try {
-                // Avoid second start() call on store in case when near cache 
is enabled.
-                if (cctx.config().isWriteBehindEnabled()) {
-                    if (!cctx.isNear())
-                        ((LifecycleAware)store).stop();
-                }
-                else {
-                    if (cctx.isNear() || !CU.isNearEnabled(cctx))
-                        ((LifecycleAware)store).stop();
-                }
-            }
-            catch (Exception e) {
-                U.error(log(), "Failed to stop cache store.", e);
-            }
-        }
-    }
-
     /**
      * @return {@code true} If local store is configured.
      */
@@ -278,10 +241,10 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             if (log.isDebugEnabled())
                 log.debug("Loading value from store for key: " + key);
 
-            Object val = null;
-
             initSession(tx);
 
+            Object val = null;
+
             try {
                 val = singleThreadGate.load(key);
             }
@@ -384,8 +347,8 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
     @SuppressWarnings("unchecked")
     private void loadAllFromStore(@Nullable IgniteInternalTx tx,
         Collection<? extends K> keys,
-        final @Nullable IgniteBiInClosure<K, V> vis,
-        final @Nullable GridInClosure3<K, V, GridCacheVersion> verVis)
+        @Nullable final IgniteBiInClosure<K, V> vis,
+        @Nullable final GridInClosure3<K, V, GridCacheVersion> verVis)
         throws IgniteCheckedException {
         assert vis != null ^ verVis != null;
         assert verVis == null || locStore;
@@ -423,7 +386,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             initSession(tx);
 
             try {
-                CI2<K, Object> c = new CI2<K, Object>() {
+                IgniteBiInClosure<K,Object> c = new CI2<K, Object>() {
                     @SuppressWarnings("ConstantConditions")
                     @Override public void apply(K k, Object val) {
                         if (convert) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4383923b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
index c4e0f26..a41053b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridAbstractLifecycleAwareSelfTest.java
@@ -25,7 +25,7 @@ import java.util.*;
 import java.util.concurrent.atomic.*;
 
 /**
- * Base class for tests against {@link 
org.apache.ignite.lifecycle.LifecycleAware} support.
+ * Base class for tests against {@link LifecycleAware} support.
  */
 public abstract class GridAbstractLifecycleAwareSelfTest extends 
GridCommonAbstractTest {
     /** */
@@ -68,14 +68,14 @@ public abstract class GridAbstractLifecycleAwareSelfTest 
extends GridCommonAbstr
         }
 
         /**
-         * @return Number of times {@link 
org.apache.ignite.lifecycle.LifecycleAware#start} was called.
+         * @return Number of times {@link LifecycleAware#start} was called.
          */
         public int startCount() {
             return startCnt.get();
         }
 
         /**
-         * @return Number of times {@link 
org.apache.ignite.lifecycle.LifecycleAware#stop} was called.
+         * @return Number of times {@link LifecycleAware#stop} was called.
          */
         public int stopCount() {
             return stopCnt.get();

Reply via email to