ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] incubator-ignite git commit: ignite-598: validation
Date Tue, 31 Mar 2015 12:51:09 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-598 21d33261d -> d42ce8157


ignite-598: validation


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

Branch: refs/heads/ignite-598
Commit: 0346735125d339541c498eabfd10dc05b155747d
Parents: 6c2a551
Author: Artem Shutak <ashutak@gridgain.com>
Authored: Tue Mar 31 15:50:44 2015 +0300
Committer: Artem Shutak <ashutak@gridgain.com>
Committed: Tue Mar 31 15:50:44 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridCachePluginContext.java |  4 +++
 .../processors/cache/GridCacheProcessor.java    | 11 +++++++
 .../processors/plugin/CachePluginManager.java   | 31 ++++++++++++++++++++
 .../ignite/plugin/CachePluginContext.java       |  5 ++++
 .../ignite/plugin/CachePluginProvider.java      | 21 +++++++++++++
 5 files changed, 72 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03467351/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java
index def1556..57df0b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridCachePluginContext.java
@@ -46,6 +46,10 @@ public class GridCachePluginContext<C extends CachePluginConfiguration>
implemen
         this.igniteCacheCfg = igniteCacheCfg;
     }
 
+    @Override public IgniteConfiguration igniteConfiguration() {
+        return ctx.config();
+    }
+
     /** {@inheritDoc} */
     @Override public C cacheConfiguration() {
         return (C)cachePluginCfg;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03467351/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 50aece8..16537c6 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
@@ -1015,6 +1015,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         CacheDataStructuresManager dataStructuresMgr = new CacheDataStructuresManager();
         GridCacheTtlManager ttlMgr = new GridCacheTtlManager();
         CachePluginManager pluginMgr = new CachePluginManager(ctx, cfg);
+        
+        pluginMgr.validate();
+        
         GridCacheDrManager drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
 
         GridCacheStoreManager storeMgr = new GridCacheStoreManager(ctx, sesHolders, cfgStore,
cfg);
@@ -2016,6 +2019,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                     true);
             }
         }
+        
+        // TODO: implement remote configs valiudation.
+        // Check plugin configurations.
+//        for (CachePluginConfiguration locPluginCcfg : locCfg.getCachePluginConfigurations())
{
+//            CachePluginProvider provider = ...;
+//
+//            provider.validateRemote(locCfg, locPluginCcfg, rmtCfg, rmtNode);
+//        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03467351/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
index 96d5e79..610cce0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/plugin/CachePluginManager.java
@@ -33,6 +33,7 @@ import java.util.*;
 public class CachePluginManager extends GridCacheManagerAdapter {
     /** */
     private final List<CachePluginProvider> providers = new ArrayList<>();
+
     /**
      * @param ctx Context.
      * @param cfg Cache config.
@@ -90,6 +91,26 @@ public class CachePluginManager extends GridCacheManagerAdapter {
         return null;
     }
 
+    /**
+     * @param cfg Config.
+     * @param cls Class.
+     * @return Not <code>null</code> list.
+     */
+    public static <T extends CachePluginConfiguration> List<T> cachePluginConfigurations(IgniteConfiguration
cfg,
+        Class<T> cls) {
+        List<T> res = new ArrayList<>();
+
+        if (cfg.getCacheConfiguration() != null) {
+            for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) {
+                for (CachePluginConfiguration pluginCcfg : ccfg.getCachePluginConfigurations())
{
+                    if (cls == pluginCcfg.getClass())
+                        res.add((T)pluginCcfg);
+                }
+            }
+        }
+
+        return res;
+    }
 
     /**
      * Creates optional component.
@@ -110,4 +131,14 @@ public class CachePluginManager extends GridCacheManagerAdapter {
         
         throw new IgniteException("Unsupported component type: " + cls);
     }
+
+    /**
+     * Validates cache plugin configurations. Throw exception if validation failed.
+     *
+     * @throws IgniteCheckedException If validation failed.
+     */
+    public void validate() throws IgniteCheckedException {
+        for (CachePluginProvider provider : providers)
+            provider.validate();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03467351/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java
index 87d720d..8f283dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginContext.java
@@ -25,6 +25,11 @@ import org.apache.ignite.configuration.*;
  */
 public interface CachePluginContext<C extends CachePluginConfiguration> {
     /**
+     * @return Ignite configuration.
+     */
+    public IgniteConfiguration igniteConfiguration();
+    
+    /**
      * @return Plugin cache configuration.
      */
     public C cacheConfiguration();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03467351/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
index d086b49..a449d48 100644
--- a/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
+++ b/modules/core/src/main/java/org/apache/ignite/plugin/CachePluginProvider.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.plugin;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
 import org.jetbrains.annotations.*;
 
 /**
@@ -60,4 +62,23 @@ public interface CachePluginProvider<C extends CachePluginConfiguration>
{
      * @return Ignite component or {@code null} if component is not supported.
      */
     @Nullable public <T> T createComponent(Class<T> cls);
+
+    /**
+     * Validates cache plugin configuration in process of cache creation. Throw exception
if validation failed.
+     *
+     * @throws IgniteCheckedException If validation failed.
+     */
+    public void validate() throws IgniteCheckedException;
+
+    /**
+     * Checks that remote caches has configuration compatible with the local.
+     *
+     * @param locCfg
+     * @param locPluginCcfg
+     * @param rmtCfg
+     * @param node
+     * @throws IgniteCheckedException
+     */
+    public void validateRemote(CacheConfiguration locCfg, C locPluginCcfg, CacheConfiguration
rmtCfg, ClusterNode node) 
+        throws IgniteCheckedException;
 }


Mime
View raw message