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/59299cbf Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/59299cbf Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/59299cbf Branch: refs/heads/ignite-sql-tests Commit: 59299cbf317a37aaf4ae5cf9a8ba884225fabec8 Parents: 4383923 Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Wed Feb 11 18:47:14 2015 -0800 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Wed Feb 11 18:47:14 2015 -0800 ---------------------------------------------------------------------- .../processors/cache/GridCacheStoreManager.java | 30 ++++++++++++++++++++ .../cache/GridCacheWriteBehindStore.java | 17 +---------- ...BehindStorePartitionedMultiNodeSelfTest.java | 2 +- 3 files changed, 32 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59299cbf/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 f885cf2..53f6ad6 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,6 +30,7 @@ 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.*; @@ -166,6 +167,19 @@ 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(); + } + } + catch (Exception e) { + throw new IgniteCheckedException("Failed to start cache store: " + e, e); + } + } + boolean convertPortable = !cctx.keepPortableInStore(); if (cctx.portableEnabled()) @@ -175,6 +189,22 @@ public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> { "be ignored because portable mode is not enabled for cache: " + cctx.namex()); } + /** {@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(); + } + } + catch (Exception e) { + U.error(log(), "Failed to stop cache store.", e); + } + } + } + /** * @return Convert-portable flag. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59299cbf/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java index c8017b0..084ebbd 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java @@ -258,16 +258,11 @@ public class GridCacheWriteBehindStore<K, V> extends CacheStore<K, V> implements /** * Performs all the initialization logic for write-behind cache store. * This class must not be used until this method returns. - * - * @throws IgniteCheckedException If cache cannot be started due to some reasons. */ @Override public void start() { assert cacheFlushFreq != 0 || cacheMaxSize != 0; if (stopping.compareAndSet(true, false)) { - if (store instanceof LifecycleAware) - ((LifecycleAware)store).start(); - if (log.isDebugEnabled()) log.debug("Starting write-behind store for cache '" + cacheName + '\''); @@ -337,9 +332,6 @@ public class GridCacheWriteBehindStore<K, V> extends CacheStore<K, V> implements if (!graceful) log.warning("Shutdown was aborted"); - - if (store instanceof LifecycleAware) - ((LifecycleAware)store).stop(); } } @@ -351,14 +343,7 @@ public class GridCacheWriteBehindStore<K, V> extends CacheStore<K, V> implements wakeUp(); } - /** - * Default empty implementation. This method needs to be overridden only if - * {@link org.apache.ignite.cache.GridCache#loadCache(org.apache.ignite.lang.IgniteBiPredicate, long, Object...)} method - * is explicitly called. - * - * @param clo {@inheritDoc} - * @param args {@inheritDoc} - */ + /** {@inheritDoc} */ @Override public void loadCache(IgniteBiInClosure<K, V> clo, @Nullable Object... args) { store.loadCache(clo, args); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/59299cbf/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java index 96595ba..935b1b5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStorePartitionedMultiNodeSelfTest.java @@ -182,7 +182,7 @@ public class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest extends GridC } /** - * @throws org.apache.ignite.internal.IgniteInterruptedCheckedException If sleep was interrupted. + * @throws IgniteInterruptedCheckedException If sleep was interrupted. */ private void checkWrites() throws IgniteInterruptedCheckedException { U.sleep(WRITE_BEHIND_FLUSH_FREQ * 2);