ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-843 WIP on preview.
Date Wed, 26 Aug 2015 03:34:47 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 dfd177450 -> cfaee64d9


IGNITE-843 WIP on preview.


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

Branch: refs/heads/ignite-843
Commit: cfaee64d9ef19650b96f6024fdce76c771c6b479
Parents: dfd1774
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Wed Aug 26 10:35:00 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Wed Aug 26 10:35:00 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    |  26 +++-
 .../src/main/js/routes/caches.js                |   6 +-
 .../main/js/routes/generator/generator-xml.js   | 138 ++++++++++++-------
 3 files changed, 110 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cfaee64d/modules/control-center-web/src/main/js/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/caches-controller.js b/modules/control-center-web/src/main/js/controllers/caches-controller.js
index 3cb2893..291ab90 100644
--- a/modules/control-center-web/src/main/js/controllers/caches-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/caches-controller.js
@@ -183,7 +183,11 @@ controlCenterModule.controller('cachesController', [
                     $scope.caches = data.caches;
                     $scope.clusters = data.clusters;
 
-                    _.forEach(data.metadatas, function (meta) {
+                    var metadatas = _.map(data.metadatas, function (meta) {
+                        return {value: meta._id, label: meta.name, kind: meta.kind, meta:
meta}
+                    });
+
+                    _.forEach(metadatas, function (meta) {
                         var kind = meta.kind;
 
                         if (kind == 'query' || kind == 'both')
@@ -250,10 +254,26 @@ controlCenterModule.controller('cachesController', [
                         if (val) {
                             sessionStorage.cacheBackupItem = angular.toJson(val);
 
+                            var qryMeta = _.reduce($scope.queryMetadata, function(memo, meta){
+                                if (_.contains(val.queryMetadata, meta.value)) {
+                                    memo.push(meta.meta);
+                                }
+
+                                return memo;
+                            }, []);
+
+                            var storeMeta = _.reduce($scope.storeMetadata, function(memo,
meta){
+                                if (_.contains(val.storeMetadata, meta.value)) {
+                                    memo.push(meta.meta);
+                                }
+
+                                return memo;
+                            }, []);
+
                             $scope.preview.general = $generatorXml.cacheGeneral(val).join('');
                             $scope.preview.memory = $generatorXml.cacheMemory(val).join('');
-                            $scope.preview.query = $generatorXml.cacheQuery(val).join('');
-                            $scope.preview.store = $generatorXml.cacheStore(val).join('');
+                            $scope.preview.query = $generatorXml.cacheMetadatas(qryMeta,
null, $generatorXml.cacheQuery(val)).join('');
+                            $scope.preview.store = $generatorXml.cacheMetadatas(null, storeMeta,
$generatorXml.cacheStore(val)).join('');
                             $scope.preview.concurrency = $generatorXml.cacheConcurrency(val).join('');
                             $scope.preview.rebalance = $generatorXml.cacheRebalance(val).join('');
                             $scope.preview.serverNearCache = $generatorXml.cacheServerNearCache(val).join('');

http://git-wip-us.apache.org/repos/asf/ignite/blob/cfaee64d/modules/control-center-web/src/main/js/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/caches.js b/modules/control-center-web/src/main/js/routes/caches.js
index dac1d98..3d2851c 100644
--- a/modules/control-center-web/src/main/js/routes/caches.js
+++ b/modules/control-center-web/src/main/js/routes/caches.js
@@ -44,7 +44,7 @@ router.post('/list', function (req, res) {
             db.Cluster.find({space: {$in: space_ids}}, '_id name').sort('name').exec(function
(err, clusters) {
                 if (db.processed(err, res)) {
                     // Get all caches type metadata for spaces.
-                    db.CacheTypeMetadata.find({space: {$in: space_ids}}, '_id name kind',
function (err, metadatas) {
+                    db.CacheTypeMetadata.find({space: {$in: space_ids}}).sort('name').exec(function
(err, metadatas) {
                         if (db.processed(err, res)) {
                             // Get all caches for spaces.
                             db.Cache.find({space: {$in: space_ids}}).sort('name').exec(function
(err, caches) {
@@ -78,9 +78,7 @@ router.post('/list', function (req, res) {
                                         clusters: clusters.map(function(cluster) {
                                             return {value: cluster._id, label: cluster.name};
                                         }),
-                                        metadatas: metadatas.map(function (meta) {
-                                            return {value: meta._id, label: meta.name, kind:
meta.kind};
-                                        }),
+                                        metadatas: metadatas,
                                         caches: caches});
                                 }
                             });

http://git-wip-us.apache.org/repos/asf/ignite/blob/cfaee64d/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-xml.js b/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
index c3c0ef5..8380a38 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-xml.js
@@ -23,6 +23,13 @@ if (typeof window === 'undefined') {
     $generatorCommon = require('./generator-common');
 }
 
+function _escape(s) {
+    if (typeof(s) != 'string')
+        return s;
+
+    return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g,
'&gt;');
+}
+
 function _escapeAttr(s) {
     if (typeof(s) != 'string')
         return s;
@@ -30,6 +37,21 @@ function _escapeAttr(s) {
     return s.replace(/&/g, '&amp;').replace(/"/g, '&quot;');
 }
 
+function _addElement(res, tag, attr1, val1, attr2, val2) {
+    var elem = '<' + tag;
+
+    if (attr1)
+        elem += ' ' + attr1 + '="' + val1 + '"';
+
+    if (attr2)
+        elem += ' ' + attr2 + '="' + val2 + '"';
+
+    elem += '/>';
+
+    res.emptyLineIfNeeded();
+    res.line(elem);
+}
+
 function _addProperty(res, obj, propName, setterName) {
     if ($commonUtils.isDefined(obj)) {
         var val = obj[propName];
@@ -57,7 +79,7 @@ function _addListProperty(res, obj, propName, listType, rowFactory) {
 
         if (!rowFactory)
             rowFactory = function (val) {
-                return '<value>' + escape(val) + '</value>'
+                return '<value>' + _escape(val) + '</value>'
             };
 
         res.startBlock('<property name="' + propName + '">');
@@ -107,7 +129,7 @@ function _addBeanWithProperties(res, bean, beanPropName, beanClass, props,
creat
                                 var eqIndex = nameAndValue.indexOf('=');
                                 if (eqIndex >= 0) {
                                     res.line('<prop key="' + _escapeAttr(nameAndValue.substring(0,
eqIndex)) + '">' +
-                                        escape(nameAndValue.substr(eqIndex + 1)) + '</prop>');
+                                        _escape(nameAndValue.substr(eqIndex + 1)) + '</prop>');
                                 }
                             }
 
@@ -236,23 +258,6 @@ function _addCacheTypeMetadataGroups(res, meta) {
     }
 }
 
-function _addElement(res, tag, attr1, val1, attr2, val2) {
-    var elem = '<' + tag;
-
-    if (attr1) {
-        elem += ' ' + attr1 + '="' + val1 + '"'
-    }
-
-    if (attr2) {
-        elem += ' ' + attr2 + '="' + val2 + '"'
-    }
-
-    elem += '/>';
-
-    res.emptyLineIfNeeded();
-    res.line(elem);
-}
-
 $generatorXml = {};
 
 // Generate discovery.
@@ -565,6 +570,7 @@ $generatorXml.clusterTransactions = function (cluster, res) {
     return res;
 };
 
+// Generate cache general group.
 $generatorXml.cacheGeneral = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -586,6 +592,7 @@ $generatorXml.cacheGeneral = function(cache, res) {
     return res;
 };
 
+// Generate cache memory group.
 $generatorXml.cacheMemory = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -607,6 +614,7 @@ $generatorXml.cacheMemory = function(cache, res) {
     return res;
 };
 
+// Generate cache query & indexing group.
 $generatorXml.cacheQuery = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -641,6 +649,7 @@ $generatorXml.cacheQuery = function(cache, res) {
     return res;
 };
 
+// Generate cache store group.
 $generatorXml.cacheStore = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -685,6 +694,7 @@ $generatorXml.cacheStore = function(cache, res) {
     return res;
 };
 
+// Generate cache concurrency group.
 $generatorXml.cacheConcurrency = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -698,6 +708,7 @@ $generatorXml.cacheConcurrency = function(cache, res) {
     return res;
 };
 
+// Generate cache rebalance group.
 $generatorXml.cacheRebalance = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -717,6 +728,7 @@ $generatorXml.cacheRebalance = function(cache, res) {
     return res;
 };
 
+// Generate cache server near cache group.
 $generatorXml.cacheServerNearCache = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -742,6 +754,7 @@ $generatorXml.cacheServerNearCache = function(cache, res) {
     return res;
 };
 
+// Generate cache statistics group.
 $generatorXml.cacheStatistics = function(cache, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -754,6 +767,7 @@ $generatorXml.cacheStatistics = function(cache, res) {
     return res;
 };
 
+// Generate metadata general group.
 $generatorXml.metadataGeneral = function(meta, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -766,6 +780,7 @@ $generatorXml.metadataGeneral = function(meta, res) {
     return res;
 };
 
+// Generate metadata for query group.
 $generatorXml.metadataQuery = function(meta, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -783,6 +798,7 @@ $generatorXml.metadataQuery = function(meta, res) {
     return res;
 };
 
+// Generate metadata for store group.
 $generatorXml.metadataStore = function(meta, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -800,6 +816,7 @@ $generatorXml.metadataStore = function(meta, res) {
     return res;
 };
 
+// Generate cache type metadata config.
 $generatorXml.cacheMetadata = function(meta, res) {
     if (!res)
         res = $generatorCommon.builder();
@@ -811,34 +828,19 @@ $generatorXml.cacheMetadata = function(meta, res) {
     $generatorXml.metadataStore(meta, res);
 
     res.endBlock('</bean>');
+
+    res.needEmptyLine = true;
+
+    return res;
 };
 
-// Generate caches configs.
-$generatorXml.cache = function(cache, res) {
+// Generate cache type metadata configs.
+$generatorXml.cacheMetadatas = function(qryMeta, storeMeta, res) {
     if (!res)
         res = $generatorCommon.builder();
 
-    res.startBlock('<bean class="org.apache.ignite.configuration.CacheConfiguration">');
-
-    $generatorXml.cacheGeneral(cache, res);
-
-    $generatorXml.cacheMemory(cache, res);
-
-    $generatorXml.cacheQuery(cache, res);
-
-    $generatorXml.cacheStore(cache, res);
-
-    $generatorXml.cacheConcurrency(cache, res);
-
-    $generatorXml.cacheRebalance(cache, res);
-
-    $generatorXml.cacheServerNearCache(cache, res);
-
-    $generatorXml.cacheStatistics(cache, res);
-
-    // Generate cache type metadata configs.
-    if ((cache.queryMetadata && cache.queryMetadata.length > 0) ||
-        (cache.storeMetadata && cache.storeMetadata.length > 0)) {
+    if ((qryMeta && qryMeta.length > 0) ||
+        (storeMeta && storeMeta.length > 0)) {
         res.emptyLineIfNeeded();
 
         res.startBlock('<property name="typeMetadata">');
@@ -846,8 +848,8 @@ $generatorXml.cache = function(cache, res) {
 
         var metaNames = [];
 
-        if (cache.queryMetadata && cache.queryMetadata.length > 0) {
-            _.forEach(cache.queryMetadata, function (meta) {
+        if (qryMeta && qryMeta.length > 0) {
+            _.forEach(qryMeta, function (meta) {
                 if (!_.contains(metaNames, meta.name)) {
                     metaNames.push(meta.name);
 
@@ -856,8 +858,8 @@ $generatorXml.cache = function(cache, res) {
             });
         }
 
-        if (cache.storeMetadata && cache.storeMetadata.length > 0) {
-            _.forEach(cache.storeMetadata, function (meta) {
+        if (storeMeta && storeMeta.length > 0) {
+            _.forEach(storeMeta, function (meta) {
                 if (!_.contains(metaNames, meta.name)) {
                     metaNames.push(meta.name);
 
@@ -868,8 +870,38 @@ $generatorXml.cache = function(cache, res) {
 
         res.endBlock('</list>');
         res.endBlock('</property>');
+
+        res.needEmptyLine = true;
     }
 
+    return res;
+};
+
+// Generate caches configs.
+$generatorXml.cache = function(cache, res) {
+    if (!res)
+        res = $generatorCommon.builder();
+
+    res.startBlock('<bean class="org.apache.ignite.configuration.CacheConfiguration">');
+
+    $generatorXml.cacheGeneral(cache, res);
+
+    $generatorXml.cacheMemory(cache, res);
+
+    $generatorXml.cacheQuery(cache, res);
+
+    $generatorXml.cacheStore(cache, res);
+
+    $generatorXml.cacheConcurrency(cache, res);
+
+    $generatorXml.cacheRebalance(cache, res);
+
+    $generatorXml.cacheServerNearCache(cache, res);
+
+    $generatorXml.cacheStatistics(cache, res);
+
+    $generatorXml.cacheMetadatas(cache.queryMetadata, cache.storeMetadata);
+
     res.endBlock('</bean>');
 
     return res;
@@ -902,17 +934,17 @@ $generatorXml.clusterCaches = function(caches, res) {
     return res;
 };
 
-$generatorXml.cluster = function (cluster, clientNearConfiguration) {
+$generatorXml.cluster = function (cluster, clientNearCfg) {
     var res = $generatorCommon.builder();
 
-    if (clientNearConfiguration) {
+    if (clientNearCfg) {
         res.startBlock('<bean id="nearCacheBean" class="org.apache.ignite.configuration.NearCacheConfiguration">');
 
-        if (clientNearConfiguration.nearStartSize)
-            _addProperty(res, clientNearConfiguration, 'nearStartSize');
+        if (clientNearCfg.nearStartSize)
+            _addProperty(res, clientNearCfg, 'nearStartSize');
 
-        if (clientNearConfiguration.nearEvictionPolicy && clientNearConfiguration.nearEvictionPolicy.kind)
-            _createEvictionPolicy(res, clientNearConfiguration.nearEvictionPolicy, 'nearEvictionPolicy');
+        if (clientNearCfg.nearEvictionPolicy && clientNearCfg.nearEvictionPolicy.kind)
+            _createEvictionPolicy(res, clientNearCfg.nearEvictionPolicy, 'nearEvictionPolicy');
 
         res.endBlock('</bean>');
 
@@ -922,7 +954,7 @@ $generatorXml.cluster = function (cluster, clientNearConfiguration) {
     // Generate Ignite Configuration.
     res.startBlock('<bean class="org.apache.ignite.configuration.IgniteConfiguration">');
 
-    if (clientNearConfiguration) {
+    if (clientNearCfg) {
         res.line('<property name="clientMode" value="true" />');
 
         res.line();


Mime
View raw message