ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [1/2] ignite git commit: IGNITE-843 XML and Java code generation: fixed logic and added support for default values.
Date Tue, 15 Sep 2015 09:25:05 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 70e48e6f4 -> dfd927b0d


IGNITE-843 XML and Java code generation: fixed logic and added support for default values.


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

Branch: refs/heads/ignite-843
Commit: b44677c4fa2e2f81a95b093983abf1373cce510a
Parents: 4d48d0d
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Tue Sep 15 16:24:33 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Tue Sep 15 16:24:33 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/caches-controller.js    |   2 +-
 .../src/main/js/helpers/common-utils.js         |  28 +++++
 .../js/routes/generator/generator-common.js     |  45 +++++---
 .../main/js/routes/generator/generator-java.js  | 102 +++++++++++--------
 .../js/routes/generator/generator-properties.js |   2 +-
 .../main/js/routes/generator/generator-xml.js   |  80 +++++++++------
 6 files changed, 173 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b44677c4/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 db8ee4f..325bc1f 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
@@ -274,7 +274,7 @@ controlCenterModule.controller('cachesController', [
                     $scope.$watch('backupItem', function (val) {
                         if (val) {
                             var metas = cacheMetadatas(val);
-                            var varName = 'cache';
+                            var varName = $commonUtils.toJavaName('cache', val.name);
 
                             $scope.preview.general.xml = $generatorXml.cacheMetadatas(metas,
$generatorXml.cacheGeneral(val)).asString();
                             $scope.preview.general.java = $generatorJava.cacheMetadatas(metas,
varName, $generatorJava.cacheGeneral(val, varName)).asString();

http://git-wip-us.apache.org/repos/asf/ignite/blob/b44677c4/modules/control-center-web/src/main/js/helpers/common-utils.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/common-utils.js b/modules/control-center-web/src/main/js/helpers/common-utils.js
index b8dd058..15b9534 100644
--- a/modules/control-center-web/src/main/js/helpers/common-utils.js
+++ b/modules/control-center-web/src/main/js/helpers/common-utils.js
@@ -42,6 +42,34 @@ $commonUtils.hasProperty = function (obj, props) {
     return false;
 };
 
+/**
+ * @param obj Object to check.
+ * @param props Array of properties names.
+ * @returns {boolean} 'true' if
+ */
+$commonUtils.hasAtLeastOneProperty = function (obj, props) {
+    if (obj && props) {
+        return _.findIndex(props, function (prop) {
+                return $commonUtils.isDefined(obj[prop]);
+            }) >= 0;
+    }
+
+    return false;
+};
+
+/**
+ * Convert some name to valid java name.
+ *
+ * @param prefix To append to java name.
+ * @param name to convert.
+ * @returns {string} Valid java name.
+ */
+$commonUtils.toJavaName = function (prefix, name) {
+    var javaName = name ? name.replace(/[^A-Za-z_0-9]+/, '_') : 'dflt';
+
+    return prefix + javaName.charAt(0).toLocaleUpperCase() + javaName.slice(1);
+};
+
 $commonUtils.randomString = function (len) {
     var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
     var possibleLen = possible.length;

http://git-wip-us.apache.org/repos/asf/ignite/blob/b44677c4/modules/control-center-web/src/main/js/routes/generator/generator-common.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-common.js b/modules/control-center-web/src/main/js/routes/generator/generator-common.js
index 100df46..72362d3 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-common.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-common.js
@@ -19,6 +19,7 @@
 if (typeof window === 'undefined') {
     _ = require('lodash');
 
+    $commonUtils = require('../../helpers/common-utils');
     $dataStructures = require('../../helpers/data-structures');
 }
 
@@ -57,10 +58,36 @@ $generatorCommon.builder = function () {
     var res = [];
 
     res.deep = 0;
-
+    res.needEmptyLine = false;
     res.lineStart = true;
-
     res.datasources = [];
+    res.imports = {};
+
+    res.safeDeep = 0;
+    res.safeNeedEmptyLine = false;
+    res.safeImports = {};
+    res.safeDatasources = [];
+    res.safePoint = -1;
+
+    res.startSafeBlock = function () {
+        res.safeDeep = this.deep;
+        this.safeNeedEmptyLine = this.needEmptyLine;
+        this.safeImports = _.cloneDeep(this.imports);
+        this.safeDatasources = this.datasources.slice();
+        this.safePoint = this.length;
+    };
+
+    res.rollbackSafeBlock = function () {
+        if (this.safePoint >= 0) {
+            this.splice(this.safePoint, this.length - this.safePoint);
+
+            this.deep = res.safeDeep;
+            this.needEmptyLine = this.safeNeedEmptyLine;
+            this.datasources = this.safeDatasources;
+            this.imports = this.safeImports;
+            this.safePoint = -1;
+        }
+    };
 
     res.asString = function() {
       return this.join('\n');
@@ -117,8 +144,6 @@ $generatorCommon.builder = function () {
         }
     };
 
-    res.imports = {};
-
     /**
      * Add class to imports.
      *
@@ -161,16 +186,6 @@ $generatorCommon.builder = function () {
     return res;
 };
 
-// Atomic configuration code generation descriptor.
-$generatorCommon.ATOMIC_CONFIGURATION = {
-    className: 'org.apache.ignite.configuration.AtomicConfiguration',
-    fields: {
-        backups: null,
-        cacheMode: {type: 'enum', enumClass: 'org.apache.ignite.cache.CacheMode', dflt: 'PARTITIONED'},
-        atomicSequenceReserveSize: null
-    }
-};
-
 // Eviction policies code generation descriptors.
 $generatorCommon.EVICTION_POLICIES = {
     LRU: {
@@ -266,7 +281,7 @@ $generatorCommon.STORE_FACTORIES = {
 $generatorCommon.SWAP_SPACE_SPI = {
     className: 'org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi',
     fields: {
-        baseDirectory: null,
+        baseDirectory: {type: 'path'},
         readStripesNumber: null,
         maximumSparsity: {type: 'float'},
         maxWriteQueueSize: null,

http://git-wip-us.apache.org/repos/asf/ignite/blob/b44677c4/modules/control-center-web/src/main/js/routes/generator/generator-java.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-java.js b/modules/control-center-web/src/main/js/routes/generator/generator-java.js
index dce71c2..2a063d3 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-java.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-java.js
@@ -28,19 +28,6 @@ if (typeof window === 'undefined') {
 $generatorJava = {};
 
 /**
- * Convert some name to valid java name.
- *
- * @param prefix To append to java name.
- * @param name to convert.
- * @returns {string} Valid java name.
- */
-$generatorJava.toJavaName = function (prefix, name) {
-    var javaName = name ? name.replace(/[^A-Za-z_0-9]+/, '_') : 'dflt';
-
-    return prefix + javaName.charAt(0).toLocaleUpperCase() + javaName.slice(1);
-};
-
-/**
  * Translate some value to valid java code.
  *
  * @param val Value to convert.
@@ -51,11 +38,14 @@ $generatorJava.toJavaCode = function (val, type) {
     if (val == null)
         return 'null';
 
+    if (type == 'class')
+        return val + '.class';
+
     if (type == 'float')
         return val + 'f';
 
-    if (type == 'class')
-        return val + '.class';
+    if (type == 'path')
+        return '"' + val.replace('\\', '\\\\') + '"';
 
     if (type)
         return type + '.' + val;
@@ -71,10 +61,11 @@ $generatorJava.toJavaCode = function (val, type) {
 
 /**
  * @param propName Property name
+ * @param setterName Optional concrete setter name.
  * @returns Property setter with name by java conventions.
  */
-$generatorJava.setterName = function (propName) {
-    return $generatorJava.toJavaName('set', propName);
+$generatorJava.setterName = function (propName, setterName) {
+    return setterName ? setterName : $commonUtils.toJavaName('set', propName);
 };
 
 /**
@@ -129,20 +120,28 @@ $generatorJava.declareVariable = function (res, varNew, varName, varFullType,
va
  * @param varName Variable name.
  * @param obj Source object with data.
  * @param propName Property name to take from source object.
- * @param enumType Optional info about property datatype.
+ * @param dataType Optional info about property data type.
  * @param setterName Optional special setter name.
+ * @param dflt Optional default value.
  */
-$generatorJava.property = function (res, varName, obj, propName, enumType, setterName) {
+$generatorJava.property = function (res, varName, obj, propName, dataType, setterName, dflt)
{
     var val = obj[propName];
 
     if ($commonUtils.isDefined(val)) {
-        res.emptyLineIfNeeded();
+        var hasDflt = $commonUtils.isDefined(dflt);
+
+        // Add to result if no default provided or value not equals to default.
+        if (!hasDflt || (hasDflt && val != dflt)) {
+            res.emptyLineIfNeeded();
+
+            res.line(varName + '.' + $generatorJava.setterName(propName, setterName)
+                + '(' + $generatorJava.toJavaCode(val, dataType) + ');');
 
-        res.line(varName + '.' + $generatorJava.setterName(setterName ? setterName : propName)
-            + '(' + $generatorJava.toJavaCode(val, enumType) + ');');
+            return true;
+        }
     }
 
-    return val;
+    return false;
 };
 
 /**
@@ -172,7 +171,7 @@ $generatorJava.listProperty = function (res, varName, obj, propName, enumType,
s
 
         res.importClass('java.util.Arrays');
 
-        res.append(varName + '.' + $generatorJava.setterName(setterName ? setterName : propName)
+ '(Arrays.asList(');
+        res.append(varName + '.' + $generatorJava.setterName(propName, setterName) + '(Arrays.asList(');
 
         for (var i = 0; i < val.length; i++) {
             if (i > 0)
@@ -194,7 +193,7 @@ $generatorJava.multiparamProperty = function (res, varName, obj, propName,
type,
     if (val && val.length > 0) {
         res.emptyLineIfNeeded();
 
-        res.append(varName + '.' + $generatorJava.setterName(setterName ? setterName : propName)
+ '(');
+        res.append(varName + '.' + $generatorJava.setterName(propName, setterName) + '(');
 
         for (var i = 0; i < val.length; i++) {
             if (i > 0)
@@ -231,6 +230,10 @@ $generatorJava.beanProperty = function (res, varName, bean, beanPropName,
beanVa
                             $generatorJava.property(res, beanVarName, bean, propName, 'float',
descr.setterName);
                             break;
 
+                        case 'path':
+                            $generatorJava.property(res, beanVarName, bean, propName, 'path',
descr.setterName);
+                            break;
+
                         case 'propertiesAsList':
                             var val = bean[propName];
 
@@ -410,12 +413,33 @@ $generatorJava.clusterAtomics = function (cluster, res) {
     if (!res)
         res = $generatorCommon.builder();
 
-    var atomicCfg = $generatorCommon.ATOMIC_CONFIGURATION;
+    var atomics = cluster.atomicConfiguration;
 
-    $generatorJava.beanProperty(res, 'cfg', cluster.atomicConfiguration, 'atomicConfiguration',
'atomicCfg',
-        atomicCfg.className, atomicCfg.fields);
+    if ($commonUtils.hasAtLeastOneProperty(atomics, ['cacheMode', 'atomicSequenceReserveSize',
'backups'])) {
+        res.startSafeBlock();
 
-    res.needEmptyLine = true;
+        $generatorJava.declareVariable(res, true, 'atomicCfg', 'org.apache.ignite.configuration.AtomicConfiguration');
+
+        $generatorJava.property(res, 'atomicCfg', atomics, 'cacheMode');
+
+        var cacheMode = atomics.cacheMode ? atomics.cacheMode : 'PARTITIONED';
+
+        var hasData = cacheMode != 'PARTITIONED';
+
+        hasData = $generatorJava.property(res, 'atomicCfg', atomics, 'atomicSequenceReserveSize')
|| hasData;
+
+        if (cacheMode == 'PARTITIONED')
+            hasData = $generatorJava.property(res, 'atomicCfg', atomics, 'backups') || hasData;
+
+        res.needEmptyLine = true;
+
+        res.line('cfg.setAtomicConfiguration(atomicCfg);');
+
+        res.needEmptyLine = true;
+
+        if (!hasData)
+            res.rollbackSafeBlock();
+    }
 
     return res;
 };
@@ -429,7 +453,7 @@ $generatorJava.clusterCommunication = function (cluster, res) {
     $generatorJava.property(res, 'cfg', cluster, 'networkSendRetryDelay');
     $generatorJava.property(res, 'cfg', cluster, 'networkSendRetryCount');
     $generatorJava.property(res, 'cfg', cluster, 'segmentCheckFrequency');
-    $generatorJava.property(res, 'cfg', cluster, 'waitForSegmentOnStart');
+    $generatorJava.property(res, 'cfg', cluster, 'waitForSegmentOnStart', null, null, false);
     $generatorJava.property(res, 'cfg', cluster, 'discoveryStartupDelay');
 
     res.needEmptyLine = true;
@@ -442,7 +466,7 @@ $generatorJava.clusterDeployment = function (cluster, res) {
     if (!res)
         res = $generatorCommon.builder();
 
-    $generatorJava.property(res, 'cfg', cluster, 'deploymentMode', 'DeploymentMode');
+    $generatorJava.property(res, 'cfg', cluster, 'deploymentMode', null, null, 'SHARED');
 
     res.needEmptyLine = true;
 
@@ -515,7 +539,7 @@ $generatorJava.clusterMarshaller = function (cluster, res) {
         $generatorJava.beanProperty(res, 'marshaller', marshaller[marshaller.kind], marshallerDesc.className,
marshallerDesc.fields, true);
     }
 
-    $generatorJava.property(res, 'cfg', cluster, 'marshalLocalJobs');
+    $generatorJava.property(res, 'cfg', cluster, 'marshalLocalJobs', null, null, false);
     $generatorJava.property(res, 'cfg', cluster, 'marshallerCacheKeepAliveTime');
     $generatorJava.property(res, 'cfg', cluster, 'marshallerCacheThreadPoolSize');
 
@@ -547,7 +571,7 @@ $generatorJava.clusterP2p = function (cluster, res) {
     var p2pEnabled = cluster.peerClassLoadingEnabled;
 
     if ($commonUtils.isDefined(p2pEnabled)) {
-        $generatorJava.property(res, 'cfg', cluster, 'peerClassLoadingEnabled');
+        $generatorJava.property(res, 'cfg', cluster, 'peerClassLoadingEnabled', null, null,
false);
 
         if (p2pEnabled) {
             $generatorJava.property(res, 'cfg', cluster, 'peerClassLoadingMissedResourcesCacheSize');
@@ -708,13 +732,13 @@ $generatorJava.cacheStore = function (cache, varName, res) {
         if (storeFactory) {
             var storeFactoryDesc = $generatorCommon.STORE_FACTORIES[cache.cacheStoreFactory.kind];
 
-            var sfVarName = $generatorJava.toJavaName('storeFactory', cache.name);
+            var sfVarName = $commonUtils.toJavaName('storeFactory', cache.name);
             var dsVarName = 'none';
 
             if (storeFactory.dialect) {
                 var dataSourceBean = storeFactory.dataSourceBean;
 
-                dsVarName = $generatorJava.toJavaName('dataSource', dataSourceBean);
+                dsVarName = $commonUtils.toJavaName('dataSource', dataSourceBean);
 
                 if (!_.contains(res.datasources, dataSourceBean)) {
                     res.datasources.push(dataSourceBean);
@@ -841,7 +865,7 @@ $generatorJava.metadataQueryFields = function (res, meta, fieldProperty)
{
 
         res.needEmptyLine = true;
 
-        res.line('typeMeta.' + $generatorJava.toJavaName('set', fieldProperty) + '(' + fieldProperty
+ ');');
+        res.line('typeMeta.' + $commonUtils.toJavaName('set', fieldProperty) + '(' + fieldProperty
+ ');');
 
         res.needEmptyLine = true;
     }
@@ -919,7 +943,7 @@ $generatorJava.metadataDatabaseFields = function (res, meta, fieldProperty)
{
                 + '));');
         });
 
-        res.line('typeMeta.' + $generatorJava.toJavaName('set', fieldProperty) + '(' + fieldProperty
+ ');');
+        res.line('typeMeta.' + $commonUtils.toJavaName('set', fieldProperty) + '(' + fieldProperty
+ ');');
 
         res.needEmptyLine = true;
     }
@@ -1046,7 +1070,7 @@ $generatorJava.clusterCaches = function (caches, res) {
         _.forEach(caches, function (cache) {
             res.emptyLineIfNeeded();
 
-            var cacheName = $generatorJava.toJavaName('cache', cache.name);
+            var cacheName = $commonUtils.toJavaName('cache', cache.name);
 
             $generatorJava.declareVariable(res, true, cacheName, 'org.apache.ignite.configuration.CacheConfiguration');
 
@@ -1125,8 +1149,6 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg)
{
         $generatorJava.clusterCaches(cluster.caches, res);
 
         if (javaClass) {
-            res.needEmptyLine = true;
-
             res.line('return cfg;');
             res.endBlock('}');
             res.endBlock('}');

http://git-wip-us.apache.org/repos/asf/ignite/blob/b44677c4/modules/control-center-web/src/main/js/routes/generator/generator-properties.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-properties.js
b/modules/control-center-web/src/main/js/routes/generator/generator-properties.js
index ef1be12..9c1f34b 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-properties.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-properties.js
@@ -58,7 +58,7 @@ $generatorProperties.dataSourcesProperties = function (cluster) {
     }
 
     if (datasources.length > 0)
-        return '# ' + mainComment() + '\n\n' + res.join('\n');
+        return '# ' + $generatorCommon.mainComment() + '\n\n' + res.join('\n');
 
     return undefined;
 };

http://git-wip-us.apache.org/repos/asf/ignite/blob/b44677c4/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 7d92f9f..f302458 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
@@ -59,6 +59,7 @@ $generatorXml.property = function (res, obj, propName, setterName, dflt)
{
         if ($commonUtils.isDefined(val)) {
             var hasDflt = $commonUtils.isDefined(dflt);
 
+            // Add to result if no default provided or value not equals to default.
             if (!hasDflt || (hasDflt && val != dflt)) {
                 $generatorXml.element(res, 'property', 'name', setterName ? setterName :
propName, 'value', $generatorXml.escape(val));
 
@@ -111,13 +112,11 @@ $generatorXml.beanProperty = function (res, bean, beanPropName, desc,
createBean
     var props = desc.fields;
 
     if (bean && $commonUtils.hasProperty(bean, props)) {
-        var tmpRes = $generatorCommon.builder();
+        res.startSafeBlock();
 
-        tmpRes.deep = res.deep;
-
-        tmpRes.emptyLineIfNeeded();
-        tmpRes.startBlock('<property name="' + beanPropName + '">');
-        tmpRes.startBlock('<bean class="' + desc.className + '">');
+        res.emptyLineIfNeeded();
+        res.startBlock('<property name="' + beanPropName + '">');
+        res.startBlock('<bean class="' + desc.className + '">');
 
         var hasData = false;
 
@@ -127,13 +126,13 @@ $generatorXml.beanProperty = function (res, bean, beanPropName, desc,
createBean
 
                 if (descr) {
                     if (descr.type == 'list') {
-                        $generatorXml.listProperty(tmpRes, bean, propName, descr.setterName);
+                        $generatorXml.listProperty(res, bean, propName, descr.setterName);
                     }
                     else if (descr.type == 'jdbcDialect') {
                         if (bean[propName]) {
-                            tmpRes.startBlock('<property name="' + propName + '">');
-                            tmpRes.line('<bean class="' + $generatorCommon.jdbcDialectClassName(bean[propName])
+ '"/>');
-                            tmpRes.endBlock('</property>');
+                            res.startBlock('<property name="' + propName + '">');
+                            res.line('<bean class="' + $generatorCommon.jdbcDialectClassName(bean[propName])
+ '"/>');
+                            res.endBlock('</property>');
 
                             hasData = true;
                         }
@@ -142,44 +141,41 @@ $generatorXml.beanProperty = function (res, bean, beanPropName, desc,
createBean
                         var val = bean[propName];
 
                         if (val && val.length > 0) {
-                            tmpRes.startBlock('<property name="' + propName + '">');
-                            tmpRes.startBlock('<props>');
+                            res.startBlock('<property name="' + propName + '">');
+                            res.startBlock('<props>');
 
                             for (var i = 0; i < val.length; i++) {
                                 var nameAndValue = val[i];
 
                                 var eqIndex = nameAndValue.indexOf('=');
                                 if (eqIndex >= 0) {
-                                    tmpRes.line('<prop key="' + $generatorXml.escape(nameAndValue.substring(0,
eqIndex)) + '">' +
+                                    res.line('<prop key="' + $generatorXml.escape(nameAndValue.substring(0,
eqIndex)) + '">' +
                                         $generatorXml.escape(nameAndValue.substr(eqIndex
+ 1)) + '</prop>');
                                 }
                             }
 
-                            tmpRes.endBlock('</props>');
-                            tmpRes.endBlock('</property>');
+                            res.endBlock('</props>');
+                            res.endBlock('</property>');
 
                             hasData = true;
                         }
                     }
                     else {
-                        if ($generatorXml.property(tmpRes, bean, propName, descr.setterName,
descr.dflt))
+                        if ($generatorXml.property(res, bean, propName, descr.setterName,
descr.dflt))
                             hasData = true;
                     }
                 }
                 else
-                    if ($generatorXml.property(tmpRes, bean, propName))
+                    if ($generatorXml.property(res, bean, propName))
                         hasData = true;
             }
         }
 
-        tmpRes.endBlock('</bean>');
-        tmpRes.endBlock('</property>');
-
-        if (hasData)
-            _.forEach(tmpRes, function (line) {
-                res.push(line);
-            });
+        res.endBlock('</bean>');
+        res.endBlock('</property>');
 
+        if (!hasData)
+            res.rollbackSafeBlock();
     }
     else if (createBeanAlthoughNoProps) {
         res.emptyLineIfNeeded();
@@ -321,9 +317,35 @@ $generatorXml.clusterAtomics = function (cluster, res) {
     if (!res)
         res = $generatorCommon.builder();
 
-    $generatorXml.beanProperty(res, cluster.atomicConfiguration, 'atomicConfiguration', $generatorCommon.ATOMIC_CONFIGURATION);
+    var atomics = cluster.atomicConfiguration;
 
-    res.needEmptyLine = true;
+    if ($commonUtils.hasAtLeastOneProperty(atomics, ['cacheMode', 'atomicSequenceReserveSize',
'backups'])) {
+        res.startSafeBlock();
+
+        res.emptyLineIfNeeded();
+
+        res.startBlock('<property name="atomicConfiguration">');
+        res.startBlock('<bean class="org.apache.ignite.configuration.AtomicConfiguration">');
+
+        var cacheMode = atomics.cacheMode ? atomics.cacheMode : 'PARTITIONED';
+
+        var hasData = cacheMode != 'PARTITIONED';
+
+        $generatorXml.property(res, atomics, 'cacheMode');
+
+        hasData = $generatorXml.property(res, atomics, 'atomicSequenceReserveSize') || hasData;
+
+        if (cacheMode == 'PARTITIONED')
+            hasData = $generatorXml.property(res, atomics, 'backups') || hasData;
+
+        res.endBlock('</bean>');
+        res.endBlock('</property>');
+
+        res.needEmptyLine = true;
+
+        if (!hasData)
+            res.rollbackSafeBlock();
+    }
 
     return res;
 };
@@ -337,7 +359,7 @@ $generatorXml.clusterCommunication = function (cluster, res) {
     $generatorXml.property(res, cluster, 'networkSendRetryDelay');
     $generatorXml.property(res, cluster, 'networkSendRetryCount');
     $generatorXml.property(res, cluster, 'segmentCheckFrequency');
-    $generatorXml.property(res, cluster, 'waitForSegmentOnStart');
+    $generatorXml.property(res, cluster, 'waitForSegmentOnStart', null, false);
     $generatorXml.property(res, cluster, 'discoveryStartupDelay');
 
     res.needEmptyLine = true;
@@ -410,7 +432,7 @@ $generatorXml.clusterMarshaller = function (cluster, res) {
         res.needEmptyLine = true;
     }
 
-    $generatorXml.property(res, cluster, 'marshalLocalJobs');
+    $generatorXml.property(res, cluster, 'marshalLocalJobs', null, false);
     $generatorXml.property(res, cluster, 'marshallerCacheKeepAliveTime');
     $generatorXml.property(res, cluster, 'marshallerCacheThreadPoolSize');
 
@@ -442,7 +464,7 @@ $generatorXml.clusterP2p = function (cluster, res) {
     var p2pEnabled = cluster.peerClassLoadingEnabled;
 
     if ($commonUtils.isDefined(p2pEnabled)) {
-        $generatorXml.property(res, cluster, 'peerClassLoadingEnabled');
+        $generatorXml.property(res, cluster, 'peerClassLoadingEnabled', null, false);
 
         if (p2pEnabled) {
             $generatorXml.property(res, cluster, 'peerClassLoadingMissedResourcesCacheSize');


Mime
View raw message