ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [1/2] incubator-ignite git commit: # IGNITE-45 Fixed problem with creation CacheStore by CacheLoader and CacheWriter.
Date Wed, 18 Mar 2015 13:59:21 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-45 acaf9cf3c -> c32cb7f08


# IGNITE-45 Fixed problem with creation CacheStore by CacheLoader and CacheWriter.


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

Branch: refs/heads/ignite-45
Commit: 9634cb2dce9f47e77449fc1b50c898f1c674e028
Parents: acaf9cf
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Wed Mar 18 16:55:22 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Mar 18 16:55:22 2015 +0300

----------------------------------------------------------------------
 .../GridCacheLoaderWriterStoreFactory.java      | 56 ++++++++++++++++++++
 .../processors/cache/GridCacheProcessor.java    | 33 +++---------
 .../resources/META-INF/classnames.properties    |  2 +-
 3 files changed, 65 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9634cb2d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
new file mode 100644
index 0000000..cc9de9d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheLoaderWriterStoreFactory.java
@@ -0,0 +1,56 @@
+/*
+ * 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.internal.processors.cache;
+
+import org.apache.ignite.cache.store.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.configuration.*;
+import javax.cache.integration.*;
+
+/**
+ *
+ */
+class GridCacheLoaderWriterStoreFactory<K, V> implements Factory<CacheStore<K,
V>> {
+    /** */
+    private final Factory<CacheLoader<K, V>> ldrFactory;
+
+    /** */
+    private final Factory<CacheWriter<K, V>> writerFactory;
+
+    /**
+     * @param ldrFactory Loader factory.
+     * @param writerFactory Writer factory.
+     */
+    GridCacheLoaderWriterStoreFactory(@Nullable Factory<CacheLoader<K, V>> ldrFactory,
+        @Nullable Factory<CacheWriter<K, V>> writerFactory) {
+        this.ldrFactory = ldrFactory;
+        this.writerFactory = writerFactory;
+
+        assert ldrFactory != null || writerFactory != null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public CacheStore<K, V> create() {
+        CacheLoader<K, V> ldr = ldrFactory == null ? null : ldrFactory.create();
+
+        CacheWriter<K, V> writer = writerFactory == null ? null : writerFactory.create();
+
+        return new GridCacheLoaderWriterStore<>(ldr, writer);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9634cb2d/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 7c44529..ab00cd2 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
@@ -215,28 +215,10 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         if (cfg.getCacheStoreFactory() == null) {
             Factory<CacheLoader> ldrFactory = cfg.getCacheLoaderFactory();
+            Factory<CacheWriter> writerFactory = cfg.isWriteThrough() ? cfg.getCacheWriterFactory()
: null;
 
-            CacheLoader ldr = null;
-
-            if (ldrFactory != null)
-                ldr = ldrFactory.create();
-
-            Factory<CacheWriter> writerFactory = cfg.getCacheWriterFactory();
-
-            CacheWriter writer = null;
-
-            if (cfg.isWriteThrough() && writerFactory != null)
-                writer = writerFactory.create();
-
-            if (ldr != null || writer != null) {
-                final CacheStore store = new GridCacheLoaderWriterStore(ldr, writer);
-
-                cfg.setCacheStoreFactory(new Factory<CacheStore<? super Object, ? super
Object>>() {
-                    @Override public CacheStore<? super Object, ? super Object> create()
{
-                        return store;
-                    }
-                });
-            }
+            if (ldrFactory != null || writerFactory != null)
+                cfg.setCacheStoreFactory(new GridCacheLoaderWriterStoreFactory(ldrFactory,
writerFactory));
         }
         else {
             if (cfg.getCacheLoaderFactory() != null)
@@ -462,7 +444,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param objs Extra components.
      * @throws IgniteCheckedException If failed to inject.
      */
-    private void prepare(CacheConfiguration cfg, Object... objs) throws IgniteCheckedException
{
+    private void prepare(CacheConfiguration cfg, Collection<Object> objs) throws IgniteCheckedException
{
         prepare(cfg, cfg.getEvictionPolicy(), false);
         prepare(cfg, cfg.getAffinity(), false);
         prepare(cfg, cfg.getAffinityMapper(), false);
@@ -993,17 +975,18 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (!sysCaches.contains(cfg.getName()))
             suggestOptimizations(cfg, cfgStore != null);
 
-        List<Object> toPrepare = new ArrayList<>();
+        Collection<Object> toPrepare = new ArrayList<>();
 
         toPrepare.add(jta.tmLookup());
-        toPrepare.add(cfgStore);
 
         if (cfgStore instanceof GridCacheLoaderWriterStore) {
             toPrepare.add(((GridCacheLoaderWriterStore)cfgStore).loader());
             toPrepare.add(((GridCacheLoaderWriterStore)cfgStore).writer());
         }
+        else
+            toPrepare.add(cfgStore);
 
-        prepare(cfg, toPrepare.toArray(new Object[toPrepare.size()]));
+        prepare(cfg, toPrepare);
 
         U.startLifecycleAware(lifecycleAwares(cfg, jta.tmLookup(), cfgStore));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9634cb2d/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 24a13c0..f81b644 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -362,7 +362,7 @@ org.apache.ignite.internal.processors.cache.GridCacheIoManager$2
 org.apache.ignite.internal.processors.cache.GridCacheIoManager$3
 org.apache.ignite.internal.processors.cache.GridCacheIterator
 org.apache.ignite.internal.processors.cache.GridCacheKeySet
-org.apache.ignite.internal.processors.cache.GridCacheLoaderWriterStore
+org.apache.ignite.internal.processors.cache.GridCacheLoaderWriterStoreFactory
 org.apache.ignite.internal.processors.cache.GridCacheLockTimeoutException
 org.apache.ignite.internal.processors.cache.GridCacheLogger
 org.apache.ignite.internal.processors.cache.GridCacheMessage


Mime
View raw message