ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [1/3] incubator-ignite git commit: # IGNITE-843 Extract createEvictionPolicy() method.
Date Wed, 24 Jun 2015 12:24:50 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 56d8c671e -> c2be3e437


# IGNITE-843 Extract createEvictionPolicy() method.


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

Branch: refs/heads/ignite-843
Commit: 468271fa71ac5331ea6c535edfcdb9a5368ab632
Parents: 56d8c67
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Wed Jun 24 12:16:31 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Wed Jun 24 12:16:31 2015 +0300

----------------------------------------------------------------------
 modules/webconfig/nodejs/utils/generatorJava.js | 28 ++++++++------------
 .../webconfig/nodejs/utils/generatorUtils.js    |  8 ++++++
 2 files changed, 19 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/468271fa/modules/webconfig/nodejs/utils/generatorJava.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/utils/generatorJava.js b/modules/webconfig/nodejs/utils/generatorJava.js
index 4386694..ced6ac3 100644
--- a/modules/webconfig/nodejs/utils/generatorJava.js
+++ b/modules/webconfig/nodejs/utils/generatorJava.js
@@ -202,12 +202,15 @@ exports.generateClusterConfiguration = function(cluster) {
     return res.join('');
 };
 
-var evictionPolicies = {
-    'LRU': {shortClassName: 'LruEvictionPolicy', fields: {batchSize: null, maxMemorySize:
null, maxSize: null}},
-    'RND': {shortClassName: 'RandomEvictionPolicy', fields: {maxSize: null}},
-    'FIFO': {shortClassName: 'FifoEvictionPolicy', fields: {batchSize: null, maxMemorySize:
null, maxSize: null}},
-    'SORTED': {shortClassName: 'SortedEvictionPolicy', fields: {batchSize: null, maxMemorySize:
null, maxSize: null}}
-};
+function createEvictionPolicy(res, evictionPolicy, varName, propertyName) {
+    if (evictionPolicy && evictionPolicy.kind) {
+        var e = generatorUtils.evictionPolicies[evictionPolicy.kind];
+
+        var obj = evictionPolicy[evictionPolicy.kind.toUpperCase()];
+
+        addBeanWithProperties(res, obj, varName, propertyName, propertyName, e.shortClassName,
e.fields, true);
+    }
+}
 
 exports.generateCacheConfiguration = function(cacheCfg, varName, res) {
     if (!res)
@@ -233,13 +236,8 @@ exports.generateCacheConfiguration = function(cacheCfg, varName, res)
{
     addProperty(res, cacheCfg, varName, 'swapEnabled');
 
     res.needEmptyLine = true;
-    
-    if (cacheCfg.evictionPolicy && cacheCfg.evictionPolicy.kind) {
-        var e = evictionPolicies[cacheCfg.evictionPolicy.kind];
 
-        addBeanWithProperties(res, cacheCfg.evictionPolicy[cacheCfg.evictionPolicy.kind.toUpperCase()],
varName, 
-            'evictionPolicy', 'evictionPolicy', e.shortClassName, e.fields, true);
-    }
+    createEvictionPolicy(res, cacheCfg.evictionPolicy, varName, 'evictionPolicy');
 
     res.needEmptyLine = true;
     
@@ -247,11 +245,7 @@ exports.generateCacheConfiguration = function(cacheCfg, varName, res)
{
         'NearCacheConfiguration', {nearStartSize: null, atomicSequenceReserveSize: null},
true);
     
     if (cacheCfg.nearConfiguration && cacheCfg.nearConfiguration.nearEvictionPolicy
&& cacheCfg.nearConfiguration.nearEvictionPolicy.kind) {
-        var evictionPolicy = cacheCfg.nearConfiguration.nearEvictionPolicy;
-        e = evictionPolicies[evictionPolicy.kind];
-        
-        addBeanWithProperties(res, evictionPolicy[evictionPolicy.kind.toUpperCase()], 'nearConfiguration',
-            'nearEvictionPolicy', 'nearEvictionPolicy', e.shortClassName, e.fields, true);
+        createEvictionPolicy(res, cacheCfg.nearConfiguration.nearEvictionPolicy, 'nearConfiguration',
'nearEvictionPolicy');
     }
 
     res.needEmptyLine = true;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/468271fa/modules/webconfig/nodejs/utils/generatorUtils.js
----------------------------------------------------------------------
diff --git a/modules/webconfig/nodejs/utils/generatorUtils.js b/modules/webconfig/nodejs/utils/generatorUtils.js
index 84e8f62..d29e35c 100644
--- a/modules/webconfig/nodejs/utils/generatorUtils.js
+++ b/modules/webconfig/nodejs/utils/generatorUtils.js
@@ -104,6 +104,14 @@ exports.builder = function () {
     return res;
 };
 
+exports.evictionPolicies = {
+    'LRU': {shortClassName: 'LruEvictionPolicy', fields: {batchSize: null, maxMemorySize:
null, maxSize: null}},
+    'RND': {shortClassName: 'RandomEvictionPolicy', fields: {maxSize: null}},
+    'FIFO': {shortClassName: 'FifoEvictionPolicy', fields: {batchSize: null, maxMemorySize:
null, maxSize: null}},
+    'SORTED': {shortClassName: 'SortedEvictionPolicy', fields: {batchSize: null, maxMemorySize:
null, maxSize: null}}
+};
+
+
 exports.writeProperties = function(writer, cluster) {
     
 };
\ No newline at end of file


Mime
View raw message