You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2015/07/07 12:32:37 UTC
[1/2] incubator-ignite git commit: # ignite-843 Route rename.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-843 047c41b02 -> 73d08d60d
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/utils/generatorJava.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/utils/generatorJava.js b/modules/web-control-center/nodejs/utils/generatorJava.js
deleted file mode 100644
index 2e32900..0000000
--- a/modules/web-control-center/nodejs/utils/generatorJava.js
+++ /dev/null
@@ -1,570 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var generatorUtils = require("./generatorUtils");
-
-exports.generateClusterConfiguration = function(cluster, generateJavaClass) {
- var res = generatorUtils.builder();
-
- if (generateJavaClass) {
- res.line('/**');
- res.line(' * ' + generatorUtils.mainComment());
- res.line(' */');
- res.startBlock('public class ConfigurationFactory {');
- res.line('/**');
- res.line(' * Configure grid.');
- res.line(' */');
- res.startBlock('public IgniteConfiguration createConfiguration() {');
- }
-
- res.importClass('org.apache.ignite.configuration.IgniteConfiguration');
-
- res.line('IgniteConfiguration cfg = new IgniteConfiguration();');
- res.line();
-
- if (cluster.discovery) {
- var d = cluster.discovery;
-
- res.importClass('org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi');
- res.line('TcpDiscoverySpi discovery = new TcpDiscoverySpi();');
- switch (d.kind) {
- case 'Multicast':
- addBeanWithProperties(res, d.Multicast, 'discovery', 'ipFinder', 'ipFinder',
- 'org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder', {
- multicastGroup: null,
- multicastPort: null,
- responseWaitTime: null,
- addressRequestAttempts: null,
- localAddress: null
- }, true);
-
- break;
-
- case 'Vm':
- addBeanWithProperties(res, d.Vm, 'discovery', 'ipFinder', 'ipFinder',
- 'org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder', {
- addresses: {type: 'list'}
- }, true);
-
- break;
-
- case 'S3':
- if (d.S3) {
- addBeanWithProperties(res, d.S3, 'discovery', 'ipFinder', 'ipFinder',
- 'org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder', {bucketName: null},
- true);
- }
- else {
- res.importClass('org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder');
-
- res.line('discovery.setIpFinder(new TcpDiscoveryS3IpFinder());');
- }
-
- break;
-
- case 'Cloud':
- addBeanWithProperties(res, d.Cloud, 'discovery', 'ipFinder', 'ipFinder',
- 'org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder', {
- credential: null,
- credentialPath: null,
- identity: null,
- provider: null,
- regions: {type: 'list'},
- zones: {type: 'list'}
- }, true);
-
- break;
-
- case 'GoogleStorage':
- addBeanWithProperties(res, d.GoogleStorage, 'discovery', 'ipFinder', 'ipFinder',
- 'org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder', {
- projectName: null,
- bucketName: null,
- serviceAccountP12FilePath: null
- }, true);
-
- //if (d.GoogleStorage.addrReqAttempts) todo ????
- // res.line('<property name="serviceAccountP12FilePath" value="' + escapeAttr(d.GoogleStorage.addrReqAttempts) + '"/>');
-
- break;
-
- case 'Jdbc':
- res.importClass('org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder');
-
- res.line();
- res.line('TcpDiscoveryJdbcIpFinder ipFinder = new TcpDiscoveryJdbcIpFinder();');
- res.line('ipFinder.setInitSchema(' + (d.Jdbc.initSchema != null || d.Jdbc.initSchema) + ');');
- res.line('discovery.setIpFinder(ipFinder);');
- res.needEmptyLine = true;
-
- break;
-
- case 'SharedFs':
- addBeanWithProperties(res, d.SharedFs, 'discovery', 'ipFinder', 'ipFinder',
- 'org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder', {path: null},
- true);
-
- break;
-
- default:
- throw "Unknown discovery kind: " + d.kind;
- }
-
- res.emptyLineIfNeeded();
-
- res.line('cfg.setDiscoverySpi(discovery);');
-
- 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.className, generatorUtils.atomicConfiguration.fields);
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'networkTimeout');
- addProperty(res, cluster, 'cfg', 'networkSendRetryDelay');
- addProperty(res, cluster, 'cfg', 'networkSendRetryCount');
- addProperty(res, cluster, 'cfg', 'segmentCheckFrequency');
- addProperty(res, cluster, 'cfg', 'waitForSegmentOnStart');
- addProperty(res, cluster, 'cfg', 'discoveryStartupDelay');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'deploymentMode', 'DeploymentMode');
-
- res.needEmptyLine = true;
-
- if (cluster.includeEventTypes && cluster.includeEventTypes.length > 0) {
- res.emptyLineIfNeeded();
-
- if (cluster.includeEventTypes.length == 1) {
- res.importClass('org.apache.ignite.events.EventType');
-
- res.line('cfg.setIncludeEventTypes(EventType.' + cluster.includeEventTypes[0] + ');');
- }
- else {
- res.append('int[] events = new int[EventType.' + cluster.includeEventTypes[0] + '.length');
-
- for (i = 1; i < cluster.includeEventTypes.length; i++) {
- res.line();
-
- res.append(' + EventType.' + cluster.includeEventTypes[i] + '.length');
- }
-
- res.line('];');
- res.line();
- res.line('int k = 0;');
-
- for (i = 0; i < cluster.includeEventTypes.length; i++) {
- res.line();
-
- var e = cluster.includeEventTypes[i];
-
- res.line('System.arraycopy(EventType.' + e + ', 0, events, k, EventType.' + e + '.length);');
- res.line('k += EventType.' + e + '.length;');
- }
-
- res.line();
- res.line('cfg.setIncludeEventTypes(events);');
- }
-
- res.needEmptyLine = true;
- }
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'marshalLocalJobs');
- addProperty(res, cluster, 'cfg', 'marshCacheKeepAliveTime');
- addProperty(res, cluster, 'cfg', 'marshCachePoolSize');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'metricsExpireTime');
- addProperty(res, cluster, 'cfg', 'metricsHistorySize');
- addProperty(res, cluster, 'cfg', 'metricsLogFrequency');
- addProperty(res, cluster, 'cfg', 'metricsUpdateFrequency');
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'peerClassLoadingEnabled');
- addMultiparamProperty(res, cluster, 'cfg', 'peerClassLoadingLocalClassPathExclude');
- addProperty(res, cluster, 'cfg', 'peerClassLoadingMissedResourcesCacheSize');
- addProperty(res, cluster, 'cfg', 'peerClassLoadingThreadPoolSize');
- res.needEmptyLine = true;
-
- if (cluster.swapSpaceSpi && cluster.swapSpaceSpi.kind == 'FileSwapSpaceSpi') {
- addBeanWithProperties(res, cluster.swapSpaceSpi.FileSwapSpaceSpi, 'cfg', 'swapSpaceSpi', 'swapSpi',
- generatorUtils.swapSpaceSpi.className, generatorUtils.swapSpaceSpi.fields, true);
-
- res.needEmptyLine = true;
- }
-
- addProperty(res, cluster, 'cfg', 'clockSyncSamples');
- addProperty(res, cluster, 'cfg', 'clockSyncFrequency');
- addProperty(res, cluster, 'cfg', 'timeServerPortBase');
- addProperty(res, cluster, 'cfg', 'timeServerPortRange');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'publicThreadPoolSize');
- addProperty(res, cluster, 'cfg', 'systemThreadPoolSize');
- addProperty(res, cluster, 'cfg', 'managementThreadPoolSize');
- addProperty(res, cluster, 'cfg', 'igfsThreadPoolSize');
-
- res.needEmptyLine = true;
-
- addBeanWithProperties(res, cluster.transactionConfiguration, 'cfg', 'transactionConfiguration',
- 'transactionConfiguration', generatorUtils.transactionConfiguration.className,
- generatorUtils.transactionConfiguration.fields);
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'cacheSanityCheckEnabled');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cfg', 'utilityCacheKeepAliveTime');
- addProperty(res, cluster, 'cfg', 'utilityCachePoolSize');
-
- if (generateJavaClass) {
- res.line();
- res.line('return cfg;');
- res.endBlock('}');
- res.endBlock('}');
-
- return res.generateImports() + '\n\n' + res.join('')
- }
-
- return res.join('');
-};
-
-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.className, e.fields, true);
- }
-}
-
-exports.generateCacheConfiguration = generateCacheConfiguration;
-
-function generateCacheConfiguration(cacheCfg, varName, res) {
- if (!res)
- res = generatorUtils.builder();
-
- res.emptyLineIfNeeded();
-
- res.importClass('org.apache.ignite.configuration.CacheConfiguration');
-
- res.line('CacheConfiguration ' + varName + ' = new CacheConfiguration();');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'name');
-
- addProperty(res, cacheCfg, varName, 'mode', 'CacheMode', 'cacheMode');
-
- addProperty(res, cacheCfg, varName, 'atomicityMode', 'CacheAtomicityMode');
- addProperty(res, cacheCfg, varName, 'backups');
- addProperty(res, cacheCfg, varName, 'startSize');
- addProperty(res, cacheCfg, varName, 'readFromBackup');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'memoryMode', 'CacheMemoryMode');
- addProperty(res, cacheCfg, varName, 'offHeapMaxMemory');
- addProperty(res, cacheCfg, varName, 'swapEnabled');
- addProperty(res, cacheCfg, varName, 'copyOnRead');
-
- res.needEmptyLine = true;
-
- createEvictionPolicy(res, cacheCfg.evictionPolicy, varName, 'evictionPolicy');
-
- if (cacheCfg.nearConfiguration && (cacheCfg.nearConfiguration.nearStartSize || cacheCfg.nearConfiguration.nearEvictionPolicy.kind)) {
- res.needEmptyLine = true;
-
- addBeanWithProperties(res, cacheCfg.nearConfiguration, varName, 'nearConfiguration', 'nearConfiguration',
- 'org.apache.ignite.configuration.NearCacheConfiguration',
- {nearStartSize: null, atomicSequenceReserveSize: null}, true);
-
- if (cacheCfg.nearConfiguration && cacheCfg.nearConfiguration.nearEvictionPolicy && cacheCfg.nearConfiguration.nearEvictionPolicy.kind) {
- createEvictionPolicy(res, cacheCfg.nearConfiguration.nearEvictionPolicy, 'nearConfiguration', 'nearEvictionPolicy');
- }
- }
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'sqlEscapeAll');
- addProperty(res, cacheCfg, varName, 'sqlOnheapRowCacheSize');
- addProperty(res, cacheCfg, varName, 'longQueryWarningTimeout');
-
- if (cacheCfg.indexedTypes && cacheCfg.indexedTypes.length > 0) {
- res.emptyLineIfNeeded();
-
- res.append(varName + '.setIndexedTypes(');
-
- for (var i = 0; i < cacheCfg.indexedTypes.length; i++) {
- if (i > 0)
- res.append(', ');
-
- var pair = cacheCfg.indexedTypes[i];
-
- res.append(toJavaCode(pair.keyClass, 'class')).append(', ').append(toJavaCode(pair.valueClass, 'class'))
- }
-
- res.line(');');
- }
-
- addMultiparamProperty(res, cacheCfg, varName, 'sqlFunctionClasses', 'class');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'rebalanceMode', 'CacheRebalanceMode');
- addProperty(res, cacheCfg, varName, 'rebalanceThreadPoolSize');
- addProperty(res, cacheCfg, varName, 'rebalanceBatchSize');
- addProperty(res, cacheCfg, varName, 'rebalanceOrder');
- addProperty(res, cacheCfg, varName, 'rebalanceDelay');
- addProperty(res, cacheCfg, varName, 'rebalanceTimeout');
- addProperty(res, cacheCfg, varName, 'rebalanceThrottle');
-
- res.needEmptyLine = true;
-
- if (cacheCfg.cacheStoreFactory && cacheCfg.cacheStoreFactory.kind) {
- var obj = cacheCfg.cacheStoreFactory[cacheCfg.cacheStoreFactory.kind];
- var data = generatorUtils.storeFactories[cacheCfg.cacheStoreFactory.kind];
-
- addBeanWithProperties(res, obj, varName, 'cacheStoreFactory', 'cacheStoreFactory', data.className,
- data.fields, true);
- }
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'loadPreviousValue');
- addProperty(res, cacheCfg, varName, 'readThrough');
- addProperty(res, cacheCfg, varName, 'writeThrough');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'invalidate');
- addProperty(res, cacheCfg, varName, 'defaultLockTimeout');
- addProperty(res, cacheCfg, varName, 'transactionManagerLookupClassName');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'writeBehindEnabled');
- addProperty(res, cacheCfg, varName, 'writeBehindBatchSize');
- addProperty(res, cacheCfg, varName, 'writeBehindFlushSize');
- addProperty(res, cacheCfg, varName, 'writeBehindFlushFrequency');
- addProperty(res, cacheCfg, varName, 'writeBehindFlushThreadCount');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'statisticsEnabled');
- addProperty(res, cacheCfg, varName, 'managementEnabled');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, varName, 'maxConcurrentAsyncOperations');
-
- return res;
-}
-
-function toJavaCode(val, type) {
- if (val == null)
- return 'null';
-
- if (type == 'float')
- return val + 'f';
-
- if (type == 'class')
- return val + '.class';
-
- if (type)
- return type + '.' + val;
-
- if (typeof(val) == 'string')
- return '"' + val.replace('"', '\\"') + '"';
-
- if (typeof(val) == 'number' || typeof(val) == 'boolean')
- return '' + val;
-
- throw "Unknown type: " + typeof(val) + ' (' + val + ')';
-}
-
-function addProperty(res, obj, objVariableName, propName, enumType, setterName) {
- var val = obj[propName];
-
- if (val) {
- res.emptyLineIfNeeded();
-
- res.line(objVariableName + '.' + getSetterName(setterName ? setterName : propName)
- + '(' + toJavaCode(val, enumType) + ');');
- }
-}
-
-function getSetterName(propName) {
- return 'set' + propName.charAt(0).toLocaleUpperCase() + propName.slice(1);
-}
-
-function addListProperty(res, obj, objVariableName, propName, enumType, setterName) {
- var val = obj[propName];
-
- if (val && val.length > 0) {
- res.append(objVariableName + '.' + getSetterName(setterName ? setterName : propName) + '(Arrays.asList(');
-
- for (var i = 0; i < val.length; i++) {
- if (i > 0)
- res.append(', ');
-
- res.append(toJavaCode(val[i], enumType));
- }
-
- res.line('));');
- }
-}
-
-function addMultiparamProperty(res, obj, objVariableName, propName, type, setterName) {
- var val = obj[propName];
-
- if (val && val.length > 0) {
- res.append(objVariableName + '.' + getSetterName(setterName ? setterName : propName) + '(');
-
- for (var i = 0; i < val.length; i++) {
- if (i > 0)
- res.append(', ');
-
- res.append(toJavaCode(val[i], type));
- }
-
- res.line(');');
- }
-}
-
-function addBeanWithProperties(res, bean, objVarName, beanPropName, beanVarName, beanClass, props, createBeanAlthoughNoProps) {
- if (!bean)
- return;
-
- if (generatorUtils.hasProperty(bean, props)) {
- if (!res.emptyLineIfNeeded()) {
- res.line();
- }
-
- res.line(beanClass + ' ' + beanVarName + ' = new ' + beanClass + '();');
- for (var propName in props) {
- if (props.hasOwnProperty(propName)) {
- var descr = props[propName];
-
- if (descr) {
- switch (descr.type) {
- case 'list':
- addListProperty(res, bean, beanVarName, propName, descr.elementsType, descr.setterName);
- break;
-
- case 'enum':
- addProperty(res, bean, beanVarName, propName, descr.enumClass, descr.setterName);
- break;
-
- case 'float':
- addProperty(res, bean, beanVarName, propName, 'float', descr.setterName);
- break;
-
- case 'propertiesAsList':
- var val = bean[propName];
-
- if (val && val.length > 0) {
- res.line('Properties ' + descr.propVarName + ' = new Properties();');
-
- for (var i = 0; i < val.length; i++) {
- var nameAndValue = val[i];
-
- var eqIndex = nameAndValue.indexOf('=');
- if (eqIndex >= 0) {
- res.line(descr.propVarName + '.setProperty('
- + nameAndValue.substring(0, eqIndex) + ', '
- + nameAndValue.substr(eqIndex + 1) + ');');
- }
-
- }
-
- res.line(beanVarName + '.' + getSetterName(propName) + '(' + descr.propVarName + ');');
- }
- break;
-
- case 'className':
- if (bean[propName]) {
- res.line(beanVarName + '.' + getSetterName(propName) + '(new ' + bean[propName] + '());');
- }
- break;
-
- default:
- addProperty(res, bean, beanVarName, propName, null, descr.setterName);
- }
- }
- else {
- addProperty(res, bean, beanVarName, propName);
- }
- }
- }
-
- res.line(objVarName + '.' + getSetterName(beanPropName) + '(' + beanVarName + ');');
-
- res.needEmptyLine = true;
- }
- else if (createBeanAlthoughNoProps) {
- res.emptyLineIfNeeded();
-
- res.line(objVarName + '.' + getSetterName(beanPropName) + '(new ' + beanClass + '());');
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/utils/generatorUtils.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/utils/generatorUtils.js b/modules/web-control-center/nodejs/utils/generatorUtils.js
deleted file mode 100644
index 2469c2e..0000000
--- a/modules/web-control-center/nodejs/utils/generatorUtils.js
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-exports.mainComment = function() {
- return 'This configuration was generated by Ignite Control Center ('
- + formatDate(new Date()) + ')';
-};
-
-function addLeadingZero(numberStr, minSize) {
- if (typeof (numberStr) != 'string')
- numberStr = '' + numberStr;
-
- while (numberStr.length < minSize) {
- numberStr = '0' + numberStr;
- }
-
- return numberStr;
-}
-
-exports.formatDate = formatDate;
-
-function formatDate(date) {
- var dd = addLeadingZero(date.getDate(), 2);
- var mm = addLeadingZero(date.getMonth() + 1, 2);
-
- var yyyy = date.getFullYear();
-
- return mm + '/' + dd + '/' + yyyy + ' ' + addLeadingZero(date.getHours(), 2) + ':' + addLeadingZero(date.getMinutes(), 2);
-}
-
-exports.builder = function () {
- var res = [];
-
- res.deep = 0;
- res.lineStart = true;
-
- res.append = function(s) {
- if (this.lineStart) {
- for (var i = 0; i < this.deep; i++)
- this.push(' ');
-
- this.lineStart = false;
- }
-
- this.push(s);
-
- return this;
- };
-
- res.line = function(s) {
- if (s)
- this.append(s);
-
- this.push('\n');
- this.lineStart = true;
-
- return this;
- };
-
- res.startBlock = function(s) {
- if (s)
- this.append(s);
-
- this.push('\n');
- this.lineStart = true;
- this.deep++;
-
- return this;
- };
-
- res.endBlock = function(s) {
- this.deep--;
-
- if (s)
- this.append(s);
-
- this.push('\n');
- this.lineStart = true;
-
- return this;
- };
-
- res.emptyLineIfNeeded = function() {
- if (this.needEmptyLine) {
- this.line();
-
- this.needEmptyLine = false;
-
- return true;
- }
-
- return false;
- };
-
- res.imports = {};
-
- res.importClass = function(fullClassName) {
- var dotIdx = fullClassName.lastIndexOf('.');
-
- var shortName;
-
- if (dotIdx > 0)
- shortName = fullClassName.substr(dotIdx + 1);
- else
- shortName = fullClassName;
-
- if (this.imports[shortName]) {
- if (this.imports[shortName] != fullClassName)
- throw "Class name conflict: " + this.imports[shortName] + ' and ' + fullClassName;
- }
- else {
- this.imports[shortName] = fullClassName;
- }
-
- return shortName;
- };
-
- res.generateImports = function() {
- var res = [];
-
- for (var clsName in this.imports) {
- if (this.imports.hasOwnProperty(clsName))
- res.push('import ' + this.imports[clsName] + ';');
- }
-
- return res.join('\n')
- };
-
- return res;
-};
-
-function ClassDescriptor(className, fields) {
- this.className = className;
-
- this.fields = fields;
-}
-
-exports.evictionPolicies = {
- 'LRU': new ClassDescriptor('org.apache.ignite.cache.eviction.lru.LruEvictionPolicy',
- {batchSize: null, maxMemorySize: null, maxSize: null}),
- 'RND': new ClassDescriptor('org.apache.ignite.cache.eviction.random.RandomEvictionPolicy', {maxSize: null}),
- 'FIFO': new ClassDescriptor('org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy',
- {batchSize: null, maxMemorySize: null, maxSize: null}),
- 'SORTED': new ClassDescriptor('org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy',
- {batchSize: null, maxMemorySize: null, maxSize: null})
-};
-
-exports.knownClasses = {
- OracleDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.OracleDialect', {}),
- BasicJdbcDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect', {}),
- DB2Dialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.DB2Dialect', {}),
- SQLServerDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect', {}),
- MySQLDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect', {}),
- H2Dialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.H2Dialect', {})
-};
-
-exports.storeFactories = {
- CacheJdbcPojoStoreFactory: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory', {
- dataSourceBean: null,
- dialect: {type: 'className'}
- }),
-
- CacheJdbcBlobStoreFactory: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactory', {
- user: null,
- dataSourceBean: null,
- initSchema: null,
- createTableQuery: null,
- loadQuery: null,
- insertQuery: null,
- updateQuery: null,
- deleteQuery: null
- }),
-
- CacheHibernateBlobStoreFactory: new ClassDescriptor('org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory', {
- hibernateProperties: {type: 'propertiesAsList', propVarName: 'props'}
- })
-};
-
-exports.atomicConfiguration = new ClassDescriptor('org.apache.ignite.configuration.AtomicConfiguration', {
- backups: null,
- cacheMode: {type: 'enum', enumClass: 'CacheMode'},
- atomicSequenceReserveSize: null
-});
-
-exports.swapSpaceSpi = new ClassDescriptor('org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi', {
- baseDirectory: null,
- readStripesNumber: null,
- maximumSparsity: {type: 'float'},
- maxWriteQueueSize: null,
- writeBufferSize: null
-});
-
-exports.transactionConfiguration = new ClassDescriptor('org.apache.ignite.configuration.TransactionConfiguration', {
- defaultTxConcurrency: {type: 'enum', enumClass: 'TransactionConcurrency'},
- transactionIsolation: {type: 'TransactionIsolation', setterName: 'defaultTxIsolation'},
- defaultTxTimeout: null,
- pessimisticTxLogLinger: null,
- pessimisticTxLogSize: null,
- txSerializableEnabled: null
-});
-
-exports.hasProperty = function(obj, props) {
- for (var propName in props) {
- if (props.hasOwnProperty(propName)) {
- if (obj[propName])
- return true;
- }
- }
-
- return false;
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/utils/generatorXml.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/utils/generatorXml.js b/modules/web-control-center/nodejs/utils/generatorXml.js
deleted file mode 100644
index e29d465..0000000
--- a/modules/web-control-center/nodejs/utils/generatorXml.js
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var generatorUtils = require("./generatorUtils");
-var dataStructures = require("../public/javascripts/dataStructures.js");
-
-exports.generateClusterConfiguration = function(cluster) {
- var res = generatorUtils.builder();
-
- res.push('' +
- '<?xml version="1.0" encoding="UTF-8"?>\n' +
- '\n' +
- '<!-- ' + generatorUtils.mainComment() + ' -->\n' +
- '<beans xmlns="http://www.springframework.org/schema/beans"\n' +
- ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n' +
- ' xmlns:util="http://www.springframework.org/schema/util"\n' +
- ' xsi:schemaLocation="http://www.springframework.org/schema/beans\n' +
- ' http://www.springframework.org/schema/beans/spring-beans.xsd\n' +
- ' http://www.springframework.org/schema/util\n' +
- ' http://www.springframework.org/schema/util/spring-util.xsd">\n' +
- ' <bean class="org.apache.ignite.configuration.IgniteConfiguration">\n');
-
- res.deep = 2;
-
- if (cluster.discovery) {
- res.startBlock('<property name="discoverySpi">');
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">');
- res.startBlock('<property name="ipFinder">');
-
- var d = cluster.discovery;
-
- switch (d.kind) {
- case 'Multicast':
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">');
-
- addProperty(res, d.Multicast, 'multicastGroup');
- addProperty(res, d.Multicast, 'multicastPort');
- addProperty(res, d.Multicast, 'responseWaitTime');
- addProperty(res, d.Multicast, 'addressRequestAttempts');
- addProperty(res, d.Multicast, 'localAddress');
-
- res.endBlock('</bean>');
-
- break;
-
- case 'Vm':
- if (d.Vm.addresses.length > 0) {
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">');
-
- addListProperty(res, d.Vm, 'addresses');
-
- res.endBlock('</bean>');
- }
- else {
- res.line('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"/>');
- }
-
- break;
-
- case 'S3':
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder">');
-
- if (d.S3 && d.S3.bucketName)
- res.line('<property name="bucketName" value="' + escapeAttr(d.S3.bucketName) + '" />');
-
- res.endBlock('</bean>');
-
- break;
-
- case 'Cloud':
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder">');
-
- addProperty(res, d.Cloud, 'credential');
- addProperty(res, d.Cloud, 'credentialPath');
- addProperty(res, d.Cloud, 'identity');
- addProperty(res, d.Cloud, 'provider');
- addListProperty(res, d.Cloud, 'regions');
- addListProperty(res, d.Cloud, 'zones');
-
- res.endBlock('</bean>');
-
- break;
-
- case 'GoogleStorage':
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder">');
-
- addProperty(res, d.GoogleStorage, 'projectName');
- addProperty(res, d.GoogleStorage, 'bucketName');
- addProperty(res, d.GoogleStorage, 'serviceAccountP12FilePath');
-
- //if (d.GoogleStorage.addrReqAttempts) todo ????
- // res.line('<property name="serviceAccountP12FilePath" value="' + escapeAttr(d.GoogleStorage.addrReqAttempts) + '"/>');
-
- res.endBlock('</bean>');
-
- break;
-
- case 'Jdbc':
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder">');
- res.line('<property name="initSchema" value="' + (d.Jdbc.initSchema != null || d.Jdbc.initSchema) + '"/>');
- res.endBlock('</bean>');
-
- break;
-
- case 'SharedFs':
- if (d.SharedFs.path) {
- res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder">');
- addProperty(res, d.SharedFs, 'path');
- res.endBlock('</bean>');
- }
- else {
- res.line('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder"/>');
- }
-
- break;
-
- default:
- throw "Unknown discovery kind: " + d.kind;
- }
-
- res.endBlock('</property>');
- res.endBlock('</bean>');
- res.endBlock('</property>');
-
- 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;
- }
-
- if (cluster.includeEventTypes && cluster.includeEventTypes.length > 0) {
- res.emptyLineIfNeeded();
-
- res.startBlock('<property name="includeEventTypes">');
-
- if (cluster.includeEventTypes.length == 1) {
- res.line('<util:constant static-field="org.apache.ignite.events.EventType.' + cluster.includeEventTypes[0] + '"/>')
- }
- else {
- res.startBlock('<array>');
-
- for (i = 0; i < cluster.includeEventTypes.length; i++) {
- if (i > 0)
- res.line();
-
- var eventGroup = cluster.includeEventTypes[i];
-
- res.line('<!-- EventType.' + eventGroup + ' -->');
-
- var eventList = dataStructures.eventGroups[eventGroup];
-
- for (var k = 0; k < eventList.length; k++) {
- res.line('<util:constant static-field="org.apache.ignite.events.EventType.' + eventList[k] + '"/>')
- }
- }
-
- res.endBlock('</array>');
- }
-
- res.endBlock('</property>');
-
- res.needEmptyLine = true;
- }
-
- addBeanWithProperties(res, cluster.atomicConfiguration, 'atomicConfiguration',
- generatorUtils.atomicConfiguration.className, generatorUtils.atomicConfiguration.fields);
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'networkTimeout');
- addProperty(res, cluster, 'networkSendRetryDelay');
- addProperty(res, cluster, 'networkSendRetryCount');
- addProperty(res, cluster, 'segmentCheckFrequency');
- addProperty(res, cluster, 'waitForSegmentOnStart');
- addProperty(res, cluster, 'discoveryStartupDelay');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'deploymentMode');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'marshalLocalJobs');
- addProperty(res, cluster, 'marshCacheKeepAliveTime');
- addProperty(res, cluster, 'marshCachePoolSize');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'metricsExpireTime');
- addProperty(res, cluster, 'metricsHistorySize');
- addProperty(res, cluster, 'metricsLogFrequency');
- addProperty(res, cluster, 'metricsUpdateFrequency');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'peerClassLoadingEnabled');
- addListProperty(res, cluster, 'peerClassLoadingLocalClassPathExclude');
- addProperty(res, cluster, 'peerClassLoadingMissedResourcesCacheSize');
- addProperty(res, cluster, 'peerClassLoadingThreadPoolSize');
-
- res.needEmptyLine = true;
-
- if (cluster.swapSpaceSpi && cluster.swapSpaceSpi.kind == 'FileSwapSpaceSpi') {
- addBeanWithProperties(res, cluster.swapSpaceSpi.FileSwapSpaceSpi, 'swapSpaceSpi',
- generatorUtils.swapSpaceSpi.className, generatorUtils.swapSpaceSpi.fields, true);
-
- res.needEmptyLine = true;
- }
-
- addProperty(res, cluster, 'clockSyncSamples');
- addProperty(res, cluster, 'clockSyncFrequency');
- addProperty(res, cluster, 'timeServerPortBase');
- addProperty(res, cluster, 'timeServerPortRange');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'publicThreadPoolSize');
- addProperty(res, cluster, 'systemThreadPoolSize');
- addProperty(res, cluster, 'managementThreadPoolSize');
- addProperty(res, cluster, 'igfsThreadPoolSize');
-
- res.needEmptyLine = true;
-
- addBeanWithProperties(res, cluster.transactionConfiguration, 'transactionConfiguration',
- generatorUtils.transactionConfiguration.className, generatorUtils.transactionConfiguration.fields);
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cacheSanityCheckEnabled');
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'utilityCacheKeepAliveTime');
- addProperty(res, cluster, 'utilityCachePoolSize');
-
- res.push(' </bean>\n');
- res.push('</beans>');
-
- return res.join('');
-};
-
-function createEvictionPolicy(res, evictionPolicy, propertyName) {
- if (evictionPolicy && evictionPolicy.kind) {
- var e = generatorUtils.evictionPolicies[evictionPolicy.kind];
-
- var obj = evictionPolicy[evictionPolicy.kind.toUpperCase()];
-
- addBeanWithProperties(res, obj, propertyName, e.className, e.fields, true);
- }
-}
-
-function generateCacheConfiguration(cacheCfg, res) {
- if (!res)
- res = generatorUtils.builder();
-
- res.startBlock('<bean class="org.apache.ignite.configuration.CacheConfiguration">');
-
- addProperty(res, cacheCfg, 'name');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'mode', 'cacheMode');
-
- addProperty(res, cacheCfg, 'atomicityMode');
- addProperty(res, cacheCfg, 'backups');
- addProperty(res, cacheCfg, 'startSize');
- addProperty(res, cacheCfg, 'readFromBackup');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'memoryMode');
- addProperty(res, cacheCfg, 'offHeapMaxMemory');
- addProperty(res, cacheCfg, 'swapEnabled');
- addProperty(res, cacheCfg, 'copyOnRead');
-
- res.needEmptyLine = true;
-
- createEvictionPolicy(res, cacheCfg.evictionPolicy, 'evictionPolicy');
-
- res.needEmptyLine = true;
-
- if (cacheCfg.nearCacheEnabled) {
- res.emptyLineIfNeeded();
-
- res.startBlock('<property name="nearConfiguration">');
- res.startBlock('<bean class="org.apache.ignite.configuration.NearCacheConfiguration">');
-
- if (cacheCfg.nearConfiguration && cacheCfg.nearConfiguration.nearStartSize)
- addProperty(res, cacheCfg.nearConfiguration, 'nearStartSize');
-
- if (cacheCfg.nearConfiguration && cacheCfg.nearConfiguration.nearEvictionPolicy.kind)
- createEvictionPolicy(res, cacheCfg.nearConfiguration.nearEvictionPolicy, 'nearEvictionPolicy');
-
- res.endBlock('</bean>');
- res.endBlock('</property>');
- }
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'sqlEscapeAll');
- addProperty(res, cacheCfg, 'sqlOnheapRowCacheSize');
- addProperty(res, cacheCfg, 'longQueryWarningTimeout');
-
- if (cacheCfg.indexedTypes && cacheCfg.indexedTypes.length > 0) {
- res.startBlock('<property name="indexedTypes">');
- res.startBlock('<array>');
-
- for (var i = 0; i < cacheCfg.indexedTypes.length; i++) {
- var pair = cacheCfg.indexedTypes[i];
-
- res.line('<value>' + escape(pair.keyClass) + '</value>');
- res.line('<value>' + escape(pair.valueClass) + '</value>');
- }
-
- res.endBlock('</array>');
- res.endBlock('</property>');
- }
-
- addListProperty(res, cacheCfg, 'sqlFunctionClasses', 'array');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'rebalanceMode');
- addProperty(res, cacheCfg, 'rebalanceThreadPoolSize');
- addProperty(res, cacheCfg, 'rebalanceBatchSize');
- addProperty(res, cacheCfg, 'rebalanceOrder');
- addProperty(res, cacheCfg, 'rebalanceDelay');
- addProperty(res, cacheCfg, 'rebalanceTimeout');
- addProperty(res, cacheCfg, 'rebalanceThrottle');
-
- res.needEmptyLine = true;
-
- if (cacheCfg.cacheStoreFactory && cacheCfg.cacheStoreFactory.kind) {
- var obj = cacheCfg.cacheStoreFactory[cacheCfg.cacheStoreFactory.kind];
- var data = generatorUtils.storeFactories[cacheCfg.cacheStoreFactory.kind];
-
- addBeanWithProperties(res, obj, 'cacheStoreFactory', data.className, data.fields, true);
- }
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'loadPreviousValue');
- addProperty(res, cacheCfg, 'readThrough');
- addProperty(res, cacheCfg, 'writeThrough');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'invalidate');
- addProperty(res, cacheCfg, 'defaultLockTimeout');
- addProperty(res, cacheCfg, 'transactionManagerLookupClassName');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'writeBehindEnabled');
- addProperty(res, cacheCfg, 'writeBehindBatchSize');
- addProperty(res, cacheCfg, 'writeBehindFlushSize');
- addProperty(res, cacheCfg, 'writeBehindFlushFrequency');
- addProperty(res, cacheCfg, 'writeBehindFlushThreadCount');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'statisticsEnabled');
- addProperty(res, cacheCfg, 'managementEnabled');
-
- res.needEmptyLine = true;
-
- addProperty(res, cacheCfg, 'maxConcurrentAsyncOperations');
-
- res.endBlock('</bean>');
-
- return res;
-}
-
-exports.generateCacheConfiguration = generateCacheConfiguration;
-
-function addProperty(res, obj, propName, setterName) {
- var val = obj[propName];
-
- if (val) {
- res.emptyLineIfNeeded();
-
- res.line('<property name="' + (setterName ? setterName : propName) + '" value="' + escapeAttr(val) + '"/>');
- }
-}
-
-function addBeanWithProperties(res, bean, beanPropName, beanClass, props, createBeanAlthoughNoProps) {
- if (!bean)
- return;
-
- if (generatorUtils.hasProperty(bean, props)) {
- res.emptyLineIfNeeded();
- res.startBlock('<property name="' + beanPropName + '">');
- res.startBlock('<bean class="' + beanClass + '">');
-
- for (var propName in props) {
- if (props.hasOwnProperty(propName)) {
- var descr = props[propName];
-
- if (descr) {
- if (descr.type == 'list') {
- addListProperty(res, bean, propName, descr.setterName);
- }
- else if (descr.type == 'className') {
- if (bean[propName]) {
- res.startBlock('<property name="' + propName + '">');
- res.line('<bean class="' + generatorUtils.knownClasses[bean[propName]].className + '"/>');
- res.endBlock('</property>');
- }
- }
- else if (descr.type == 'propertiesAsList') {
- var val = bean[propName];
-
- if (val && val.length > 0) {
- 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) {
- res.line('<prop key="' + escapeAttr(nameAndValue.substring(0, eqIndex)) + '">' +
- + escape(nameAndValue.substr(eqIndex + 1)) + '</prop>');
- }
- }
-
- res.endBlock('</props>');
- res.endBlock('</property>');
- }
- }
- else {
- addProperty(res, bean, propName, descr.setterName);
- }
- }
- else {
- addProperty(res, bean, propName);
- }
- }
- }
-
- res.endBlock('</bean>');
- res.endBlock('</property>');
- }
- else if (createBeanAlthoughNoProps) {
- res.emptyLineIfNeeded();
- res.line('<property name="' + beanPropName + '">');
- res.line(' <bean class="' + beanClass + '"/>');
- res.line('</property>');
- }
-}
-function addListProperty(res, obj, propName, listType, rowFactory) {
- var val = obj[propName];
-
- if (val && val.length > 0) {
- res.emptyLineIfNeeded();
-
- if (!listType)
- listType = 'list';
-
- if (!rowFactory)
- rowFactory = function(val) { return '<value>' + escape(val) + '</value>' };
-
- res.startBlock('<property name="' + propName + '">');
- res.startBlock('<' + listType + '>');
-
- for (var i = 0; i < val.length; i++)
- res.line(rowFactory(val[i]));
-
- res.endBlock('</' + listType + '>');
- res.endBlock('</property>');
- }
-}
-
-function escapeAttr(s) {
- if (typeof(s) != 'string')
- return s;
-
- return s.replace(/&/g, '&').replace(/"/g, '"');
-}
-
-function escape(s) {
- if (typeof(s) != 'string')
- return s;
-
- return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
-}
[2/2] incubator-ignite git commit: # ignite-843 Route rename.
Posted by an...@apache.org.
# ignite-843 Route rename.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/73d08d60
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/73d08d60
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/73d08d60
Branch: refs/heads/ignite-843
Commit: 73d08d60d2dccd75e57ad921416b4105511e93bb
Parents: 047c41b
Author: Andrey <an...@gridgain.com>
Authored: Tue Jul 7 17:30:39 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Jul 7 17:30:39 2015 +0700
----------------------------------------------------------------------
modules/web-control-center/nodejs/app.js | 27 +-
.../nodejs/generator/common.js | 225 ++++++++
.../web-control-center/nodejs/generator/java.js | 570 +++++++++++++++++++
.../web-control-center/nodejs/generator/xml.js | 516 +++++++++++++++++
.../public/javascripts/controllers/caches.js | 6 +-
.../public/javascripts/controllers/clusters.js | 6 +-
.../javascripts/controllers/persistences.js | 6 +-
.../public/javascripts/controllers/summary.js | 5 +-
.../web-control-center/nodejs/routes/auth.js | 81 ---
.../web-control-center/nodejs/routes/caches.js | 16 +-
.../nodejs/routes/clusters.js | 16 +-
.../nodejs/routes/configGenerator.js | 55 --
.../web-control-center/nodejs/routes/pages.js | 68 ---
.../nodejs/routes/persistences.js | 16 +-
.../web-control-center/nodejs/routes/public.js | 106 ++++
.../web-control-center/nodejs/routes/summary.js | 60 ++
.../nodejs/utils/generatorJava.js | 570 -------------------
.../nodejs/utils/generatorUtils.js | 225 --------
.../nodejs/utils/generatorXml.js | 516 -----------------
19 files changed, 1518 insertions(+), 1572 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/app.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/app.js b/modules/web-control-center/nodejs/app.js
index b3a58a6..b166917 100644
--- a/modules/web-control-center/nodejs/app.js
+++ b/modules/web-control-center/nodejs/app.js
@@ -25,12 +25,11 @@ var bodyParser = require('body-parser');
var session = require('express-session');
var mongoStore = require('connect-mongo')(session);
-var pageRoutes = require('./routes/pages');
+var publicRoutes = require('./routes/public');
var clustersRouter = require('./routes/clusters');
var cachesRouter = require('./routes/caches');
var persistencesRouter = require('./routes/persistences');
-var authRouter = require('./routes/auth');
-var configGenerator = require('./routes/configGenerator');
+var summary = require('./routes/summary');
var adminRouter = require('./routes/admin');
var passport = require('passport');
@@ -85,27 +84,19 @@ var mustAuthenticated = function (req, res, next) {
};
var adminOnly = function(req, res, next) {
- if (!req.isAuthenticated() || !req.user.admin)
- res.sendStatus(403);
- else
- next();
+ req.isAuthenticated() && req.user.admin ? next() : res.sendStatus(403);
};
-app.all('/configuration/clusters', mustAuthenticated);
-app.all('/configuration/caches', mustAuthenticated);
-app.all('/configuration/summary', mustAuthenticated);
-
app.all('/admin/*', mustAuthenticated, adminOnly);
+app.all('/configuration/*', mustAuthenticated);
-app.use('/', pageRoutes);
-app.use('/rest/clusters', clustersRouter);
-app.use('/rest/caches', cachesRouter);
-app.use('/rest/persistences', persistencesRouter);
-app.use('/rest/auth', authRouter);
-app.use('/rest/configGenerator', configGenerator);
-
+app.use('/', publicRoutes);
app.use('/admin', adminRouter);
+app.use('/configuration/clusters', clustersRouter);
+app.use('/configuration/caches', cachesRouter);
+app.use('/configuration/persistences', persistencesRouter);
+app.use('/configuration/summary', summary);
// Catch 404 and forward to error handler.
app.use(function (req, res, next) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/generator/common.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/generator/common.js b/modules/web-control-center/nodejs/generator/common.js
new file mode 100644
index 0000000..2469c2e
--- /dev/null
+++ b/modules/web-control-center/nodejs/generator/common.js
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+exports.mainComment = function() {
+ return 'This configuration was generated by Ignite Control Center ('
+ + formatDate(new Date()) + ')';
+};
+
+function addLeadingZero(numberStr, minSize) {
+ if (typeof (numberStr) != 'string')
+ numberStr = '' + numberStr;
+
+ while (numberStr.length < minSize) {
+ numberStr = '0' + numberStr;
+ }
+
+ return numberStr;
+}
+
+exports.formatDate = formatDate;
+
+function formatDate(date) {
+ var dd = addLeadingZero(date.getDate(), 2);
+ var mm = addLeadingZero(date.getMonth() + 1, 2);
+
+ var yyyy = date.getFullYear();
+
+ return mm + '/' + dd + '/' + yyyy + ' ' + addLeadingZero(date.getHours(), 2) + ':' + addLeadingZero(date.getMinutes(), 2);
+}
+
+exports.builder = function () {
+ var res = [];
+
+ res.deep = 0;
+ res.lineStart = true;
+
+ res.append = function(s) {
+ if (this.lineStart) {
+ for (var i = 0; i < this.deep; i++)
+ this.push(' ');
+
+ this.lineStart = false;
+ }
+
+ this.push(s);
+
+ return this;
+ };
+
+ res.line = function(s) {
+ if (s)
+ this.append(s);
+
+ this.push('\n');
+ this.lineStart = true;
+
+ return this;
+ };
+
+ res.startBlock = function(s) {
+ if (s)
+ this.append(s);
+
+ this.push('\n');
+ this.lineStart = true;
+ this.deep++;
+
+ return this;
+ };
+
+ res.endBlock = function(s) {
+ this.deep--;
+
+ if (s)
+ this.append(s);
+
+ this.push('\n');
+ this.lineStart = true;
+
+ return this;
+ };
+
+ res.emptyLineIfNeeded = function() {
+ if (this.needEmptyLine) {
+ this.line();
+
+ this.needEmptyLine = false;
+
+ return true;
+ }
+
+ return false;
+ };
+
+ res.imports = {};
+
+ res.importClass = function(fullClassName) {
+ var dotIdx = fullClassName.lastIndexOf('.');
+
+ var shortName;
+
+ if (dotIdx > 0)
+ shortName = fullClassName.substr(dotIdx + 1);
+ else
+ shortName = fullClassName;
+
+ if (this.imports[shortName]) {
+ if (this.imports[shortName] != fullClassName)
+ throw "Class name conflict: " + this.imports[shortName] + ' and ' + fullClassName;
+ }
+ else {
+ this.imports[shortName] = fullClassName;
+ }
+
+ return shortName;
+ };
+
+ res.generateImports = function() {
+ var res = [];
+
+ for (var clsName in this.imports) {
+ if (this.imports.hasOwnProperty(clsName))
+ res.push('import ' + this.imports[clsName] + ';');
+ }
+
+ return res.join('\n')
+ };
+
+ return res;
+};
+
+function ClassDescriptor(className, fields) {
+ this.className = className;
+
+ this.fields = fields;
+}
+
+exports.evictionPolicies = {
+ 'LRU': new ClassDescriptor('org.apache.ignite.cache.eviction.lru.LruEvictionPolicy',
+ {batchSize: null, maxMemorySize: null, maxSize: null}),
+ 'RND': new ClassDescriptor('org.apache.ignite.cache.eviction.random.RandomEvictionPolicy', {maxSize: null}),
+ 'FIFO': new ClassDescriptor('org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy',
+ {batchSize: null, maxMemorySize: null, maxSize: null}),
+ 'SORTED': new ClassDescriptor('org.apache.ignite.cache.eviction.sorted.SortedEvictionPolicy',
+ {batchSize: null, maxMemorySize: null, maxSize: null})
+};
+
+exports.knownClasses = {
+ OracleDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.OracleDialect', {}),
+ BasicJdbcDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.BasicJdbcDialect', {}),
+ DB2Dialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.DB2Dialect', {}),
+ SQLServerDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect', {}),
+ MySQLDialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect', {}),
+ H2Dialect: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.H2Dialect', {})
+};
+
+exports.storeFactories = {
+ CacheJdbcPojoStoreFactory: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory', {
+ dataSourceBean: null,
+ dialect: {type: 'className'}
+ }),
+
+ CacheJdbcBlobStoreFactory: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactory', {
+ user: null,
+ dataSourceBean: null,
+ initSchema: null,
+ createTableQuery: null,
+ loadQuery: null,
+ insertQuery: null,
+ updateQuery: null,
+ deleteQuery: null
+ }),
+
+ CacheHibernateBlobStoreFactory: new ClassDescriptor('org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory', {
+ hibernateProperties: {type: 'propertiesAsList', propVarName: 'props'}
+ })
+};
+
+exports.atomicConfiguration = new ClassDescriptor('org.apache.ignite.configuration.AtomicConfiguration', {
+ backups: null,
+ cacheMode: {type: 'enum', enumClass: 'CacheMode'},
+ atomicSequenceReserveSize: null
+});
+
+exports.swapSpaceSpi = new ClassDescriptor('org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi', {
+ baseDirectory: null,
+ readStripesNumber: null,
+ maximumSparsity: {type: 'float'},
+ maxWriteQueueSize: null,
+ writeBufferSize: null
+});
+
+exports.transactionConfiguration = new ClassDescriptor('org.apache.ignite.configuration.TransactionConfiguration', {
+ defaultTxConcurrency: {type: 'enum', enumClass: 'TransactionConcurrency'},
+ transactionIsolation: {type: 'TransactionIsolation', setterName: 'defaultTxIsolation'},
+ defaultTxTimeout: null,
+ pessimisticTxLogLinger: null,
+ pessimisticTxLogSize: null,
+ txSerializableEnabled: null
+});
+
+exports.hasProperty = function(obj, props) {
+ for (var propName in props) {
+ if (props.hasOwnProperty(propName)) {
+ if (obj[propName])
+ return true;
+ }
+ }
+
+ return false;
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/generator/java.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/generator/java.js b/modules/web-control-center/nodejs/generator/java.js
new file mode 100644
index 0000000..81357fa
--- /dev/null
+++ b/modules/web-control-center/nodejs/generator/java.js
@@ -0,0 +1,570 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var generatorUtils = require("./common");
+
+exports.generateClusterConfiguration = function(cluster, generateJavaClass) {
+ var res = generatorUtils.builder();
+
+ if (generateJavaClass) {
+ res.line('/**');
+ res.line(' * ' + generatorUtils.mainComment());
+ res.line(' */');
+ res.startBlock('public class ConfigurationFactory {');
+ res.line('/**');
+ res.line(' * Configure grid.');
+ res.line(' */');
+ res.startBlock('public IgniteConfiguration createConfiguration() {');
+ }
+
+ res.importClass('org.apache.ignite.configuration.IgniteConfiguration');
+
+ res.line('IgniteConfiguration cfg = new IgniteConfiguration();');
+ res.line();
+
+ if (cluster.discovery) {
+ var d = cluster.discovery;
+
+ res.importClass('org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi');
+ res.line('TcpDiscoverySpi discovery = new TcpDiscoverySpi();');
+ switch (d.kind) {
+ case 'Multicast':
+ addBeanWithProperties(res, d.Multicast, 'discovery', 'ipFinder', 'ipFinder',
+ 'org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder', {
+ multicastGroup: null,
+ multicastPort: null,
+ responseWaitTime: null,
+ addressRequestAttempts: null,
+ localAddress: null
+ }, true);
+
+ break;
+
+ case 'Vm':
+ addBeanWithProperties(res, d.Vm, 'discovery', 'ipFinder', 'ipFinder',
+ 'org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder', {
+ addresses: {type: 'list'}
+ }, true);
+
+ break;
+
+ case 'S3':
+ if (d.S3) {
+ addBeanWithProperties(res, d.S3, 'discovery', 'ipFinder', 'ipFinder',
+ 'org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder', {bucketName: null},
+ true);
+ }
+ else {
+ res.importClass('org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder');
+
+ res.line('discovery.setIpFinder(new TcpDiscoveryS3IpFinder());');
+ }
+
+ break;
+
+ case 'Cloud':
+ addBeanWithProperties(res, d.Cloud, 'discovery', 'ipFinder', 'ipFinder',
+ 'org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder', {
+ credential: null,
+ credentialPath: null,
+ identity: null,
+ provider: null,
+ regions: {type: 'list'},
+ zones: {type: 'list'}
+ }, true);
+
+ break;
+
+ case 'GoogleStorage':
+ addBeanWithProperties(res, d.GoogleStorage, 'discovery', 'ipFinder', 'ipFinder',
+ 'org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder', {
+ projectName: null,
+ bucketName: null,
+ serviceAccountP12FilePath: null
+ }, true);
+
+ //if (d.GoogleStorage.addrReqAttempts) todo ????
+ // res.line('<property name="serviceAccountP12FilePath" value="' + escapeAttr(d.GoogleStorage.addrReqAttempts) + '"/>');
+
+ break;
+
+ case 'Jdbc':
+ res.importClass('org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder');
+
+ res.line();
+ res.line('TcpDiscoveryJdbcIpFinder ipFinder = new TcpDiscoveryJdbcIpFinder();');
+ res.line('ipFinder.setInitSchema(' + (d.Jdbc.initSchema != null || d.Jdbc.initSchema) + ');');
+ res.line('discovery.setIpFinder(ipFinder);');
+ res.needEmptyLine = true;
+
+ break;
+
+ case 'SharedFs':
+ addBeanWithProperties(res, d.SharedFs, 'discovery', 'ipFinder', 'ipFinder',
+ 'org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder', {path: null},
+ true);
+
+ break;
+
+ default:
+ throw "Unknown discovery kind: " + d.kind;
+ }
+
+ res.emptyLineIfNeeded();
+
+ res.line('cfg.setDiscoverySpi(discovery);');
+
+ 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.className, generatorUtils.atomicConfiguration.fields);
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'networkTimeout');
+ addProperty(res, cluster, 'cfg', 'networkSendRetryDelay');
+ addProperty(res, cluster, 'cfg', 'networkSendRetryCount');
+ addProperty(res, cluster, 'cfg', 'segmentCheckFrequency');
+ addProperty(res, cluster, 'cfg', 'waitForSegmentOnStart');
+ addProperty(res, cluster, 'cfg', 'discoveryStartupDelay');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'deploymentMode', 'DeploymentMode');
+
+ res.needEmptyLine = true;
+
+ if (cluster.includeEventTypes && cluster.includeEventTypes.length > 0) {
+ res.emptyLineIfNeeded();
+
+ if (cluster.includeEventTypes.length == 1) {
+ res.importClass('org.apache.ignite.events.EventType');
+
+ res.line('cfg.setIncludeEventTypes(EventType.' + cluster.includeEventTypes[0] + ');');
+ }
+ else {
+ res.append('int[] events = new int[EventType.' + cluster.includeEventTypes[0] + '.length');
+
+ for (i = 1; i < cluster.includeEventTypes.length; i++) {
+ res.line();
+
+ res.append(' + EventType.' + cluster.includeEventTypes[i] + '.length');
+ }
+
+ res.line('];');
+ res.line();
+ res.line('int k = 0;');
+
+ for (i = 0; i < cluster.includeEventTypes.length; i++) {
+ res.line();
+
+ var e = cluster.includeEventTypes[i];
+
+ res.line('System.arraycopy(EventType.' + e + ', 0, events, k, EventType.' + e + '.length);');
+ res.line('k += EventType.' + e + '.length;');
+ }
+
+ res.line();
+ res.line('cfg.setIncludeEventTypes(events);');
+ }
+
+ res.needEmptyLine = true;
+ }
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'marshalLocalJobs');
+ addProperty(res, cluster, 'cfg', 'marshCacheKeepAliveTime');
+ addProperty(res, cluster, 'cfg', 'marshCachePoolSize');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'metricsExpireTime');
+ addProperty(res, cluster, 'cfg', 'metricsHistorySize');
+ addProperty(res, cluster, 'cfg', 'metricsLogFrequency');
+ addProperty(res, cluster, 'cfg', 'metricsUpdateFrequency');
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'peerClassLoadingEnabled');
+ addMultiparamProperty(res, cluster, 'cfg', 'peerClassLoadingLocalClassPathExclude');
+ addProperty(res, cluster, 'cfg', 'peerClassLoadingMissedResourcesCacheSize');
+ addProperty(res, cluster, 'cfg', 'peerClassLoadingThreadPoolSize');
+ res.needEmptyLine = true;
+
+ if (cluster.swapSpaceSpi && cluster.swapSpaceSpi.kind == 'FileSwapSpaceSpi') {
+ addBeanWithProperties(res, cluster.swapSpaceSpi.FileSwapSpaceSpi, 'cfg', 'swapSpaceSpi', 'swapSpi',
+ generatorUtils.swapSpaceSpi.className, generatorUtils.swapSpaceSpi.fields, true);
+
+ res.needEmptyLine = true;
+ }
+
+ addProperty(res, cluster, 'cfg', 'clockSyncSamples');
+ addProperty(res, cluster, 'cfg', 'clockSyncFrequency');
+ addProperty(res, cluster, 'cfg', 'timeServerPortBase');
+ addProperty(res, cluster, 'cfg', 'timeServerPortRange');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'publicThreadPoolSize');
+ addProperty(res, cluster, 'cfg', 'systemThreadPoolSize');
+ addProperty(res, cluster, 'cfg', 'managementThreadPoolSize');
+ addProperty(res, cluster, 'cfg', 'igfsThreadPoolSize');
+
+ res.needEmptyLine = true;
+
+ addBeanWithProperties(res, cluster.transactionConfiguration, 'cfg', 'transactionConfiguration',
+ 'transactionConfiguration', generatorUtils.transactionConfiguration.className,
+ generatorUtils.transactionConfiguration.fields);
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'cacheSanityCheckEnabled');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cfg', 'utilityCacheKeepAliveTime');
+ addProperty(res, cluster, 'cfg', 'utilityCachePoolSize');
+
+ if (generateJavaClass) {
+ res.line();
+ res.line('return cfg;');
+ res.endBlock('}');
+ res.endBlock('}');
+
+ return res.generateImports() + '\n\n' + res.join('')
+ }
+
+ return res.join('');
+};
+
+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.className, e.fields, true);
+ }
+}
+
+exports.generateCacheConfiguration = generateCacheConfiguration;
+
+function generateCacheConfiguration(cacheCfg, varName, res) {
+ if (!res)
+ res = generatorUtils.builder();
+
+ res.emptyLineIfNeeded();
+
+ res.importClass('org.apache.ignite.configuration.CacheConfiguration');
+
+ res.line('CacheConfiguration ' + varName + ' = new CacheConfiguration();');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'name');
+
+ addProperty(res, cacheCfg, varName, 'mode', 'CacheMode', 'cacheMode');
+
+ addProperty(res, cacheCfg, varName, 'atomicityMode', 'CacheAtomicityMode');
+ addProperty(res, cacheCfg, varName, 'backups');
+ addProperty(res, cacheCfg, varName, 'startSize');
+ addProperty(res, cacheCfg, varName, 'readFromBackup');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'memoryMode', 'CacheMemoryMode');
+ addProperty(res, cacheCfg, varName, 'offHeapMaxMemory');
+ addProperty(res, cacheCfg, varName, 'swapEnabled');
+ addProperty(res, cacheCfg, varName, 'copyOnRead');
+
+ res.needEmptyLine = true;
+
+ createEvictionPolicy(res, cacheCfg.evictionPolicy, varName, 'evictionPolicy');
+
+ if (cacheCfg.nearConfiguration && (cacheCfg.nearConfiguration.nearStartSize || cacheCfg.nearConfiguration.nearEvictionPolicy.kind)) {
+ res.needEmptyLine = true;
+
+ addBeanWithProperties(res, cacheCfg.nearConfiguration, varName, 'nearConfiguration', 'nearConfiguration',
+ 'org.apache.ignite.configuration.NearCacheConfiguration',
+ {nearStartSize: null, atomicSequenceReserveSize: null}, true);
+
+ if (cacheCfg.nearConfiguration && cacheCfg.nearConfiguration.nearEvictionPolicy && cacheCfg.nearConfiguration.nearEvictionPolicy.kind) {
+ createEvictionPolicy(res, cacheCfg.nearConfiguration.nearEvictionPolicy, 'nearConfiguration', 'nearEvictionPolicy');
+ }
+ }
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'sqlEscapeAll');
+ addProperty(res, cacheCfg, varName, 'sqlOnheapRowCacheSize');
+ addProperty(res, cacheCfg, varName, 'longQueryWarningTimeout');
+
+ if (cacheCfg.indexedTypes && cacheCfg.indexedTypes.length > 0) {
+ res.emptyLineIfNeeded();
+
+ res.append(varName + '.setIndexedTypes(');
+
+ for (var i = 0; i < cacheCfg.indexedTypes.length; i++) {
+ if (i > 0)
+ res.append(', ');
+
+ var pair = cacheCfg.indexedTypes[i];
+
+ res.append(toJavaCode(pair.keyClass, 'class')).append(', ').append(toJavaCode(pair.valueClass, 'class'))
+ }
+
+ res.line(');');
+ }
+
+ addMultiparamProperty(res, cacheCfg, varName, 'sqlFunctionClasses', 'class');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'rebalanceMode', 'CacheRebalanceMode');
+ addProperty(res, cacheCfg, varName, 'rebalanceThreadPoolSize');
+ addProperty(res, cacheCfg, varName, 'rebalanceBatchSize');
+ addProperty(res, cacheCfg, varName, 'rebalanceOrder');
+ addProperty(res, cacheCfg, varName, 'rebalanceDelay');
+ addProperty(res, cacheCfg, varName, 'rebalanceTimeout');
+ addProperty(res, cacheCfg, varName, 'rebalanceThrottle');
+
+ res.needEmptyLine = true;
+
+ if (cacheCfg.cacheStoreFactory && cacheCfg.cacheStoreFactory.kind) {
+ var obj = cacheCfg.cacheStoreFactory[cacheCfg.cacheStoreFactory.kind];
+ var data = generatorUtils.storeFactories[cacheCfg.cacheStoreFactory.kind];
+
+ addBeanWithProperties(res, obj, varName, 'cacheStoreFactory', 'cacheStoreFactory', data.className,
+ data.fields, true);
+ }
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'loadPreviousValue');
+ addProperty(res, cacheCfg, varName, 'readThrough');
+ addProperty(res, cacheCfg, varName, 'writeThrough');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'invalidate');
+ addProperty(res, cacheCfg, varName, 'defaultLockTimeout');
+ addProperty(res, cacheCfg, varName, 'transactionManagerLookupClassName');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'writeBehindEnabled');
+ addProperty(res, cacheCfg, varName, 'writeBehindBatchSize');
+ addProperty(res, cacheCfg, varName, 'writeBehindFlushSize');
+ addProperty(res, cacheCfg, varName, 'writeBehindFlushFrequency');
+ addProperty(res, cacheCfg, varName, 'writeBehindFlushThreadCount');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'statisticsEnabled');
+ addProperty(res, cacheCfg, varName, 'managementEnabled');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, varName, 'maxConcurrentAsyncOperations');
+
+ return res;
+}
+
+function toJavaCode(val, type) {
+ if (val == null)
+ return 'null';
+
+ if (type == 'float')
+ return val + 'f';
+
+ if (type == 'class')
+ return val + '.class';
+
+ if (type)
+ return type + '.' + val;
+
+ if (typeof(val) == 'string')
+ return '"' + val.replace('"', '\\"') + '"';
+
+ if (typeof(val) == 'number' || typeof(val) == 'boolean')
+ return '' + val;
+
+ throw "Unknown type: " + typeof(val) + ' (' + val + ')';
+}
+
+function addProperty(res, obj, objVariableName, propName, enumType, setterName) {
+ var val = obj[propName];
+
+ if (val) {
+ res.emptyLineIfNeeded();
+
+ res.line(objVariableName + '.' + getSetterName(setterName ? setterName : propName)
+ + '(' + toJavaCode(val, enumType) + ');');
+ }
+}
+
+function getSetterName(propName) {
+ return 'set' + propName.charAt(0).toLocaleUpperCase() + propName.slice(1);
+}
+
+function addListProperty(res, obj, objVariableName, propName, enumType, setterName) {
+ var val = obj[propName];
+
+ if (val && val.length > 0) {
+ res.append(objVariableName + '.' + getSetterName(setterName ? setterName : propName) + '(Arrays.asList(');
+
+ for (var i = 0; i < val.length; i++) {
+ if (i > 0)
+ res.append(', ');
+
+ res.append(toJavaCode(val[i], enumType));
+ }
+
+ res.line('));');
+ }
+}
+
+function addMultiparamProperty(res, obj, objVariableName, propName, type, setterName) {
+ var val = obj[propName];
+
+ if (val && val.length > 0) {
+ res.append(objVariableName + '.' + getSetterName(setterName ? setterName : propName) + '(');
+
+ for (var i = 0; i < val.length; i++) {
+ if (i > 0)
+ res.append(', ');
+
+ res.append(toJavaCode(val[i], type));
+ }
+
+ res.line(');');
+ }
+}
+
+function addBeanWithProperties(res, bean, objVarName, beanPropName, beanVarName, beanClass, props, createBeanAlthoughNoProps) {
+ if (!bean)
+ return;
+
+ if (generatorUtils.hasProperty(bean, props)) {
+ if (!res.emptyLineIfNeeded()) {
+ res.line();
+ }
+
+ res.line(beanClass + ' ' + beanVarName + ' = new ' + beanClass + '();');
+ for (var propName in props) {
+ if (props.hasOwnProperty(propName)) {
+ var descr = props[propName];
+
+ if (descr) {
+ switch (descr.type) {
+ case 'list':
+ addListProperty(res, bean, beanVarName, propName, descr.elementsType, descr.setterName);
+ break;
+
+ case 'enum':
+ addProperty(res, bean, beanVarName, propName, descr.enumClass, descr.setterName);
+ break;
+
+ case 'float':
+ addProperty(res, bean, beanVarName, propName, 'float', descr.setterName);
+ break;
+
+ case 'propertiesAsList':
+ var val = bean[propName];
+
+ if (val && val.length > 0) {
+ res.line('Properties ' + descr.propVarName + ' = new Properties();');
+
+ for (var i = 0; i < val.length; i++) {
+ var nameAndValue = val[i];
+
+ var eqIndex = nameAndValue.indexOf('=');
+ if (eqIndex >= 0) {
+ res.line(descr.propVarName + '.setProperty('
+ + nameAndValue.substring(0, eqIndex) + ', '
+ + nameAndValue.substr(eqIndex + 1) + ');');
+ }
+
+ }
+
+ res.line(beanVarName + '.' + getSetterName(propName) + '(' + descr.propVarName + ');');
+ }
+ break;
+
+ case 'className':
+ if (bean[propName]) {
+ res.line(beanVarName + '.' + getSetterName(propName) + '(new ' + bean[propName] + '());');
+ }
+ break;
+
+ default:
+ addProperty(res, bean, beanVarName, propName, null, descr.setterName);
+ }
+ }
+ else {
+ addProperty(res, bean, beanVarName, propName);
+ }
+ }
+ }
+
+ res.line(objVarName + '.' + getSetterName(beanPropName) + '(' + beanVarName + ');');
+
+ res.needEmptyLine = true;
+ }
+ else if (createBeanAlthoughNoProps) {
+ res.emptyLineIfNeeded();
+
+ res.line(objVarName + '.' + getSetterName(beanPropName) + '(new ' + beanClass + '());');
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/generator/xml.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/generator/xml.js b/modules/web-control-center/nodejs/generator/xml.js
new file mode 100644
index 0000000..0278cf3
--- /dev/null
+++ b/modules/web-control-center/nodejs/generator/xml.js
@@ -0,0 +1,516 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var generatorUtils = require("./common");
+var dataStructures = require("../public/javascripts/dataStructures.js");
+
+exports.generateClusterConfiguration = function(cluster) {
+ var res = generatorUtils.builder();
+
+ res.push('' +
+ '<?xml version="1.0" encoding="UTF-8"?>\n' +
+ '\n' +
+ '<!-- ' + generatorUtils.mainComment() + ' -->\n' +
+ '<beans xmlns="http://www.springframework.org/schema/beans"\n' +
+ ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n' +
+ ' xmlns:util="http://www.springframework.org/schema/util"\n' +
+ ' xsi:schemaLocation="http://www.springframework.org/schema/beans\n' +
+ ' http://www.springframework.org/schema/beans/spring-beans.xsd\n' +
+ ' http://www.springframework.org/schema/util\n' +
+ ' http://www.springframework.org/schema/util/spring-util.xsd">\n' +
+ ' <bean class="org.apache.ignite.configuration.IgniteConfiguration">\n');
+
+ res.deep = 2;
+
+ if (cluster.discovery) {
+ res.startBlock('<property name="discoverySpi">');
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">');
+ res.startBlock('<property name="ipFinder">');
+
+ var d = cluster.discovery;
+
+ switch (d.kind) {
+ case 'Multicast':
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">');
+
+ addProperty(res, d.Multicast, 'multicastGroup');
+ addProperty(res, d.Multicast, 'multicastPort');
+ addProperty(res, d.Multicast, 'responseWaitTime');
+ addProperty(res, d.Multicast, 'addressRequestAttempts');
+ addProperty(res, d.Multicast, 'localAddress');
+
+ res.endBlock('</bean>');
+
+ break;
+
+ case 'Vm':
+ if (d.Vm.addresses.length > 0) {
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">');
+
+ addListProperty(res, d.Vm, 'addresses');
+
+ res.endBlock('</bean>');
+ }
+ else {
+ res.line('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"/>');
+ }
+
+ break;
+
+ case 'S3':
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder">');
+
+ if (d.S3 && d.S3.bucketName)
+ res.line('<property name="bucketName" value="' + escapeAttr(d.S3.bucketName) + '" />');
+
+ res.endBlock('</bean>');
+
+ break;
+
+ case 'Cloud':
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder">');
+
+ addProperty(res, d.Cloud, 'credential');
+ addProperty(res, d.Cloud, 'credentialPath');
+ addProperty(res, d.Cloud, 'identity');
+ addProperty(res, d.Cloud, 'provider');
+ addListProperty(res, d.Cloud, 'regions');
+ addListProperty(res, d.Cloud, 'zones');
+
+ res.endBlock('</bean>');
+
+ break;
+
+ case 'GoogleStorage':
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder">');
+
+ addProperty(res, d.GoogleStorage, 'projectName');
+ addProperty(res, d.GoogleStorage, 'bucketName');
+ addProperty(res, d.GoogleStorage, 'serviceAccountP12FilePath');
+
+ //if (d.GoogleStorage.addrReqAttempts) todo ????
+ // res.line('<property name="serviceAccountP12FilePath" value="' + escapeAttr(d.GoogleStorage.addrReqAttempts) + '"/>');
+
+ res.endBlock('</bean>');
+
+ break;
+
+ case 'Jdbc':
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder">');
+ res.line('<property name="initSchema" value="' + (d.Jdbc.initSchema != null || d.Jdbc.initSchema) + '"/>');
+ res.endBlock('</bean>');
+
+ break;
+
+ case 'SharedFs':
+ if (d.SharedFs.path) {
+ res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder">');
+ addProperty(res, d.SharedFs, 'path');
+ res.endBlock('</bean>');
+ }
+ else {
+ res.line('<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder"/>');
+ }
+
+ break;
+
+ default:
+ throw "Unknown discovery kind: " + d.kind;
+ }
+
+ res.endBlock('</property>');
+ res.endBlock('</bean>');
+ res.endBlock('</property>');
+
+ 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;
+ }
+
+ if (cluster.includeEventTypes && cluster.includeEventTypes.length > 0) {
+ res.emptyLineIfNeeded();
+
+ res.startBlock('<property name="includeEventTypes">');
+
+ if (cluster.includeEventTypes.length == 1) {
+ res.line('<util:constant static-field="org.apache.ignite.events.EventType.' + cluster.includeEventTypes[0] + '"/>')
+ }
+ else {
+ res.startBlock('<array>');
+
+ for (i = 0; i < cluster.includeEventTypes.length; i++) {
+ if (i > 0)
+ res.line();
+
+ var eventGroup = cluster.includeEventTypes[i];
+
+ res.line('<!-- EventType.' + eventGroup + ' -->');
+
+ var eventList = dataStructures.eventGroups[eventGroup];
+
+ for (var k = 0; k < eventList.length; k++) {
+ res.line('<util:constant static-field="org.apache.ignite.events.EventType.' + eventList[k] + '"/>')
+ }
+ }
+
+ res.endBlock('</array>');
+ }
+
+ res.endBlock('</property>');
+
+ res.needEmptyLine = true;
+ }
+
+ addBeanWithProperties(res, cluster.atomicConfiguration, 'atomicConfiguration',
+ generatorUtils.atomicConfiguration.className, generatorUtils.atomicConfiguration.fields);
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'networkTimeout');
+ addProperty(res, cluster, 'networkSendRetryDelay');
+ addProperty(res, cluster, 'networkSendRetryCount');
+ addProperty(res, cluster, 'segmentCheckFrequency');
+ addProperty(res, cluster, 'waitForSegmentOnStart');
+ addProperty(res, cluster, 'discoveryStartupDelay');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'deploymentMode');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'marshalLocalJobs');
+ addProperty(res, cluster, 'marshCacheKeepAliveTime');
+ addProperty(res, cluster, 'marshCachePoolSize');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'metricsExpireTime');
+ addProperty(res, cluster, 'metricsHistorySize');
+ addProperty(res, cluster, 'metricsLogFrequency');
+ addProperty(res, cluster, 'metricsUpdateFrequency');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'peerClassLoadingEnabled');
+ addListProperty(res, cluster, 'peerClassLoadingLocalClassPathExclude');
+ addProperty(res, cluster, 'peerClassLoadingMissedResourcesCacheSize');
+ addProperty(res, cluster, 'peerClassLoadingThreadPoolSize');
+
+ res.needEmptyLine = true;
+
+ if (cluster.swapSpaceSpi && cluster.swapSpaceSpi.kind == 'FileSwapSpaceSpi') {
+ addBeanWithProperties(res, cluster.swapSpaceSpi.FileSwapSpaceSpi, 'swapSpaceSpi',
+ generatorUtils.swapSpaceSpi.className, generatorUtils.swapSpaceSpi.fields, true);
+
+ res.needEmptyLine = true;
+ }
+
+ addProperty(res, cluster, 'clockSyncSamples');
+ addProperty(res, cluster, 'clockSyncFrequency');
+ addProperty(res, cluster, 'timeServerPortBase');
+ addProperty(res, cluster, 'timeServerPortRange');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'publicThreadPoolSize');
+ addProperty(res, cluster, 'systemThreadPoolSize');
+ addProperty(res, cluster, 'managementThreadPoolSize');
+ addProperty(res, cluster, 'igfsThreadPoolSize');
+
+ res.needEmptyLine = true;
+
+ addBeanWithProperties(res, cluster.transactionConfiguration, 'transactionConfiguration',
+ generatorUtils.transactionConfiguration.className, generatorUtils.transactionConfiguration.fields);
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'cacheSanityCheckEnabled');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cluster, 'utilityCacheKeepAliveTime');
+ addProperty(res, cluster, 'utilityCachePoolSize');
+
+ res.push(' </bean>\n');
+ res.push('</beans>');
+
+ return res.join('');
+};
+
+function createEvictionPolicy(res, evictionPolicy, propertyName) {
+ if (evictionPolicy && evictionPolicy.kind) {
+ var e = generatorUtils.evictionPolicies[evictionPolicy.kind];
+
+ var obj = evictionPolicy[evictionPolicy.kind.toUpperCase()];
+
+ addBeanWithProperties(res, obj, propertyName, e.className, e.fields, true);
+ }
+}
+
+function generateCacheConfiguration(cacheCfg, res) {
+ if (!res)
+ res = generatorUtils.builder();
+
+ res.startBlock('<bean class="org.apache.ignite.configuration.CacheConfiguration">');
+
+ addProperty(res, cacheCfg, 'name');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'mode', 'cacheMode');
+
+ addProperty(res, cacheCfg, 'atomicityMode');
+ addProperty(res, cacheCfg, 'backups');
+ addProperty(res, cacheCfg, 'startSize');
+ addProperty(res, cacheCfg, 'readFromBackup');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'memoryMode');
+ addProperty(res, cacheCfg, 'offHeapMaxMemory');
+ addProperty(res, cacheCfg, 'swapEnabled');
+ addProperty(res, cacheCfg, 'copyOnRead');
+
+ res.needEmptyLine = true;
+
+ createEvictionPolicy(res, cacheCfg.evictionPolicy, 'evictionPolicy');
+
+ res.needEmptyLine = true;
+
+ if (cacheCfg.nearCacheEnabled) {
+ res.emptyLineIfNeeded();
+
+ res.startBlock('<property name="nearConfiguration">');
+ res.startBlock('<bean class="org.apache.ignite.configuration.NearCacheConfiguration">');
+
+ if (cacheCfg.nearConfiguration && cacheCfg.nearConfiguration.nearStartSize)
+ addProperty(res, cacheCfg.nearConfiguration, 'nearStartSize');
+
+ if (cacheCfg.nearConfiguration && cacheCfg.nearConfiguration.nearEvictionPolicy.kind)
+ createEvictionPolicy(res, cacheCfg.nearConfiguration.nearEvictionPolicy, 'nearEvictionPolicy');
+
+ res.endBlock('</bean>');
+ res.endBlock('</property>');
+ }
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'sqlEscapeAll');
+ addProperty(res, cacheCfg, 'sqlOnheapRowCacheSize');
+ addProperty(res, cacheCfg, 'longQueryWarningTimeout');
+
+ if (cacheCfg.indexedTypes && cacheCfg.indexedTypes.length > 0) {
+ res.startBlock('<property name="indexedTypes">');
+ res.startBlock('<array>');
+
+ for (var i = 0; i < cacheCfg.indexedTypes.length; i++) {
+ var pair = cacheCfg.indexedTypes[i];
+
+ res.line('<value>' + escape(pair.keyClass) + '</value>');
+ res.line('<value>' + escape(pair.valueClass) + '</value>');
+ }
+
+ res.endBlock('</array>');
+ res.endBlock('</property>');
+ }
+
+ addListProperty(res, cacheCfg, 'sqlFunctionClasses', 'array');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'rebalanceMode');
+ addProperty(res, cacheCfg, 'rebalanceThreadPoolSize');
+ addProperty(res, cacheCfg, 'rebalanceBatchSize');
+ addProperty(res, cacheCfg, 'rebalanceOrder');
+ addProperty(res, cacheCfg, 'rebalanceDelay');
+ addProperty(res, cacheCfg, 'rebalanceTimeout');
+ addProperty(res, cacheCfg, 'rebalanceThrottle');
+
+ res.needEmptyLine = true;
+
+ if (cacheCfg.cacheStoreFactory && cacheCfg.cacheStoreFactory.kind) {
+ var obj = cacheCfg.cacheStoreFactory[cacheCfg.cacheStoreFactory.kind];
+ var data = generatorUtils.storeFactories[cacheCfg.cacheStoreFactory.kind];
+
+ addBeanWithProperties(res, obj, 'cacheStoreFactory', data.className, data.fields, true);
+ }
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'loadPreviousValue');
+ addProperty(res, cacheCfg, 'readThrough');
+ addProperty(res, cacheCfg, 'writeThrough');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'invalidate');
+ addProperty(res, cacheCfg, 'defaultLockTimeout');
+ addProperty(res, cacheCfg, 'transactionManagerLookupClassName');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'writeBehindEnabled');
+ addProperty(res, cacheCfg, 'writeBehindBatchSize');
+ addProperty(res, cacheCfg, 'writeBehindFlushSize');
+ addProperty(res, cacheCfg, 'writeBehindFlushFrequency');
+ addProperty(res, cacheCfg, 'writeBehindFlushThreadCount');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'statisticsEnabled');
+ addProperty(res, cacheCfg, 'managementEnabled');
+
+ res.needEmptyLine = true;
+
+ addProperty(res, cacheCfg, 'maxConcurrentAsyncOperations');
+
+ res.endBlock('</bean>');
+
+ return res;
+}
+
+exports.generateCacheConfiguration = generateCacheConfiguration;
+
+function addProperty(res, obj, propName, setterName) {
+ var val = obj[propName];
+
+ if (val) {
+ res.emptyLineIfNeeded();
+
+ res.line('<property name="' + (setterName ? setterName : propName) + '" value="' + escapeAttr(val) + '"/>');
+ }
+}
+
+function addBeanWithProperties(res, bean, beanPropName, beanClass, props, createBeanAlthoughNoProps) {
+ if (!bean)
+ return;
+
+ if (generatorUtils.hasProperty(bean, props)) {
+ res.emptyLineIfNeeded();
+ res.startBlock('<property name="' + beanPropName + '">');
+ res.startBlock('<bean class="' + beanClass + '">');
+
+ for (var propName in props) {
+ if (props.hasOwnProperty(propName)) {
+ var descr = props[propName];
+
+ if (descr) {
+ if (descr.type == 'list') {
+ addListProperty(res, bean, propName, descr.setterName);
+ }
+ else if (descr.type == 'className') {
+ if (bean[propName]) {
+ res.startBlock('<property name="' + propName + '">');
+ res.line('<bean class="' + generatorUtils.knownClasses[bean[propName]].className + '"/>');
+ res.endBlock('</property>');
+ }
+ }
+ else if (descr.type == 'propertiesAsList') {
+ var val = bean[propName];
+
+ if (val && val.length > 0) {
+ 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) {
+ res.line('<prop key="' + escapeAttr(nameAndValue.substring(0, eqIndex)) + '">' +
+ + escape(nameAndValue.substr(eqIndex + 1)) + '</prop>');
+ }
+ }
+
+ res.endBlock('</props>');
+ res.endBlock('</property>');
+ }
+ }
+ else {
+ addProperty(res, bean, propName, descr.setterName);
+ }
+ }
+ else {
+ addProperty(res, bean, propName);
+ }
+ }
+ }
+
+ res.endBlock('</bean>');
+ res.endBlock('</property>');
+ }
+ else if (createBeanAlthoughNoProps) {
+ res.emptyLineIfNeeded();
+ res.line('<property name="' + beanPropName + '">');
+ res.line(' <bean class="' + beanClass + '"/>');
+ res.line('</property>');
+ }
+}
+function addListProperty(res, obj, propName, listType, rowFactory) {
+ var val = obj[propName];
+
+ if (val && val.length > 0) {
+ res.emptyLineIfNeeded();
+
+ if (!listType)
+ listType = 'list';
+
+ if (!rowFactory)
+ rowFactory = function(val) { return '<value>' + escape(val) + '</value>' };
+
+ res.startBlock('<property name="' + propName + '">');
+ res.startBlock('<' + listType + '>');
+
+ for (var i = 0; i < val.length; i++)
+ res.line(rowFactory(val[i]));
+
+ res.endBlock('</' + listType + '>');
+ res.endBlock('</property>');
+ }
+}
+
+function escapeAttr(s) {
+ if (typeof(s) != 'string')
+ return s;
+
+ return s.replace(/&/g, '&').replace(/"/g, '"');
+}
+
+function escape(s) {
+ if (typeof(s) != 'string')
+ return s;
+
+ return s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/public/javascripts/controllers/caches.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/public/javascripts/controllers/caches.js b/modules/web-control-center/nodejs/public/javascripts/controllers/caches.js
index a4229d9..73307c6 100644
--- a/modules/web-control-center/nodejs/public/javascripts/controllers/caches.js
+++ b/modules/web-control-center/nodejs/public/javascripts/controllers/caches.js
@@ -106,7 +106,7 @@ configuratorModule.controller('cachesController', ['$scope', '$alert', '$http',
$scope.caches = [];
// When landing on the page, get caches and show them.
- $http.get('/rest/caches')
+ $http.post('/configuration/caches/list')
.success(function (data) {
$scope.spaces = data.spaces;
$scope.caches = data.caches;
@@ -164,7 +164,7 @@ configuratorModule.controller('cachesController', ['$scope', '$alert', '$http',
return;
}
- $http.post('/rest/caches/save', item)
+ $http.post('/configuration/caches/save', item)
.success(function (_id) {
var idx = _.findIndex($scope.caches, function (cache) {
return cache._id == _id;
@@ -190,7 +190,7 @@ configuratorModule.controller('cachesController', ['$scope', '$alert', '$http',
$scope.removeItem = function () {
var _id = $scope.selectedItem._id;
- $http.post('/rest/caches/remove', {_id: _id})
+ $http.post('/configuration/caches/remove', {_id: _id})
.success(function () {
var i = _.findIndex($scope.caches, function (cache) {
return cache._id == _id;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/public/javascripts/controllers/clusters.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/public/javascripts/controllers/clusters.js b/modules/web-control-center/nodejs/public/javascripts/controllers/clusters.js
index 38fd6ef..95a30ba 100644
--- a/modules/web-control-center/nodejs/public/javascripts/controllers/clusters.js
+++ b/modules/web-control-center/nodejs/public/javascripts/controllers/clusters.js
@@ -100,7 +100,7 @@ configuratorModule.controller('clustersController', ['$scope', '$alert', '$http'
});
// When landing on the page, get clusters and show them.
- $http.get('/rest/clusters')
+ $http.post('/configuration/clusters/list')
.success(function (data) {
$scope.caches = data.caches;
$scope.spaces = data.spaces;
@@ -166,7 +166,7 @@ configuratorModule.controller('clustersController', ['$scope', '$alert', '$http'
}
}
- $http.post('/rest/clusters/save', item)
+ $http.post('/configuration/clusters/save', item)
.success(function (_id) {
var idx = _.findIndex($scope.clusters, function (cluster) {
return cluster._id == _id;
@@ -197,7 +197,7 @@ configuratorModule.controller('clustersController', ['$scope', '$alert', '$http'
$scope.removeItem = function () {
var _id = $scope.selectedItem._id;
- $http.post('/rest/clusters/remove', {_id: _id})
+ $http.post('/configuration/clusters/remove', {_id: _id})
.success(function () {
var i = _.findIndex($scope.clusters, function (cluster) {
return cluster._id == _id;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/public/javascripts/controllers/persistences.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/public/javascripts/controllers/persistences.js b/modules/web-control-center/nodejs/public/javascripts/controllers/persistences.js
index 803fc1b..ab26dea 100644
--- a/modules/web-control-center/nodejs/public/javascripts/controllers/persistences.js
+++ b/modules/web-control-center/nodejs/public/javascripts/controllers/persistences.js
@@ -42,7 +42,7 @@ configuratorModule.controller('persistenceController', ['$scope', '$alert', '$ht
$scope.persistences = [];
// When landing on the page, get persistences and show them.
- $http.get('/rest/persistences')
+ $http.post('/configuration/persistences/list')
.success(function (data) {
$scope.spaces = data.spaces;
$scope.persistences = data.persistences;
@@ -87,7 +87,7 @@ configuratorModule.controller('persistenceController', ['$scope', '$alert', '$ht
$scope.saveItem = function () {
var item = $scope.backupItem;
- $http.post('/rest/persistences/save', item)
+ $http.post('/configuration/persistences/save', item)
.success(function (_id) {
var i = _.findIndex($scope.persistences, function (persistence) {
return persistence._id == _id;
@@ -111,7 +111,7 @@ configuratorModule.controller('persistenceController', ['$scope', '$alert', '$ht
$scope.removeItem = function () {
var _id = $scope.selectedItem._id;
- $http.post('/rest/persistences/remove', {_id: _id})
+ $http.post('/configuration/persistences/remove', {_id: _id})
.success(function () {
var i = _.findIndex($scope.persistences, function (persistence) {
return persistence._id == _id;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js b/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
index 52573af..6a78677 100644
--- a/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
+++ b/modules/web-control-center/nodejs/public/javascripts/controllers/summary.js
@@ -27,7 +27,7 @@ configuratorModule.controller('summaryController', ['$scope', '$http', function
$scope.xmlData = undefined;
$scope.dockerData = undefined;
- $http.get('/rest/clusters').success(function (data) {
+ $http.post('/configuration/clusters/list').success(function (data) {
$scope.caches = data.caches;
$scope.spaces = data.spaces;
$scope.clusters = data.clusters;
@@ -55,8 +55,7 @@ configuratorModule.controller('summaryController', ['$scope', '$http', function
$scope.loading = true;
- $http.get('/rest/configGenerator', {params:
- {_id: cluster._id, lang: lang, generateJavaClass: $scope.generateJavaClass}})
+ $http.post('/configuration/summary/generator', {_id: cluster._id, lang: lang, generateJavaClass: $scope.generateJavaClass})
.success(
function (data) {
if (lang == 'java') {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/auth.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/auth.js b/modules/web-control-center/nodejs/routes/auth.js
deleted file mode 100644
index a0ec132..0000000
--- a/modules/web-control-center/nodejs/routes/auth.js
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var passport = require('passport');
-var router = require('express').Router();
-
-var db = require('../db');
-
-/**
- * Register new account.
- */
-router.post('/register', function(req, res, next) {
- db.Account.count(function (err, cnt) {
- if (err)
- return res.status(401).send(err.message);
-
- req.body.admin = cnt == 0;
-
- db.Account.register(new db.Account(req.body), req.body.password, function(err, account) {
- if (err)
- return res.status(401).send(err.message);
-
- if (!account)
- return res.status(500).send('Failed to create account.');
-
- new db.Space({name: 'Personal space', owner: account._id}).save();
-
- req.logIn(account, {}, function(err) {
- if (err)
- return res.status(401).send(err.message);
-
- return res.redirect('/configuration/clusters');
- });
- });
- });
-});
-
-/**
- * Login in exist account.
- */
-router.post('/login', function(req, res, next) {
- passport.authenticate('local', function(err, user) {
- if (err)
- return res.status(401).send(err.message);
-
- if (!user)
- return res.status(401).send('Invalid email or password');
-
- req.logIn(user, {}, function(err) {
- if (err)
- return res.status(401).send(err.message);
-
- res.redirect('/configuration/clusters');
- });
- })(req, res, next);
-});
-
-/**
- * Logout.
- */
-router.get('/logout', function(req, res) {
- req.logout();
-
- res.redirect('/');
-});
-
-module.exports = router;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/caches.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/caches.js b/modules/web-control-center/nodejs/routes/caches.js
index 7de5d57..4144517 100644
--- a/modules/web-control-center/nodejs/routes/caches.js
+++ b/modules/web-control-center/nodejs/routes/caches.js
@@ -18,13 +18,18 @@
var router = require('express').Router();
var db = require('../db');
+/* GET caches page. */
+router.get('/', function(req, res) {
+ res.render('caches', { user: req.user });
+});
+
/**
- * Send spaces and caches accessed for user account.
+ * Get spaces and caches accessed for user account.
*
* @param req Request.
* @param res Response.
*/
-function selectAll(req, res) {
+router.post('/list', function(req, res) {
var user_id = req.user._id;
// Get owned space and all accessed space.
@@ -44,13 +49,6 @@ function selectAll(req, res) {
res.json({spaces: spaces, caches: caches});
});
});
-}
-
-/**
- * Get spaces and caches accessed for user account.
- */
-router.get('/', function(req, res) {
- selectAll(req, res);
});
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/clusters.js b/modules/web-control-center/nodejs/routes/clusters.js
index 91ac50a..24e64c8 100644
--- a/modules/web-control-center/nodejs/routes/clusters.js
+++ b/modules/web-control-center/nodejs/routes/clusters.js
@@ -18,13 +18,18 @@
var router = require('express').Router();
var db = require('../db');
+/* GET clusters page. */
+router.get('/', function(req, res) {
+ res.render('clusters', { user: req.user });
+});
+
/**
- * Send spaces and clusters accessed for user account.
+ * Get spaces and clusters accessed for user account.
*
* @param req Request.
* @param res Response.
*/
-function selectAll(req, res) {
+router.post('/list', function(req, res) {
var user_id = req.user._id;
// Get owned space and all accessed space.
@@ -53,13 +58,6 @@ function selectAll(req, res) {
});
});
});
-}
-
-/**
- * Get spaces and clusters accessed for user account.
- */
-router.get('/', function(req, res) {
- selectAll(req, res);
});
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/configGenerator.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/configGenerator.js b/modules/web-control-center/nodejs/routes/configGenerator.js
deleted file mode 100644
index f43817a..0000000
--- a/modules/web-control-center/nodejs/routes/configGenerator.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var db = require('../db');
-
-var router = require('express').Router();
-
-var generatorXml = require('./../utils/generatorXml');
-var generatorJava = require('./../utils/generatorJava');
-
-router.get('/', function(req, res) {
- var lang = req.query.lang;
-
- // Get cluster.
- db.Cluster.findById(req.query._id).populate('caches').exec(function (err, cluster) {
- if (err)
- return res.status(500).send(err.message);
-
- if (!cluster) {
- res.sendStatus(404);
-
- return
- }
-
- switch (lang) {
- case 'xml':
- res.send(generatorXml.generateClusterConfiguration(cluster));
- break;
-
- case 'java':
- res.send(generatorJava.generateClusterConfiguration(cluster, req.query.generateJavaClass === 'true'));
- break;
-
- default:
- res.status(404).send("Unknown language: " + lang);
- break;
- }
- });
-});
-
-module.exports = router;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/pages.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/pages.js b/modules/web-control-center/nodejs/routes/pages.js
deleted file mode 100644
index a8cde5a..0000000
--- a/modules/web-control-center/nodejs/routes/pages.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-var router = require('express').Router();
-
-// GET dropdown-menu template.
-router.get('/select', function(req, res) {
- res.render('templates/select', { });
-});
-
-/* GET login page. */
-router.get('/login', function(req, res) {
- res.render('login');
-});
-
-/* GET home page. */
-router.get('/', function(req, res) {
- if (req.isAuthenticated())
- res.redirect('/configuration/clusters');
- else
- res.render('index', { user: req.user });
-});
-
-/* GET clusters page. */
-router.get('/configuration/clusters', function(req, res) {
- res.render('clusters', { user: req.user });
-});
-
-/* GET caches page. */
-router.get('/configuration/caches', function(req, res) {
- res.render('caches', { user: req.user });
-});
-
-/* GET persistence page. */
-router.get('/configuration/persistence', function(req, res) {
- res.render('persistence', { user: req.user });
-});
-
-/* GET sql page. */
-router.get('/sql', function(req, res) {
- res.render('sql', { user: req.user });
-});
-
-/* GET clients page. */
-router.get('/clients', function(req, res) {
- res.render('clients', { user: req.user });
-});
-
-/* GET summary page. */
-router.get('/configuration/summary', function(req, res) {
- res.render('summary', { user: req.user });
-});
-
-module.exports = router;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/persistences.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/persistences.js b/modules/web-control-center/nodejs/routes/persistences.js
index 409ff5f..2b784bb 100644
--- a/modules/web-control-center/nodejs/routes/persistences.js
+++ b/modules/web-control-center/nodejs/routes/persistences.js
@@ -19,13 +19,18 @@ var router = require('express').Router();
var db = require('../db');
var ds = require('../public/javascripts/dataStructures.js'), jdbcTypes = ds.jdbcTypes, javaTypes = ds.javaTypes;
+/* GET persistence page. */
+router.get('/', function(req, res) {
+ res.render('persistence', { user: req.user });
+});
+
/**
- * Send spaces and persistences accessed for user account.
+ * Get spaces and persistences accessed for user account.
*
* @param req Request.
* @param res Response.
*/
-function selectAll(req, res) {
+router.post('/list', function(req, res) {
var user_id = req.user._id;
// Get owned space and all accessed space.
@@ -45,13 +50,6 @@ function selectAll(req, res) {
res.json({spaces: spaces, persistences: persistences});
});
});
-}
-
-/**
- * Get spaces and persistences accessed for user account.
- */
-router.get('/', function(req, res) {
- selectAll(req, res);
});
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/public.js b/modules/web-control-center/nodejs/routes/public.js
new file mode 100644
index 0000000..1edf1fc
--- /dev/null
+++ b/modules/web-control-center/nodejs/routes/public.js
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var router = require('express').Router();
+
+// GET dropdown-menu template.
+router.get('/select', function(req, res) {
+ res.render('templates/select', { });
+});
+
+/* GET login page. */
+router.get('/login', function(req, res) {
+ res.render('login');
+});
+
+/**
+ * Register new account.
+ */
+router.post('/register', function(req, res, next) {
+ db.Account.count(function (err, cnt) {
+ if (err)
+ return res.status(401).send(err.message);
+
+ req.body.admin = cnt == 0;
+
+ db.Account.register(new db.Account(req.body), req.body.password, function(err, account) {
+ if (err)
+ return res.status(401).send(err.message);
+
+ if (!account)
+ return res.status(500).send('Failed to create account.');
+
+ new db.Space({name: 'Personal space', owner: account._id}).save();
+
+ req.logIn(account, {}, function(err) {
+ if (err)
+ return res.status(401).send(err.message);
+
+ return res.redirect('/configuration/clusters');
+ });
+ });
+ });
+});
+
+/**
+ * Login in exist account.
+ */
+router.post('/login', function(req, res, next) {
+ passport.authenticate('local', function(err, user) {
+ if (err)
+ return res.status(401).send(err.message);
+
+ if (!user)
+ return res.status(401).send('Invalid email or password');
+
+ req.logIn(user, {}, function(err) {
+ if (err)
+ return res.status(401).send(err.message);
+
+ res.redirect('/configuration/clusters');
+ });
+ })(req, res, next);
+});
+
+/**
+ * Logout.
+ */
+router.get('/logout', function(req, res) {
+ req.logout();
+
+ res.redirect('/');
+});
+
+/* GET home page. */
+router.get('/', function(req, res) {
+ if (req.isAuthenticated())
+ res.redirect('/configuration/clusters');
+ else
+ res.render('index', { user: req.user });
+});
+
+///* GET sql page. */
+//router.get('/sql', function(req, res) {
+// res.render('sql', { user: req.user });
+//});
+//
+///* GET clients page. */
+//router.get('/clients', function(req, res) {
+// res.render('clients', { user: req.user });
+//});
+
+module.exports = router;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/73d08d60/modules/web-control-center/nodejs/routes/summary.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/summary.js b/modules/web-control-center/nodejs/routes/summary.js
new file mode 100644
index 0000000..ee87dbb
--- /dev/null
+++ b/modules/web-control-center/nodejs/routes/summary.js
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var db = require('../db');
+
+var router = require('express').Router();
+
+var generatorXml = require('./../generator/xml');
+var generatorJava = require('./../generator/java');
+
+/* GET summary page. */
+router.get('/', function(req, res) {
+ res.render('summary', { user: req.user });
+});
+
+router.post('/generator', function(req, res) {
+ var lang = req.body.lang;
+
+ // Get cluster.
+ db.Cluster.findById(req.body._id).populate('caches').exec(function (err, cluster) {
+ if (err)
+ return res.status(500).send(err.message);
+
+ if (!cluster) {
+ res.sendStatus(404);
+
+ return
+ }
+
+ switch (lang) {
+ case 'xml':
+ res.send(generatorXml.generateClusterConfiguration(cluster));
+ break;
+
+ case 'java':
+ res.send(generatorJava.generateClusterConfiguration(cluster, req.body.generateJavaClass));
+ break;
+
+ default:
+ res.status(404).send("Unknown language: " + lang);
+ break;
+ }
+ });
+});
+
+module.exports = router;
\ No newline at end of file