ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [08/34] incubator-ignite git commit: IGNITE-891 - Cache store improvements
Date Tue, 02 Jun 2015 03:51:02 GMT
IGNITE-891 - Cache store improvements


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

Branch: refs/heads/ignite-sprint-5
Commit: b308321d880f540fbda759be9265161a8fd02689
Parents: 463883d
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Mon May 18 18:22:29 2015 -0700
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Mon May 18 18:22:29 2015 -0700

----------------------------------------------------------------------
 .../store/GridCacheStoreManagerAdapter.java     | 44 +++++++++++++++++---
 1 file changed, 39 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b308321d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
index b608bb6..0eaa0cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -69,7 +69,7 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
     private boolean writeThrough;
 
     /** */
-    private CacheStoreSessionListener[] sesLsnrs;
+    private Collection<CacheStoreSessionListener> sesLsnrs;
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
@@ -77,6 +77,14 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
         GridKernalContext ctx = igniteContext();
         CacheConfiguration cfg = cacheConfiguration();
 
+        if (cfgStore != null && !cfg.isWriteThrough() && !cfg.isReadThrough())
{
+            U.quietAndWarn(log,
+                "Persistence store is configured, but both read-through and write-through
are disabled. This " +
+                "configuration makes sense if the store implements loadCache method only.
If this is the " +
+                "case, ignore this warning. Otherwise, fix the configuration for cache: "
+ cfg.getName(),
+                "Persistence store is configured, but both read-through and write-through
are disabled.");
+        }
+
         writeThrough = cfg.isWriteThrough();
 
         this.cfgStore = cfgStore;
@@ -118,14 +126,25 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
      * @param factories Factories.
      * @return Listeners.
      */
-    private CacheStoreSessionListener[] createSessionListeners(Factory<CacheStoreSessionListener>[]
factories) {
+    private Collection<CacheStoreSessionListener> createSessionListeners(Factory<CacheStoreSessionListener>[]
factories)
+        throws IgniteCheckedException {
         if (factories == null)
             return null;
 
-        CacheStoreSessionListener[] lsnrs = new CacheStoreSessionListener[factories.length];
+        Collection<CacheStoreSessionListener> lsnrs = new ArrayList<>(factories.length);
+
+        for (Factory<CacheStoreSessionListener> factory : factories) {
+            CacheStoreSessionListener lsnr = factory.create();
 
-        for (int i = 0; i < factories.length; i++)
-            lsnrs[i] = factories[i].create();
+            if (lsnr != null) {
+                cctx.kernalContext().resource().injectGeneric(lsnr);
+
+                if (lsnr instanceof LifecycleAware)
+                    ((LifecycleAware)lsnr).start();
+
+                lsnrs.add(lsnr);
+            }
+        }
 
         return lsnrs;
     }
@@ -195,6 +214,21 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
                 U.error(log(), "Failed to stop cache store.", e);
             }
         }
+
+        if (sesLsnrs != null) {
+            for (CacheStoreSessionListener lsnr : sesLsnrs) {
+                if (lsnr instanceof LifecycleAware)
+                    ((LifecycleAware)lsnr).stop();
+
+                try {
+                    cctx.kernalContext().resource().cleanupGeneric(lsnr);
+                }
+                catch (IgniteCheckedException e) {
+                    U.error(log, "Failed to remove injected resources from store session
listener (ignoring): " +
+                        lsnr, e);
+                }
+            }
+        }
     }
 
     /** {@inheritDoc} */


Mime
View raw message