# IGNITE-219 Fixed cache configuration.

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

Branch: refs/heads/ignite-238
Commit: 36825273ff83e3aaf92c7c4fdd913491b8bef1aa
Parents: 8b7a2c1
Author: AKuznetsov <akuznet...@gridgain.com>
Authored: Fri Feb 13 16:28:33 2015 +0700
Committer: AKuznetsov <akuznet...@gridgain.com>
Committed: Fri Feb 13 16:28:33 2015 +0700

----------------------------------------------------------------------
 .../ignite/internal/visor/cache/VisorCache.java | 51 ----------------
 .../visor/cache/VisorCacheConfiguration.java    | 62 +++++++++++++++++++-
 .../visor/cache/VisorCacheTypeMetadata.java     | 16 +++++
 .../visor/node/VisorGridConfiguration.java      |  2 +-
 4 files changed, 76 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36825273/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
index 7527a0c..a82c943 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.visor.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.store.jdbc.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
@@ -92,12 +91,6 @@ public class VisorCache implements Serializable {
     /** Cache partitions states. */
     private GridDhtPartitionMap partsMap;
 
-    /** Collection of type metadata. */
-    private Collection<VisorCacheTypeMetadata> typeMeta;
-
-    /** Check that cache have JDBC store. */
-    private boolean jdbcStore;
-
     /**
      * @param ignite Grid.
      * @param c Actual cache.
@@ -214,20 +207,6 @@ public class VisorCache implements Serializable {
         if (cnt > 0)
             memSz = (long)((double)memSz / cnt * size);
 
-        Collection<CacheTypeMetadata> cacheMetadata = 
c.configuration().getTypeMetadata();
-
-        if (cacheMetadata == null)
-            cacheMetadata = Collections.emptyList();
-
-        List<VisorCacheTypeMetadata> typeMeta = new 
ArrayList<>(cacheMetadata!= null ? cacheMetadata.size() : 0);
-
-        for (CacheTypeMetadata m: cacheMetadata)
-            typeMeta.add(VisorCacheTypeMetadata.from(m));
-
-        GridCacheContext cctx = 
((IgniteKernal)ignite).internalCache(c.name()).context();
-
-        boolean jdbcStore = cctx.store().configuredStore() instanceof 
CacheAbstractJdbcStore;
-
         VisorCache cache = new VisorCache();
 
         cache.name(cacheName);
@@ -246,8 +225,6 @@ public class VisorCache implements Serializable {
         cache.backupPartitions(bps);
         cache.metrics(VisorCacheMetrics.from(ca));
         cache.partitionMap(partsMap);
-        cache.typeMeta(typeMeta);
-        cache.jdbcStore(jdbcStore);
 
         return cache;
     }
@@ -505,32 +482,4 @@ public class VisorCache implements Serializable {
     @Override public String toString() {
         return S.toString(VisorCache.class, this);
     }
-
-    /**
-     * @param typeMeta New collection of type metadata.
-     */
-    public void typeMeta(Collection<VisorCacheTypeMetadata> typeMeta) {
-        this.typeMeta = typeMeta;
-    }
-
-    /**
-     * @return Collection of type metadata.
-     */
-    public Collection<VisorCacheTypeMetadata> typeMeta() {
-        return typeMeta;
-    }
-
-    /**
-     * @return Check that cache have JDBC store.
-     */
-    public boolean jdbcStore() {
-        return jdbcStore;
-    }
-
-    /**
-     * @param jdbcStore Check that cache have JDBC store.
-     */
-    public void jdbcStore(boolean jdbcStore) {
-        this.jdbcStore = jdbcStore;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36825273/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index 36495e0..427d1c6 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -17,8 +17,12 @@
 
 package org.apache.ignite.internal.visor.cache;
 
+import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.store.jdbc.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
@@ -133,13 +137,34 @@ public class VisorCacheConfiguration implements 
Serializable {
     /** Write behind config */
     private VisorCacheWriteBehindConfiguration writeBehind;
 
+    /** Collection of type metadata. */
+    private Collection<VisorCacheTypeMetadata> typeMeta;
+
+    /** Check that cache have JDBC store. */
+    private boolean jdbcStore;
+
     /**
+     * @param ignite Grid.
      * @param ccfg Cache configuration.
      * @return Data transfer object for cache configuration properties.
      */
-    public static VisorCacheConfiguration from(CacheConfiguration ccfg) {
+    public static VisorCacheConfiguration from(Ignite ignite, 
CacheConfiguration ccfg) {
         // TODO gg-9141 Update Visor.
 
+        Collection<CacheTypeMetadata> cacheMetadata = ccfg.getTypeMetadata();
+
+        if (cacheMetadata == null)
+            cacheMetadata = Collections.emptyList();
+
+        Collection<VisorCacheTypeMetadata> typeMeta = new 
ArrayList<>(cacheMetadata!= null ? cacheMetadata.size() : 0);
+
+        for (CacheTypeMetadata m: cacheMetadata)
+            typeMeta.add(VisorCacheTypeMetadata.from(m));
+
+        GridCacheContext cctx = 
((IgniteKernal)ignite).internalCache(ccfg.getName()).context();
+
+        boolean jdbcStore = cctx.store().configuredStore() instanceof 
CacheAbstractJdbcStore;
+
         VisorCacheConfiguration cfg = new VisorCacheConfiguration();
 
         cfg.name(ccfg.getName());
@@ -173,22 +198,25 @@ public class VisorCacheConfiguration implements 
Serializable {
         cfg.dgcConfiguration(VisorCacheDgcConfiguration.from(ccfg));
         cfg.storeConfiguration(VisorCacheStoreConfiguration.from(ccfg));
         cfg.writeBehind(VisorCacheWriteBehindConfiguration.from(ccfg));
+        cfg.typeMeta(VisorCacheTypeMetadata.list(ccfg.getTypeMetadata()));
+        cfg.jdbcStore(jdbcStore);
 
         return cfg;
     }
 
     /**
+     * @param ignite Grid.
      * @param caches Cache configurations.
      * @return Data transfer object for cache configurations properties.
      */
-    public static Iterable<VisorCacheConfiguration> list(CacheConfiguration[] 
caches) {
+    public static Iterable<VisorCacheConfiguration> list(Ignite ignite, 
CacheConfiguration[] caches) {
         if (caches == null)
             return Collections.emptyList();
 
         final Collection<VisorCacheConfiguration> cfgs = new 
ArrayList<>(caches.length);
 
         for (CacheConfiguration cache : caches)
-            cfgs.add(from(cache));
+            cfgs.add(from(ignite, cache));
 
         return cfgs;
     }
@@ -660,4 +688,32 @@ public class VisorCacheConfiguration implements 
Serializable {
     @Override public String toString() {
         return S.toString(VisorCacheConfiguration.class, this);
     }
+
+    /**
+     * @param typeMeta New collection of type metadata.
+     */
+    public void typeMeta(Collection<VisorCacheTypeMetadata> typeMeta) {
+        this.typeMeta = typeMeta;
+    }
+
+    /**
+     * @return Collection of type metadata.
+     */
+    public Collection<VisorCacheTypeMetadata> typeMeta() {
+        return typeMeta;
+    }
+
+    /**
+     * @return Check that cache have JDBC store.
+     */
+    public boolean jdbcStore() {
+        return jdbcStore;
+    }
+
+    /**
+     * @param jdbcStore Check that cache have JDBC store.
+     */
+    public void jdbcStore(boolean jdbcStore) {
+        this.jdbcStore = jdbcStore;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36825273/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
index e58880c..dec89be 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheTypeMetadata.java
@@ -73,6 +73,22 @@ public class VisorCacheTypeMetadata implements Serializable {
     private Map<String, LinkedHashMap<String, IgniteBiTuple<String, Boolean>>> 
grps;
 
     /**
+     * @param types Cache types metadata configurations.
+     * @return Data transfer object for cache type metadata configurations.
+     */
+    public static Collection<VisorCacheTypeMetadata> 
list(Collection<CacheTypeMetadata> types) {
+        if (types == null)
+            return Collections.emptyList();
+
+        final Collection<VisorCacheTypeMetadata> cfgs = new 
ArrayList<>(types.size());
+
+        for (CacheTypeMetadata type : types)
+            cfgs.add(from(type));
+
+        return cfgs;
+    }
+
+    /**
      * @param m Actual cache type metadata.
      * @return Data transfer object for given cache type metadata.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/36825273/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
index c7bfd3e..764950f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorGridConfiguration.java
@@ -107,7 +107,7 @@ public class VisorGridConfiguration implements Serializable 
{
         includeEventTypes(c.getIncludeEventTypes());
         rest(VisorRestConfiguration.from(c));
         userAttributes(c.getUserAttributes());
-        caches(VisorCacheConfiguration.list(c.getCacheConfiguration()));
+        caches(VisorCacheConfiguration.list(ignite, 
c.getCacheConfiguration()));
         ggfss(VisorGgfsConfiguration.list(c.getGgfsConfiguration()));
         
streamers(VisorStreamerConfiguration.list(c.getStreamerConfiguration()));
         env(new HashMap<>(getenv()));

Reply via email to