You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/06/24 15:49:33 UTC

incubator-ignite git commit: # IGNITE-843 Generate cache configurations when creating Ignite configuration.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 c2be3e437 -> 3e44bf56d


# IGNITE-843 Generate cache configurations when creating Ignite 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/3e44bf56
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3e44bf56
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3e44bf56

Branch: refs/heads/ignite-843
Commit: 3e44bf56dc8cd96d2475fcab3131ed01af0a38d8
Parents: c2be3e4
Author: sevdokimov <se...@gridgain.com>
Authored: Wed Jun 24 16:49:23 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Wed Jun 24 16:49:23 2015 +0300

----------------------------------------------------------------------
 .../webconfig/nodejs/routes/configGenerator.js  |  2 +-
 modules/webconfig/nodejs/utils/generatorJava.js | 46 ++++++++++++++++++--
 modules/webconfig/nodejs/utils/generatorXml.js  | 31 ++++++++++---
 3 files changed, 70 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e44bf56/modules/webconfig/nodejs/routes/configGenerator.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/routes/configGenerator.js b/modules/webconfig/nodejs/routes/configGenerator.js
index 06061fc..0313e9c 100644
--- a/modules/webconfig/nodejs/routes/configGenerator.js
+++ b/modules/webconfig/nodejs/routes/configGenerator.js
@@ -37,7 +37,7 @@ router.get('/', function(req, res) {
         });
 
         // Get all clusters for spaces.
-        db.Cluster.find({name: name, space: {$in: space_ids}}, function (err, clusters) {
+        db.Cluster.find({name: name, space: {$in: space_ids}}).populate('caches').exec(function (err, clusters) {
             if (err)
                 return res.status(500).send(err.message);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e44bf56/modules/webconfig/nodejs/utils/generatorJava.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/utils/generatorJava.js b/modules/webconfig/nodejs/utils/generatorJava.js
index d36a3ae..1219218 100644
--- a/modules/webconfig/nodejs/utils/generatorJava.js
+++ b/modules/webconfig/nodejs/utils/generatorJava.js
@@ -107,6 +107,42 @@ exports.generateClusterConfiguration = function(cluster) {
         res.needEmptyLine = true;
     }
 
+    if (cluster.caches && cluster.caches.length > 0) {
+        res.emptyLineIfNeeded();
+
+        var names = [];
+
+        for (var i = 0; i < cluster.caches.length; i++) {
+            res.emptyLineIfNeeded();
+
+            var cache = cluster.caches[i];
+
+            var cacheName = cache.name.replace(/[^A-Za-z_0-9]+/, '_');
+            cacheName = 'cache' + cacheName.charAt(0).toLocaleUpperCase() + cacheName.slice(1);
+
+            names.push(cacheName);
+
+            generateCacheConfiguration(cache, cacheName, res);
+
+            res.needEmptyLine = true;
+        }
+
+        res.emptyLineIfNeeded();
+
+        res.append('cfg.setCacheConfiguration(');
+
+        for (i = 0; i < names.length; i++) {
+            if (i > 0)
+                res.append(', ');
+
+            res.append(names[i]);
+        }
+
+        res.line(');');
+
+        res.needEmptyLine = true;
+    }
+
     addBeanWithProperties(res, cluster.atomicConfiguration, 'cfg', 'atomicConfiguration', 'atomicCfg',
         generatorUtils.atomicConfiguration.shortClassName, generatorUtils.atomicConfiguration.fields);
 
@@ -199,10 +235,14 @@ function createEvictionPolicy(res, evictionPolicy, varName, propertyName) {
     }
 }
 
-exports.generateCacheConfiguration = function(cacheCfg, varName, res) {
+exports.generateCacheConfiguration = generateCacheConfiguration;
+
+function generateCacheConfiguration(cacheCfg, varName, res) {
     if (!res)
         res = generatorUtils.builder();
-    
+
+    res.emptyLineIfNeeded();
+
     res.line('CacheConfiguration ' + varName + ' = new CacheConfiguration();');
     
     res.needEmptyLine = true;
@@ -324,7 +364,7 @@ exports.generateCacheConfiguration = function(cacheCfg, varName, res) {
     addProperty(res, cacheCfg, varName, 'maxConcurrentAsyncOperations');
     
     return res;
-};
+}
 
 function toJavaCode(val, type) {
     if (val == null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e44bf56/modules/webconfig/nodejs/utils/generatorXml.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/utils/generatorXml.js b/modules/webconfig/nodejs/utils/generatorXml.js
index 4e002d0..8a0b719 100644
--- a/modules/webconfig/nodejs/utils/generatorXml.js
+++ b/modules/webconfig/nodejs/utils/generatorXml.js
@@ -135,6 +135,25 @@ exports.generateClusterConfiguration = function(cluster) {
         res.needEmptyLine = true
     }
 
+    if (cluster.caches && cluster.caches.length > 0) {
+        res.emptyLineIfNeeded();
+
+        res.startBlock('<property name="cacheConfiguration">');
+        res.startBlock('<list>');
+
+        for (var i = 0; i < cluster.caches.length; i++) {
+            if (i > 0)
+                res.line();
+
+            generateCacheConfiguration(cluster.caches[i], res);
+        }
+
+        res.endBlock('</list>');
+        res.endBlock('</property>');
+
+        res.needEmptyLine = true;
+    }
+
     addBeanWithProperties(res, cluster.atomicConfiguration, 'atomicConfiguration',
         generatorUtils.atomicConfiguration.className, generatorUtils.atomicConfiguration.fields);
 
@@ -233,7 +252,7 @@ function createEvictionPolicy(res, evictionPolicy, propertyName) {
     }
 }
 
-exports.generateCacheConfiguration = function(cacheCfg, varName, res) {
+function generateCacheConfiguration(cacheCfg, res) {
     if (!res)
         res = generatorUtils.builder();
 
@@ -273,9 +292,9 @@ exports.generateCacheConfiguration = function(cacheCfg, varName, res) {
 
     res.needEmptyLine = true;
 
-    addProperty(res, cacheCfg, varName, 'sqlEscapeAll');
-    addProperty(res, cacheCfg, varName, 'sqlOnheapRowCacheSize');
-    addProperty(res, cacheCfg, varName, 'longQueryWarningTimeout');
+    addProperty(res, cacheCfg, 'sqlEscapeAll');
+    addProperty(res, cacheCfg, 'sqlOnheapRowCacheSize');
+    addProperty(res, cacheCfg, 'longQueryWarningTimeout');
 
     if (cacheCfg.indexedTypes && cacheCfg.indexedTypes.length > 0) {
         res.startBlock('<property name="indexedTypes">');
@@ -338,7 +357,9 @@ exports.generateCacheConfiguration = function(cacheCfg, varName, res) {
     res.endBlock('</bean>');
 
     return res;
-};
+}
+
+exports.generateCacheConfiguration = generateCacheConfiguration;
 
 function addProperty(res, obj, propName, setterName) {
     var val = obj[propName];