You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/07/08 19:26:36 UTC
[1/2] incubator-ignite git commit: IGNITE-843: WIP on generation of
datasources in XML.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-843 6da888c57 -> e45c00f4f
IGNITE-843: WIP on generation of datasources in XML.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/72b826ec
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/72b826ec
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/72b826ec
Branch: refs/heads/ignite-843
Commit: 72b826ecab774a7377683ecd05fb1224cfeada4c
Parents: cbc7527
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Jul 9 00:26:25 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Jul 9 00:26:25 2015 +0700
----------------------------------------------------------------------
.../nodejs/generator/common.js | 18 +-
.../web-control-center/nodejs/generator/java.js | 8 +
.../web-control-center/nodejs/generator/xml.js | 191 ++++++++++---------
3 files changed, 121 insertions(+), 96 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/72b826ec/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
index 8d11fdc..ed44282 100644
--- a/modules/web-control-center/nodejs/generator/common.js
+++ b/modules/web-control-center/nodejs/generator/common.js
@@ -169,12 +169,12 @@ exports.knownClasses = {
};
exports.dataSources = {
- Oracle: {className: 'oracle.jdbc.pool.OracleDataSource'},
- DB2: {className: 'com.ibm.db2.jcc.DB2ConnectionPoolDataSource'},
- SQLServer: {className: 'com.microsoft.sqlserver.jdbc.SQLServerDataSource'},
- MySQL: {className: 'com.mysql.jdbc.jdbc2.optional.MysqlDataSource'},
- PostgreSQL: {className: 'org.postgresql.ds.PGPoolingDataSource'},
- H2: {className: 'org.h2.jdbcx.JdbcDataSource'}
+ Oracle: 'oracle.jdbc.pool.OracleDataSource',
+ DB2: 'com.ibm.db2.jcc.DB2ConnectionPoolDataSource',
+ SQLServer: 'com.microsoft.sqlserver.jdbc.SQLServerDataSource',
+ MySQL: 'com.mysql.jdbc.jdbc2.optional.MysqlDataSource',
+ PostgreSQL: 'org.postgresql.ds.PGPoolingDataSource',
+ H2: 'org.h2.jdbcx.JdbcDataSource'
};
exports.storeFactories = {
@@ -233,6 +233,12 @@ exports.hasProperty = function(obj, props) {
return false;
};
+/**
+ * Convert some name to valid java name.
+ *
+ * @param name to convert.
+ * @returns {string} Valid java name.
+ */
exports.toJavaName = function(name) {
var javaName = name.replace(/[^A-Za-z_0-9]+/, '_');
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/72b826ec/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
index 36332a1..037df10 100644
--- a/modules/web-control-center/nodejs/generator/java.js
+++ b/modules/web-control-center/nodejs/generator/java.js
@@ -304,6 +304,14 @@ function createEvictionPolicy(res, evictionPolicy, varName, propertyName) {
exports.generateCacheConfiguration = generateCacheConfiguration;
+/**
+ * Generate java code for cache configuration.
+ *
+ * @param cacheCfg Cache config.
+ * @param varName Variable name.
+ * @param res Result builder.
+ * @returns {*} Append generated java code to builder and return it.
+ */
function generateCacheConfiguration(cacheCfg, varName, res) {
if (!res)
res = generatorUtils.builder();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/72b826ec/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
index e6b96d0..cc8da9d 100644
--- a/modules/web-control-center/nodejs/generator/xml.js
+++ b/modules/web-control-center/nodejs/generator/xml.js
@@ -23,25 +23,13 @@ var dataStructures = require("../public/javascripts/dataStructures.js");
exports.generateClusterConfiguration = function(cluster) {
var res = generatorUtils.builder();
- res.propertiesRequired = false;
- res.datasourceBeans = [];
+ res.datasources = [];
+ res.deep = 1;
- 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');
-
- res.push(' <bean class="org.apache.ignite.configuration.IgniteConfiguration">\n');
-
- res.deep = 2;
+ // Generate Ignite Configuration.
+ res.startBlock('<bean class="org.apache.ignite.configuration.IgniteConfiguration">');
+ // Generate discovery.
if (cluster.discovery) {
res.startBlock('<property name="discoverySpi">');
res.startBlock('<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">');
@@ -145,25 +133,25 @@ exports.generateClusterConfiguration = function(cluster) {
res.needEmptyLine = true
}
- if (cluster.caches && cluster.caches.length > 0) {
- res.emptyLineIfNeeded();
-
- res.startBlock('<property name="cacheConfiguration">');
- res.startBlock('<list>');
-
- for (var i = 0; i < cluster.caches.length; i++) {
- if (i > 0)
- res.line();
-
- generateCacheConfiguration(cluster.caches[i], res);
- }
+ // Generate atomics group.
+ addBeanWithProperties(res, cluster.atomicConfiguration, 'atomicConfiguration',
+ generatorUtils.atomicConfiguration.className, generatorUtils.atomicConfiguration.fields);
+ res.needEmptyLine = true;
- res.endBlock('</list>');
- res.endBlock('</property>');
+ // Generate communication group.
+ 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;
- res.needEmptyLine = true;
- }
+ // Generate deployment group.
+ addProperty(res, cluster, 'deploymentMode');
+ res.needEmptyLine = true;
+ // Generate events group.
if (cluster.includeEventTypes && cluster.includeEventTypes.length > 0) {
res.emptyLineIfNeeded();
@@ -197,90 +185,120 @@ exports.generateClusterConfiguration = function(cluster) {
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;
+ // Generate marshaller group.
addProperty(res, cluster, 'marshalLocalJobs');
addProperty(res, cluster, 'marshCacheKeepAliveTime');
addProperty(res, cluster, 'marshCachePoolSize');
-
res.needEmptyLine = true;
+ // Generate metrics group.
addProperty(res, cluster, 'metricsExpireTime');
addProperty(res, cluster, 'metricsHistorySize');
addProperty(res, cluster, 'metricsLogFrequency');
addProperty(res, cluster, 'metricsUpdateFrequency');
-
res.needEmptyLine = true;
+ // Generate PeerClassLoading group.
addProperty(res, cluster, 'peerClassLoadingEnabled');
addListProperty(res, cluster, 'peerClassLoadingLocalClassPathExclude');
addProperty(res, cluster, 'peerClassLoadingMissedResourcesCacheSize');
addProperty(res, cluster, 'peerClassLoadingThreadPoolSize');
-
res.needEmptyLine = true;
+ // Generate swap group.
if (cluster.swapSpaceSpi && cluster.swapSpaceSpi.kind == 'FileSwapSpaceSpi') {
addBeanWithProperties(res, cluster.swapSpaceSpi.FileSwapSpaceSpi, 'swapSpaceSpi',
generatorUtils.swapSpaceSpi.className, generatorUtils.swapSpaceSpi.fields, true);
res.needEmptyLine = true;
}
-
+
+ // Generate time group.
addProperty(res, cluster, 'clockSyncSamples');
addProperty(res, cluster, 'clockSyncFrequency');
addProperty(res, cluster, 'timeServerPortBase');
addProperty(res, cluster, 'timeServerPortRange');
-
res.needEmptyLine = true;
+ // Generate thread pools group.
addProperty(res, cluster, 'publicThreadPoolSize');
addProperty(res, cluster, 'systemThreadPoolSize');
addProperty(res, cluster, 'managementThreadPoolSize');
addProperty(res, cluster, 'igfsThreadPoolSize');
-
res.needEmptyLine = true;
-
+
+ // Generate transactions group.
addBeanWithProperties(res, cluster.transactionConfiguration, 'transactionConfiguration',
generatorUtils.transactionConfiguration.className, generatorUtils.transactionConfiguration.fields);
-
- res.needEmptyLine = true;
-
- addProperty(res, cluster, 'cacheSanityCheckEnabled');
-
res.needEmptyLine = true;
+ // Generate utility group.
addProperty(res, cluster, 'utilityCacheKeepAliveTime');
addProperty(res, cluster, 'utilityCachePoolSize');
-
- res.push(' </bean>\n');
- res.push('</beans>');
-
- if (res.propertiesRequired) {
- res.splice(1, 0,
- '\n <!--Bean to load properties file -->\n' +
- ' <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\n' +
- ' <property name="location" value="classpath:ignite.properties"/>\n' +
- ' </bean>\n');
+
+ // Generate caches configs.
+ 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;
}
- return res.join('');
+ res.endBlock('</bean>');
+
+ // Build final XML:
+ // 1. Add header.
+ var xml = '<?xml version="1.0" encoding="UTF-8"?>\n\n';
+
+ xml += '<!-- ' + generatorUtils.mainComment() + ' -->\n';
+ xml += '<beans xmlns="http://www.springframework.org/schema/beans"\n';
+ xml += ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n';
+ xml += ' xmlns:util="http://www.springframework.org/schema/util"\n';
+ xml += ' xsi:schemaLocation="http://www.springframework.org/schema/beans\n';
+ xml += ' http://www.springframework.org/schema/beans/spring-beans.xsd\n';
+ xml += ' http://www.springframework.org/schema/util\n';
+ xml += ' http://www.springframework.org/schema/util/spring-util.xsd">\n';
+
+ // 2. Add external property file and all data sources.
+ if (res.datasources.length > 0) {
+ xml += ' <!-- Load external properties file. -->\n';
+ xml += ' <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">\n';
+ xml += ' <property name="location" value="classpath:ignite.properties"/>\n';
+ xml += ' </bean>\n\n';
+
+ xml += ' <!-- Data source beans will be initialized from external properties file. -->\n';
+
+ _.forEach(res.datasources, function(item) {
+ var beanId = item.dataSourceBean;
+
+ xml += ' <bean id= "' + beanId + '" class="' + item.className + '">\n';
+ xml += ' <property name="URL" value="${' + beanId + '.jdbc.url}" />\n';
+ xml += ' <property name="user" value="${' + beanId + '.jdbc.username}" />\n';
+ xml += ' <property name="password" value="${' + beanId + '.jdbc.password}" />\n';
+ xml += ' </bean>\n\n';
+ });
+ }
+
+ // 3. Add main content.
+ xml += res.join('');
+
+ // 4. Add footer.
+ xml += '</beans>\n';
+
+ return xml;
};
function createEvictionPolicy(res, evictionPolicy, propertyName) {
@@ -381,22 +399,15 @@ function generateCacheConfiguration(cacheCfg, res) {
addBeanWithProperties(res, storeFactory, 'cacheStoreFactory', data.className, data.fields, true);
if (storeFactory.dialect) {
- res.propertiesRequired = true;
-
- if (!_.contains(res.datasourceBeans, storeFactory.dataSourceBean)) {
- res.datasourceBeans.push(storeFactory.dataSourceBean);
-
- var dataSource = generatorUtils.dataSources[storeFactory.dialect];
-
- var dsBean = '\n <bean id= "' + storeFactory.dataSourceBean + '" class="' + dataSource.className + '">\n';
-
- dsBean += ' <property name="URL" value="${' + storeFactory.dataSourceBean + '.jdbc.url}" />\n';
- dsBean += ' <property name="user" value="${' + storeFactory.dataSourceBean + '.jdbc.username}" />\n';
- dsBean += ' <property name="password" value="${' + storeFactory.dataSourceBean + '.jdbc.password}" />\n';
-
- dsBean += ' </bean>\n\n';
-
- res.splice(1, 0, dsBean);
+ console.log("storeFactory.dataSourceBean = " + storeFactory.dataSourceBean);
+
+ if (_.findIndex(res.datasources, function (ds) {
+ return ds.dataSourceBean == storeFactory.dataSourceBean;
+ }) < 0) {
+ res.datasources.push({
+ dataSourceBean: storeFactory.dataSourceBean,
+ className: generatorUtils.dataSources[storeFactory.dialect]
+ });
}
}
}
[2/2] incubator-ignite git commit: Merge remote-tracking branch
'origin/ignite-843' into ignite-843
Posted by ak...@apache.org.
Merge remote-tracking branch 'origin/ignite-843' into ignite-843
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e45c00f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e45c00f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e45c00f4
Branch: refs/heads/ignite-843
Commit: e45c00f4fe10f063bcc35e24efe24323472c7399
Parents: 72b826e 6da888c
Author: AKuznetsov <ak...@gridgain.com>
Authored: Thu Jul 9 00:26:37 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Thu Jul 9 00:26:37 2015 +0700
----------------------------------------------------------------------
modules/web-control-center/nodejs/app.js | 2 ++
.../nodejs/public/javascripts/xeditable.min.js | 6 ++++
.../nodejs/public/stylesheets/xeditable.css | 7 ++++
.../web-control-center/nodejs/routes/profile.js | 36 ++++++++++++++++++++
.../nodejs/views/includes/header.jade | 2 ++
.../nodejs/views/profile.jade | 28 +++++++++++++++
6 files changed, 81 insertions(+)
----------------------------------------------------------------------