Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6FF9C200C02 for ; Thu, 5 Jan 2017 09:58:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6EA24160B27; Thu, 5 Jan 2017 08:58:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 033BC160B56 for ; Thu, 5 Jan 2017 09:58:05 +0100 (CET) Received: (qmail 11181 invoked by uid 500); 5 Jan 2017 08:58:05 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 10567 invoked by uid 99); 5 Jan 2017 08:58:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jan 2017 08:58:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B891ADFE92; Thu, 5 Jan 2017 08:58:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Thu, 05 Jan 2017 08:58:15 -0000 Message-Id: <461d08feb2de427d98fd8715ac2b167c@git.apache.org> In-Reply-To: <76c54cad1ab1489682d63371d771d299@git.apache.org> References: <76c54cad1ab1489682d63371d771d299@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/26] ignite git commit: Web console beta-7. archived-at: Thu, 05 Jan 2017 08:58:08 -0000 http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js b/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js new file mode 100644 index 0000000..2e01761 --- /dev/null +++ b/modules/web-console/frontend/app/modules/configuration/generator/Maven.service.js @@ -0,0 +1,234 @@ +/* + * 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. + */ + +import StringBuilder from './StringBuilder'; + +// Java built-in class names. +import POM_DEPENDENCIES from 'app/data/pom-dependencies.json'; + +/** + * Pom file generation entry point. + */ +export default class IgniteMavenGenerator { + escapeId(s) { + if (typeof (s) !== 'string') + return s; + + return s.replace(/[^A-Za-z0-9_\-.]+/g, '_'); + } + + addProperty(sb, tag, val) { + sb.append('<' + tag + '>' + val + ''); + } + + addDependency(deps, groupId, artifactId, version, jar) { + if (!_.find(deps, (dep) => dep.groupId === groupId && dep.artifactId === artifactId)) + deps.push({groupId, artifactId, version, jar}); + } + + addResource(sb, dir, exclude) { + sb.startBlock(''); + if (dir) + this.addProperty(sb, 'directory', dir); + + if (exclude) { + sb.startBlock(''); + this.addProperty(sb, 'exclude', exclude); + sb.endBlock(''); + } + + sb.endBlock(''); + } + + artifact(sb, cluster, version) { + this.addProperty(sb, 'groupId', 'org.apache.ignite'); + this.addProperty(sb, 'artifactId', this.escapeId(cluster.name) + '-project'); + this.addProperty(sb, 'version', version); + + sb.emptyLine(); + } + + dependencies(sb, cluster, deps) { + sb.startBlock(''); + + _.forEach(deps, (dep) => { + sb.startBlock(''); + + this.addProperty(sb, 'groupId', dep.groupId); + this.addProperty(sb, 'artifactId', dep.artifactId); + this.addProperty(sb, 'version', dep.version); + + if (dep.jar) { + this.addProperty(sb, 'scope', 'system'); + this.addProperty(sb, 'systemPath', '${project.basedir}/jdbc-drivers/' + dep.jar); + } + + sb.endBlock(''); + }); + + sb.endBlock(''); + + return sb; + } + + build(sb = new StringBuilder(), cluster, excludeGroupIds) { + sb.startBlock(''); + sb.startBlock(''); + this.addResource(sb, 'src/main/java', '**/*.java'); + this.addResource(sb, 'src/main/resources'); + sb.endBlock(''); + + sb.startBlock(''); + sb.startBlock(''); + this.addProperty(sb, 'artifactId', 'maven-dependency-plugin'); + sb.startBlock(''); + sb.startBlock(''); + this.addProperty(sb, 'id', 'copy-libs'); + this.addProperty(sb, 'phase', 'test-compile'); + sb.startBlock(''); + this.addProperty(sb, 'goal', 'copy-dependencies'); + sb.endBlock(''); + sb.startBlock(''); + this.addProperty(sb, 'excludeGroupIds', excludeGroupIds.join(',')); + this.addProperty(sb, 'outputDirectory', 'target/libs'); + this.addProperty(sb, 'includeScope', 'compile'); + this.addProperty(sb, 'excludeTransitive', 'true'); + sb.endBlock(''); + sb.endBlock(''); + sb.endBlock(''); + sb.endBlock(''); + sb.startBlock(''); + this.addProperty(sb, 'artifactId', 'maven-compiler-plugin'); + this.addProperty(sb, 'version', '3.1'); + sb.startBlock(''); + this.addProperty(sb, 'source', '1.7'); + this.addProperty(sb, 'target', '1.7'); + sb.endBlock(''); + sb.endBlock(''); + sb.endBlock(''); + sb.endBlock(''); + + sb.endBlock(''); + } + + /** + * Add dependency for specified store factory if not exist. + * @param storeDeps Already added dependencies. + * @param storeFactory Store factory to add dependency. + */ + storeFactoryDependency(storeDeps, storeFactory) { + if (storeFactory.dialect && (!storeFactory.connectVia || storeFactory.connectVia === 'DataSource')) { + const dep = POM_DEPENDENCIES[storeFactory.dialect]; + + this.addDependency(storeDeps, dep.groupId, dep.artifactId, dep.version, dep.jar); + } + } + + /** + * Generate pom.xml. + * + * @param cluster Cluster to take info about dependencies. + * @param version Ignite version for Ignite dependencies. + * @param sb Resulting output with generated pom. + * @returns {string} Generated content. + */ + generate(cluster, version, sb = new StringBuilder()) { + const caches = cluster.caches; + const deps = []; + const storeDeps = []; + const excludeGroupIds = ['org.apache.ignite']; + + const blobStoreFactory = {cacheStoreFactory: {kind: 'CacheHibernateBlobStoreFactory'}}; + + _.forEach(caches, (cache) => { + if (cache.cacheStoreFactory && cache.cacheStoreFactory.kind) + this.storeFactoryDependency(storeDeps, cache.cacheStoreFactory[cache.cacheStoreFactory.kind]); + + if (_.get(cache, 'nodeFilter.kind') === 'Exclude') + this.addDependency(deps, 'org.apache.ignite', 'ignite-extdata-p2p', version); + }); + + sb.append(''); + + sb.emptyLine(); + + sb.append(``); + + sb.emptyLine(); + + sb.startBlock(''); + + sb.append('4.0.0'); + + sb.emptyLine(); + + this.artifact(sb, cluster, version); + + this.addDependency(deps, 'org.apache.ignite', 'ignite-core', version); + + this.addDependency(deps, 'org.apache.ignite', 'ignite-spring', version); + this.addDependency(deps, 'org.apache.ignite', 'ignite-indexing', version); + this.addDependency(deps, 'org.apache.ignite', 'ignite-rest-http', version); + + if (_.get(cluster, 'deploymentSpi.kind') === 'URI') + this.addDependency(deps, 'org.apache.ignite', 'ignite-urideploy', version); + + let dep = POM_DEPENDENCIES[cluster.discovery.kind]; + + if (dep) + this.addDependency(deps, 'org.apache.ignite', dep.artifactId, version); + + if (cluster.discovery.kind === 'Jdbc') { + const store = cluster.discovery.Jdbc; + + if (store.dataSourceBean && store.dialect) + this.storeFactoryDependency(storeDeps, cluster.discovery.Jdbc); + } + + _.forEach(cluster.checkpointSpi, (spi) => { + if (spi.kind === 'S3') { + dep = POM_DEPENDENCIES.S3; + + if (dep) + this.addDependency(deps, 'org.apache.ignite', dep.artifactId, version); + } + else if (spi.kind === 'JDBC') + this.storeFactoryDependency(storeDeps, spi.JDBC); + }); + + if (_.find(cluster.igfss, (igfs) => igfs.secondaryFileSystemEnabled)) + this.addDependency(deps, 'org.apache.ignite', 'ignite-hadoop', version); + + if (_.find(caches, blobStoreFactory)) + this.addDependency(deps, 'org.apache.ignite', 'ignite-hibernate', version); + + if (cluster.logger && cluster.logger.kind) { + dep = POM_DEPENDENCIES[cluster.logger.kind]; + + if (dep) + this.addDependency(deps, 'org.apache.ignite', dep.artifactId, version); + } + + this.dependencies(sb, cluster, deps.concat(storeDeps)); + + sb.emptyLine(); + + this.build(sb, cluster, excludeGroupIds); + + return sb; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/Pom.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/Pom.service.js b/modules/web-console/frontend/app/modules/configuration/generator/Pom.service.js deleted file mode 100644 index db58532..0000000 --- a/modules/web-console/frontend/app/modules/configuration/generator/Pom.service.js +++ /dev/null @@ -1,233 +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. - */ - -import StringBuilder from './StringBuilder'; - -// Java built-in class names. -import POM_DEPENDENCIES from 'app/data/pom-dependencies.json'; - -/** - * Pom file generation entry point. - */ -class GeneratorPom { - escapeId(s) { - if (typeof (s) !== 'string') - return s; - - return s.replace(/[^A-Za-z0-9_\-.]+/g, '_'); - } - - addProperty(sb, tag, val) { - sb.append('<' + tag + '>' + val + ''); - } - - addDependency(deps, groupId, artifactId, version, jar) { - if (!_.find(deps, (dep) => dep.groupId === groupId && dep.artifactId === artifactId)) - deps.push({groupId, artifactId, version, jar}); - } - - addResource(sb, dir, exclude) { - sb.startBlock(''); - if (dir) - this.addProperty(sb, 'directory', dir); - - if (exclude) { - sb.startBlock(''); - this.addProperty(sb, 'exclude', exclude); - sb.endBlock(''); - } - - sb.endBlock(''); - } - - artifact(sb, cluster, version) { - this.addProperty(sb, 'groupId', 'org.apache.ignite'); - this.addProperty(sb, 'artifactId', this.escapeId(cluster.name) + '-project'); - this.addProperty(sb, 'version', version); - - sb.emptyLine(); - } - - dependencies(sb, cluster, deps) { - sb.startBlock(''); - - _.forEach(deps, (dep) => { - sb.startBlock(''); - - this.addProperty(sb, 'groupId', dep.groupId); - this.addProperty(sb, 'artifactId', dep.artifactId); - this.addProperty(sb, 'version', dep.version); - - if (dep.jar) { - this.addProperty(sb, 'scope', 'system'); - this.addProperty(sb, 'systemPath', '${project.basedir}/jdbc-drivers/' + dep.jar); - } - - sb.endBlock(''); - }); - - sb.endBlock(''); - - return sb; - } - - build(sb = new StringBuilder(), cluster, excludeGroupIds) { - sb.startBlock(''); - sb.startBlock(''); - this.addResource(sb, 'src/main/java', '**/*.java'); - this.addResource(sb, 'src/main/resources'); - sb.endBlock(''); - - sb.startBlock(''); - sb.startBlock(''); - this.addProperty(sb, 'artifactId', 'maven-dependency-plugin'); - sb.startBlock(''); - sb.startBlock(''); - this.addProperty(sb, 'id', 'copy-libs'); - this.addProperty(sb, 'phase', 'test-compile'); - sb.startBlock(''); - this.addProperty(sb, 'goal', 'copy-dependencies'); - sb.endBlock(''); - sb.startBlock(''); - this.addProperty(sb, 'excludeGroupIds', excludeGroupIds.join(',')); - this.addProperty(sb, 'outputDirectory', 'target/libs'); - this.addProperty(sb, 'includeScope', 'compile'); - this.addProperty(sb, 'excludeTransitive', 'true'); - sb.endBlock(''); - sb.endBlock(''); - sb.endBlock(''); - sb.endBlock(''); - sb.startBlock(''); - this.addProperty(sb, 'artifactId', 'maven-compiler-plugin'); - this.addProperty(sb, 'version', '3.1'); - sb.startBlock(''); - this.addProperty(sb, 'source', '1.7'); - this.addProperty(sb, 'target', '1.7'); - sb.endBlock(''); - sb.endBlock(''); - sb.endBlock(''); - sb.endBlock(''); - - sb.endBlock(''); - } - - /** - * Add dependency for specified store factory if not exist. - * @param storeDeps Already added dependencies. - * @param storeFactory Store factory to add dependency. - */ - storeFactoryDependency(storeDeps, storeFactory) { - if (storeFactory.dialect && (!storeFactory.connectVia || storeFactory.connectVia === 'DataSource')) { - const dep = POM_DEPENDENCIES[storeFactory.dialect]; - - this.addDependency(storeDeps, dep.groupId, dep.artifactId, dep.version, dep.jar); - } - } - - /** - * Generate pom.xml. - * - * @param cluster Cluster to take info about dependencies. - * @param version Ignite version for Ignite dependencies. - * @param sb Resulting output with generated pom. - * @returns {string} Generated content. - */ - generate(cluster, version, sb = new StringBuilder()) { - const caches = cluster.caches; - const deps = []; - const storeDeps = []; - const excludeGroupIds = ['org.apache.ignite']; - - const blobStoreFactory = {cacheStoreFactory: {kind: 'CacheHibernateBlobStoreFactory'}}; - - _.forEach(caches, (cache) => { - if (cache.cacheStoreFactory && cache.cacheStoreFactory.kind) - this.storeFactoryDependency(storeDeps, cache.cacheStoreFactory[cache.cacheStoreFactory.kind]); - - if (_.get(cache, 'nodeFilter.kind') === 'Exclude') - this.addDependency(deps, 'org.apache.ignite', 'ignite-extdata-p2p', version); - }); - - sb.append(''); - - sb.emptyLine(); - - sb.append(``); - - sb.emptyLine(); - - sb.startBlock(''); - - sb.append('4.0.0'); - - sb.emptyLine(); - - this.artifact(sb, cluster, version); - - this.addDependency(deps, 'org.apache.ignite', 'ignite-core', version); - - this.addDependency(deps, 'org.apache.ignite', 'ignite-spring', version); - this.addDependency(deps, 'org.apache.ignite', 'ignite-indexing', version); - this.addDependency(deps, 'org.apache.ignite', 'ignite-rest-http', version); - - let dep = POM_DEPENDENCIES[cluster.discovery.kind]; - - if (dep) - this.addDependency(deps, 'org.apache.ignite', dep.artifactId, version); - - if (cluster.discovery.kind === 'Jdbc') { - const store = cluster.discovery.Jdbc; - - if (store.dataSourceBean && store.dialect) - this.storeFactoryDependency(storeDeps, cluster.discovery.Jdbc); - } - - _.forEach(cluster.checkpointSpi, (spi) => { - if (spi.kind === 'S3') { - dep = POM_DEPENDENCIES.S3; - - if (dep) - this.addDependency(deps, 'org.apache.ignite', dep.artifactId, version); - } - else if (spi.kind === 'JDBC') - this.storeFactoryDependency(storeDeps, spi.JDBC); - }); - - if (_.find(cluster.igfss, (igfs) => igfs.secondaryFileSystemEnabled)) - this.addDependency(deps, 'org.apache.ignite', 'ignite-hadoop', version); - - if (_.find(caches, blobStoreFactory)) - this.addDependency(deps, 'org.apache.ignite', 'ignite-hibernate', version); - - if (cluster.logger && cluster.logger.kind) { - dep = POM_DEPENDENCIES[cluster.logger.kind]; - - if (dep) - this.addDependency(deps, 'org.apache.ignite', dep.artifactId, version); - } - - this.dependencies(sb, cluster, deps.concat(storeDeps)); - - sb.emptyLine(); - - this.build(sb, cluster, excludeGroupIds); - - return sb; - } -} - -export default ['GeneratorPom', GeneratorPom]; http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js b/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js index 49b4aa6..8a6a471 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/Properties.service.js @@ -20,7 +20,7 @@ import StringBuilder from './StringBuilder'; /** * Properties generation entry point. */ -export default class PropertiesGenerator { +export default class IgnitePropertiesGenerator { _collectProperties(bean) { const props = []; http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/Readme.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/Readme.service.js b/modules/web-console/frontend/app/modules/configuration/generator/Readme.service.js index 7043807..0aa34ee 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/Readme.service.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/Readme.service.js @@ -20,7 +20,7 @@ import StringBuilder from './StringBuilder'; /** * Properties generation entry point. */ -export default class ReadmeGenerator { +export default class IgniteReadmeGenerator { header(sb) { sb.append('Content of this folder was generated by Apache Ignite Web Console'); sb.append('================================================================='); http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/SharpTransformer.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/SharpTransformer.service.js b/modules/web-console/frontend/app/modules/configuration/generator/SharpTransformer.service.js index 19043f6..6e6bffe 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/SharpTransformer.service.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/SharpTransformer.service.js @@ -19,225 +19,238 @@ import _ from 'lodash'; import AbstractTransformer from './AbstractTransformer'; import StringBuilder from './StringBuilder'; -export default ['JavaTypes', 'IgnitePlatformGenerator', (JavaTypes, generator) => { - return class SharpTransformer extends AbstractTransformer { - static generator = generator; - - static commentBlock(sb, ...lines) { - _.forEach(lines, (line) => sb.append(`// ${line}`)); - } - - static doc(sb, ...lines) { - sb.append('/// '); - _.forEach(lines, (line) => sb.append(`/// ${line}`)); - sb.append('/// '); - } - - static mainComment(sb) { - return this.doc(sb, sb.generatedBy()); - } - - /** - * - * @param {Array.} sb - * @param {Bean} bean - */ - static _defineBean(sb, bean) { - const shortClsName = JavaTypes.shortClassName(bean.clsName); - - sb.append(`var ${bean.id} = new ${shortClsName}();`); - } - - /** - * @param {StringBuilder} sb - * @param {Bean} parent - * @param {Bean} propertyName - * @param {String|Bean} value - * @private - */ - static _setProperty(sb, parent, propertyName, value) { - sb.append(`${parent.id}.${_.upperFirst(propertyName)} = ${value};`); - } - - /** - * - * @param {StringBuilder} sb - * @param {Bean} parent - * @param {String} propertyName - * @param {Bean} bean - * @private - */ - static _setBeanProperty(sb, parent, propertyName, bean) { - sb.append(`${parent.id}.${_.upperFirst(propertyName)} = ${bean.id};`); - } - - static _toObject(clsName, val) { - const items = _.isArray(val) ? val : [val]; - - return _.map(items, (item, idx) => { - if (_.isNil(item)) - return 'null'; - - const shortClsName = JavaTypes.shortClassName(clsName); - - switch (shortClsName) { - // case 'byte': - // return `(byte) ${item}`; - // case 'Serializable': - case 'String': - if (items.length > 1) - return `"${item}"${idx !== items.length - 1 ? ' +' : ''}`; - - return `"${item}"`; - // case 'Path': - // return `"${item.replace(/\\/g, '\\\\')}"`; - // case 'Class': - // return `${this.shortClassName(item)}.class`; - // case 'UUID': - // return `UUID.fromString("${item}")`; - // case 'PropertyChar': - // return `props.getProperty("${item}").toCharArray()`; - // case 'Property': - // return `props.getProperty("${item}")`; - // case 'Bean': - // if (item.isComplex()) - // return item.id; +import ConfigurationGenerator from './ConfigurationGenerator'; + +import ClusterDefaults from './defaults/Cluster.service'; +import CacheDefaults from './defaults/Cache.service'; +import IGFSDefaults from './defaults/IGFS.service'; + +import JavaTypes from '../../../services/JavaTypes.service'; + +const generator = new ConfigurationGenerator(); + +const clusterDflts = new ClusterDefaults(); +const cacheDflts = new CacheDefaults(); +const igfsDflts = new IGFSDefaults(); + +const javaTypes = new JavaTypes(clusterDflts, cacheDflts, igfsDflts); + +export default class SharpTransformer extends AbstractTransformer { + static generator = generator; + + static commentBlock(sb, ...lines) { + _.forEach(lines, (line) => sb.append(`// ${line}`)); + } + + static doc(sb, ...lines) { + sb.append('/// '); + _.forEach(lines, (line) => sb.append(`/// ${line}`)); + sb.append('/// '); + } + + static mainComment(sb) { + return this.doc(sb, sb.generatedBy()); + } + + /** + * + * @param {Array.} sb + * @param {Bean} bean + */ + static _defineBean(sb, bean) { + const shortClsName = javaTypes.shortClassName(bean.clsName); + + sb.append(`var ${bean.id} = new ${shortClsName}();`); + } + + /** + * @param {StringBuilder} sb + * @param {Bean} parent + * @param {Bean} propertyName + * @param {String|Bean} value + * @private + */ + static _setProperty(sb, parent, propertyName, value) { + sb.append(`${parent.id}.${_.upperFirst(propertyName)} = ${value};`); + } + + /** + * + * @param {StringBuilder} sb + * @param {Bean} parent + * @param {String} propertyName + * @param {Bean} bean + * @private + */ + static _setBeanProperty(sb, parent, propertyName, bean) { + sb.append(`${parent.id}.${_.upperFirst(propertyName)} = ${bean.id};`); + } + + static _toObject(clsName, val) { + const items = _.isArray(val) ? val : [val]; + + return _.map(items, (item, idx) => { + if (_.isNil(item)) + return 'null'; + + const shortClsName = javaTypes.shortClassName(clsName); + + switch (shortClsName) { + // case 'byte': + // return `(byte) ${item}`; + // case 'Serializable': + case 'String': + if (items.length > 1) + return `"${item}"${idx !== items.length - 1 ? ' +' : ''}`; + + return `"${item}"`; + // case 'Path': + // return `"${item.replace(/\\/g, '\\\\')}"`; + // case 'Class': + // return `${this.shortClassName(item)}.class`; + // case 'UUID': + // return `UUID.fromString("${item}")`; + // case 'PropertyChar': + // return `props.getProperty("${item}").toCharArray()`; + // case 'Property': + // return `props.getProperty("${item}")`; + // case 'Bean': + // if (item.isComplex()) + // return item.id; + // + // return this._newBean(item); + default: + if (javaTypes.nonEnum(shortClsName)) + return item; + + return `${shortClsName}.${item}`; + } + }); + } + + /** + * + * @param {StringBuilder} sb + * @param {Bean} bean + * @returns {Array} + */ + static _setProperties(sb = new StringBuilder(), bean) { + _.forEach(bean.properties, (prop) => { + switch (prop.clsName) { + case 'ICollection': + // const implClsName = JavaTypes.shortClassName(prop.implClsName); + + const colTypeClsName = javaTypes.shortClassName(prop.typeClsName); + + if (colTypeClsName === 'String') { + const items = this._toObject(colTypeClsName, prop.items); + + sb.append(`${bean.id}.${_.upperFirst(prop.name)} = new {${items.join(', ')}};`); + } + // else { + // if (_.includes(vars, prop.id)) + // sb.append(`${prop.id} = new ${implClsName}<>();`); + // else { + // vars.push(prop.id); // - // return this._newBean(item); - default: - if (JavaTypes.nonEnum(shortClsName)) - return item; - - return `${shortClsName}.${item}`; - } - }); - } - - /** - * - * @param {StringBuilder} sb - * @param {Bean} bean - * @returns {Array} - */ - static _setProperties(sb = new StringBuilder(), bean) { - _.forEach(bean.properties, (prop) => { - switch (prop.clsName) { - case 'ICollection': - // const implClsName = JavaTypes.shortClassName(prop.implClsName); - - const colTypeClsName = JavaTypes.shortClassName(prop.typeClsName); - - if (colTypeClsName === 'String') { - const items = this._toObject(colTypeClsName, prop.items); - - sb.append(`${bean.id}.${_.upperFirst(prop.name)} = new {${items.join(', ')}};`); - } - // else { - // if (_.includes(vars, prop.id)) - // sb.append(`${prop.id} = new ${implClsName}<>();`); - // else { - // vars.push(prop.id); - // - // sb.append(`${clsName}<${colTypeClsName}> ${prop.id} = new ${implClsName}<>();`); - // } - // - // sb.emptyLine(); - // - // if (nonBean) { - // const items = this._toObject(colTypeClsName, prop.items); - // - // _.forEach(items, (item) => { - // sb.append(`${prop.id}.add("${item}");`); - // - // sb.emptyLine(); - // }); - // } - // else { - // _.forEach(prop.items, (item) => { - // this.constructBean(sb, item, vars, limitLines); - // - // sb.append(`${prop.id}.add(${item.id});`); - // - // sb.emptyLine(); - // }); - // - // this._setProperty(sb, bean.id, prop.name, prop.id); - // } - // } - - break; - - case 'Bean': - const nestedBean = prop.value; - - this._defineBean(sb, nestedBean); - - sb.emptyLine(); - - this._setProperties(sb, nestedBean); - - sb.emptyLine(); - - this._setBeanProperty(sb, bean, prop.name, nestedBean); - - break; - default: - this._setProperty(sb, bean, prop.name, this._toObject(prop.clsName, prop.value)); - } - }); - - return sb; - } - - /** - * Build Java startup class with configuration. - * - * @param {Bean} cfg - * @param pkg Package name. - * @param clsName Class name for generate factory class otherwise generate code snippet. - * @param clientNearCfg Optional near cache configuration for client node. - * @returns {String} - */ - static toClassFile(cfg, pkg, clsName) { - const sb = new StringBuilder(); - - sb.startBlock(`namespace ${pkg}`, '{'); - - _.forEach(_.sortBy(cfg.collectClasses()), (cls) => sb.append(`using ${cls};`)); - sb.emptyLine(); - - - this.mainComment(sb); - sb.startBlock(`public class ${clsName}`, '{'); - - this.doc(sb, 'Configure grid.'); - sb.startBlock('public static IgniteConfiguration CreateConfiguration()', '{'); - - this._defineBean(sb, cfg); - - sb.emptyLine(); - - this._setProperties(sb, cfg); + // sb.append(`${clsName}<${colTypeClsName}> ${prop.id} = new ${implClsName}<>();`); + // } + // + // sb.emptyLine(); + // + // if (nonBean) { + // const items = this._toObject(colTypeClsName, prop.items); + // + // _.forEach(items, (item) => { + // sb.append(`${prop.id}.add("${item}");`); + // + // sb.emptyLine(); + // }); + // } + // else { + // _.forEach(prop.items, (item) => { + // this.constructBean(sb, item, vars, limitLines); + // + // sb.append(`${prop.id}.add(${item.id});`); + // + // sb.emptyLine(); + // }); + // + // this._setProperty(sb, bean.id, prop.name, prop.id); + // } + // } + + break; + + case 'Bean': + const nestedBean = prop.value; + + this._defineBean(sb, nestedBean); + + sb.emptyLine(); + + this._setProperties(sb, nestedBean); + + sb.emptyLine(); + + this._setBeanProperty(sb, bean, prop.name, nestedBean); + + break; + default: + this._setProperty(sb, bean, prop.name, this._toObject(prop.clsName, prop.value)); + } + }); + + return sb; + } + + /** + * Build Java startup class with configuration. + * + * @param {Bean} cfg + * @param pkg Package name. + * @param clsName Class name for generate factory class otherwise generate code snippet. + * @returns {String} + */ + static toClassFile(cfg, pkg, clsName) { + const sb = new StringBuilder(); + + sb.startBlock(`namespace ${pkg}`, '{'); + + _.forEach(_.sortBy(cfg.collectClasses()), (cls) => sb.append(`using ${cls};`)); + sb.emptyLine(); + + + this.mainComment(sb); + sb.startBlock(`public class ${clsName}`, '{'); + + this.doc(sb, 'Configure grid.'); + sb.startBlock('public static IgniteConfiguration CreateConfiguration()', '{'); + + this._defineBean(sb, cfg); + + sb.emptyLine(); + + this._setProperties(sb, cfg); - sb.emptyLine(); + sb.emptyLine(); - sb.append(`return ${cfg.id};`); + sb.append(`return ${cfg.id};`); - sb.endBlock('}'); + sb.endBlock('}'); - sb.endBlock('}'); + sb.endBlock('}'); - sb.endBlock('}'); + sb.endBlock('}'); - return sb.asString(); - } + return sb.asString(); + } - static generateSection(bean) { - const sb = new StringBuilder(); + static generateSection(bean) { + const sb = new StringBuilder(); - this._setProperties(sb, bean); + this._setProperties(sb, bean); - return sb.asString(); - } - }; -}]; + return sb.asString(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/SpringTransformer.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/SpringTransformer.service.js b/modules/web-console/frontend/app/modules/configuration/generator/SpringTransformer.service.js index 73df25e..b234575 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/SpringTransformer.service.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/SpringTransformer.service.js @@ -20,314 +20,311 @@ import _ from 'lodash'; import AbstractTransformer from './AbstractTransformer'; import StringBuilder from './StringBuilder'; -const escapeXml = (str) => { - return str.replace(/&/g, '&') - .replace(/"/g, '"') - .replace(/'/g, ''') - .replace(/>/g, '>') - .replace(/ { - return class SpringTransformer extends AbstractTransformer { - static generator = generator; - - static commentBlock(sb, ...lines) { - if (lines.length > 1) { - sb.append(''); - } - else - sb.append(``); +export default class IgniteSpringTransformer extends AbstractTransformer { + static escapeXml(str) { + return str.replace(/&/g, '&') + .replace(/"/g, '"') + .replace(/'/g, ''') + .replace(/>/g, '>') + .replace(/ 1) { + sb.append(''); } + else + sb.append(``); + } - static appendBean(sb, bean, appendId) { - const beanTags = []; - - if (appendId) - beanTags.push(`id="${bean.id}"`); - - beanTags.push(`class="${bean.clsName}"`); - - if (bean.factoryMtd) - beanTags.push(`factory-method="${bean.factoryMtd}"`); - - sb.startBlock(``); - - _.forEach(bean.arguments, (arg) => { - if (arg.clsName === 'MAP') { - sb.startBlock(''); - this._constructMap(sb, arg); - sb.endBlock(''); - } - else if (_.isNil(arg.value)) { - sb.startBlock(''); - sb.append(''); - sb.endBlock(''); - } - else if (arg.constant) { - sb.startBlock(''); - sb.append(``); - sb.endBlock(''); - } - else if (arg.clsName === 'BEAN') { - sb.startBlock(''); - this.appendBean(sb, arg.value); - sb.endBlock(''); - } - else - sb.append(``); - }); + static appendBean(sb, bean, appendId) { + const beanTags = []; - this._setProperties(sb, bean); + if (appendId) + beanTags.push(`id="${bean.id}"`); - sb.endBlock(''); - } + beanTags.push(`class="${bean.clsName}"`); - static _toObject(clsName, items) { - return _.map(_.isArray(items) ? items : [items], (item) => { - switch (clsName) { - case 'PROPERTY': - case 'PROPERTY_CHAR': - case 'PROPERTY_INT': - return `\${${item}}`; - case 'java.lang.Class': - return JavaTypes.fullClassName(item); - case 'long': - return `${item}L`; - case 'java.lang.String': - return escapeXml(item); - default: - return item; - } - }); - } + if (bean.factoryMtd) + beanTags.push(`factory-method="${bean.factoryMtd}"`); - static _isBean(clsName) { - return JavaTypes.nonBuiltInClass(clsName) && JavaTypes.nonEnum(clsName) && _.includes(clsName, '.'); - } + sb.startBlock(``); - static _setCollection(sb, prop) { - sb.startBlock(``); - sb.startBlock(''); + _.forEach(bean.arguments, (arg) => { + if (arg.clsName === 'MAP') { + sb.startBlock(''); + this._constructMap(sb, arg); + sb.endBlock(''); + } + else if (_.isNil(arg.value)) { + sb.startBlock(''); + sb.append(''); + sb.endBlock(''); + } + else if (arg.constant) { + sb.startBlock(''); + sb.append(``); + sb.endBlock(''); + } + else if (arg.clsName === 'BEAN') { + sb.startBlock(''); + this.appendBean(sb, arg.value); + sb.endBlock(''); + } + else + sb.append(``); + }); + + this._setProperties(sb, bean); + + sb.endBlock(''); + } + + static _toObject(clsName, items) { + return _.map(_.isArray(items) ? items : [items], (item) => { + switch (clsName) { + case 'PROPERTY': + case 'PROPERTY_CHAR': + case 'PROPERTY_INT': + return `\${${item}}`; + case 'java.lang.Class': + return this.javaTypes.fullClassName(item); + case 'long': + return `${item}L`; + case 'java.lang.String': + case 'PATH': + return this.escapeXml(item); + default: + return item; + } + }); + } - _.forEach(prop.items, (item, idx) => { - if (this._isBean(prop.typeClsName)) { - if (idx !== 0) - sb.emptyLine(); + static _isBean(clsName) { + return this.javaTypes.nonBuiltInClass(clsName) && this.javaTypes.nonEnum(clsName) && _.includes(clsName, '.'); + } - this.appendBean(sb, item); - } - else - sb.append(`${item}`); - }); + static _setCollection(sb, prop) { + sb.startBlock(``); + sb.startBlock(''); - sb.endBlock(''); - sb.endBlock(''); - } + _.forEach(prop.items, (item, idx) => { + if (this._isBean(prop.typeClsName)) { + if (idx !== 0) + sb.emptyLine(); - static _constructMap(sb, map) { - sb.startBlock(''); + this.appendBean(sb, item); + } + else + sb.append(`${item}`); + }); - _.forEach(map.entries, (entry) => { - const key = entry[map.keyField]; - const val = entry[map.valField]; + sb.endBlock(''); + sb.endBlock(''); + } - const isKeyBean = this._isBean(map.keyClsName); - const isValBean = this._isBean(map.valClsName); + static _constructMap(sb, map) { + sb.startBlock(''); + _.forEach(map.entries, (entry) => { + const key = entry[map.keyField]; + const val = entry[map.valField]; - if (isKeyBean || isValBean) { - sb.startBlock(''); + const isKeyBean = this._isBean(map.keyClsName); + const isValBean = this._isBean(map.valClsName); - sb.startBlock(''); - if (isKeyBean) - this.appendBean(sb, key); - else - sb.append(this._toObject(map.keyClsName, key)); - sb.endBlock(''); - sb.startBlock(''); - if (isValBean) - this.appendBean(sb, val); - else - sb.append(this._toObject(map.valClsName, val)); - sb.endBlock(''); + if (isKeyBean || isValBean) { + sb.startBlock(''); - sb.endBlock(''); - } + sb.startBlock(''); + if (isKeyBean) + this.appendBean(sb, key); else - sb.append(``); - }); + sb.append(this._toObject(map.keyClsName, key)); + sb.endBlock(''); - sb.endBlock(''); - } + sb.startBlock(''); + if (isValBean) + this.appendBean(sb, val); + else + sb.append(this._toObject(map.valClsName, val)); + sb.endBlock(''); - /** - * - * @param {StringBuilder} sb - * @param {Bean} bean - * @returns {StringBuilder} - */ - static _setProperties(sb, bean) { - _.forEach(bean.properties, (prop, idx) => { - switch (prop.clsName) { - case 'DATA_SOURCE': - const valAttr = prop.name === 'dataSource' ? 'ref' : 'value'; + sb.endBlock(''); + } + else + sb.append(``); + }); - sb.append(``); + sb.endBlock(''); + } - break; - case 'EVENT_TYPES': - sb.startBlock(``); + /** + * + * @param {StringBuilder} sb + * @param {Bean} bean + * @returns {StringBuilder} + */ + static _setProperties(sb, bean) { + _.forEach(bean.properties, (prop, idx) => { + switch (prop.clsName) { + case 'DATA_SOURCE': + const valAttr = prop.name === 'dataSource' ? 'ref' : 'value'; - if (prop.eventTypes.length === 1) { - const evtGrp = _.find(eventGroups, {value: _.head(prop.eventTypes)}); + sb.append(``); - evtGrp && sb.append(``); - } - else { - sb.startBlock(''); + break; + case 'EVENT_TYPES': + sb.startBlock(``); - _.forEach(prop.eventTypes, (item, ix) => { - ix > 0 && sb.emptyLine(); + if (prop.eventTypes.length === 1) { + const evtGrp = _.find(this.eventGroups, {value: _.head(prop.eventTypes)}); - const evtGrp = _.find(eventGroups, {value: item}); + evtGrp && sb.append(``); + } + else { + sb.startBlock(''); - if (evtGrp) { - sb.append(``); + _.forEach(prop.eventTypes, (item, ix) => { + ix > 0 && sb.emptyLine(); - _.forEach(evtGrp.events, (event) => - sb.append(``)); - } - }); + const evtGrp = _.find(this.eventGroups, {value: item}); - sb.endBlock(''); - } + if (evtGrp) { + sb.append(``); - sb.endBlock(''); + _.forEach(evtGrp.events, (event) => + sb.append(``)); + } + }); - break; - case 'ARRAY': - case 'COLLECTION': - this._setCollection(sb, prop); + sb.endBlock(''); + } - break; - case 'MAP': - sb.startBlock(``); + sb.endBlock(''); - this._constructMap(sb, prop); + break; + case 'ARRAY': + case 'COLLECTION': + this._setCollection(sb, prop); - sb.endBlock(''); + break; + case 'MAP': + sb.startBlock(``); - break; - case 'java.util.Properties': - sb.startBlock(``); - sb.startBlock(''); + this._constructMap(sb, prop); - _.forEach(prop.entries, (entry) => { - sb.append(`${entry.value}`); - }); + sb.endBlock(''); - sb.endBlock(''); - sb.endBlock(''); + break; + case 'java.util.Properties': + sb.startBlock(``); + sb.startBlock(''); - break; - case 'BEAN': - sb.startBlock(``); + _.forEach(prop.entries, (entry) => { + sb.append(`${entry.value}`); + }); - this.appendBean(sb, prop.value); + sb.endBlock(''); + sb.endBlock(''); - sb.endBlock(''); + break; + case 'BEAN': + sb.startBlock(``); - break; - default: - sb.append(``); - } + this.appendBean(sb, prop.value); - this._emptyLineIfNeeded(sb, bean.properties, idx); - }); + sb.endBlock(''); - return sb; - } + break; + default: + sb.append(``); + } - /** - * Build final XML. - * - * @param {Bean} cfg Ignite configuration. - * @param {Boolean} clientNearCaches - * @returns {StringBuilder} - */ - static igniteConfiguration(cfg, clientNearCaches) { - const sb = new StringBuilder(); - - // 0. Add header. - sb.append(''); - sb.emptyLine(); + this._emptyLineIfNeeded(sb, bean.properties, idx); + }); + + return sb; + } + + /** + * Build final XML. + * + * @param {Bean} cfg Ignite configuration. + * @param {Boolean} clientNearCaches + * @returns {StringBuilder} + */ + static igniteConfiguration(cfg, clientNearCaches) { + const sb = new StringBuilder(); + + // 0. Add header. + sb.append(''); + sb.emptyLine(); + + this.mainComment(sb); + sb.emptyLine(); + + // 1. Start beans section. + sb.startBlock([ + '']); + + // 2. Add external property file + if (this.hasProperties(cfg)) { + this.commentBlock(sb, 'Load external properties file.'); + + sb.startBlock(''); + sb.append(''); + sb.endBlock(''); - this.mainComment(sb); sb.emptyLine(); + } - // 1. Start beans section. - sb.startBlock([ - '']); + // 3. Add data sources. + const dataSources = this.collectDataSources(cfg); - // 2. Add external property file - if (this.hasProperties(cfg)) { - this.commentBlock(sb, 'Load external properties file.'); + if (dataSources.length) { + this.commentBlock(sb, 'Data source beans will be initialized from external properties file.'); - sb.startBlock(''); - sb.append(''); - sb.endBlock(''); + _.forEach(dataSources, (ds) => { + this.appendBean(sb, ds, true); sb.emptyLine(); - } - - // 3. Add data sources. - const dataSources = this.collectDataSources(cfg); - - if (dataSources.length) { - this.commentBlock(sb, 'Data source beans will be initialized from external properties file.'); - - _.forEach(dataSources, (ds) => { - this.appendBean(sb, ds, true); - - sb.emptyLine(); - }); - } + }); + } - _.forEach(clientNearCaches, (cache) => { - this.commentBlock(sb, 'Configuration of near cache for cache "' + cache.name + '"'); + _.forEach(clientNearCaches, (cache) => { + this.commentBlock(sb, `Configuration of near cache for cache "${cache.name}"`); - this.appendBean(sb, generator.cacheNearClient(cache), true); + this.appendBean(sb, this.generator.cacheNearClient(cache), true); - sb.emptyLine(); - }); + sb.emptyLine(); + }); - // 3. Add main content. - this.appendBean(sb, cfg); + // 3. Add main content. + this.appendBean(sb, cfg); - // 4. Close beans section. - sb.endBlock(''); + // 4. Close beans section. + sb.endBlock(''); - return sb; - } + return sb; + } - static cluster(cluster, client) { - const cfg = generator.igniteConfiguration(cluster, client); + static cluster(cluster, client) { + const cfg = this.generator.igniteConfiguration(cluster, client); - const clientNearCaches = client ? _.filter(cluster.caches, (cache) => _.get(cache, 'clientNearConfiguration.enabled')) : []; + const clientNearCaches = client ? _.filter(cluster.caches, (cache) => _.get(cache, 'clientNearConfiguration.enabled')) : []; - return this.igniteConfiguration(cfg, clientNearCaches); - } - }; -}]; + return this.igniteConfiguration(cfg, clientNearCaches); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.platform.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.platform.service.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.platform.service.js new file mode 100644 index 0000000..eeac3a0 --- /dev/null +++ b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.platform.service.js @@ -0,0 +1,56 @@ +/* + * 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. + */ + +import _ from 'lodash'; + +const enumValueMapper = (val) => _.capitalize(val); + +const DFLT_CACHE = { + cacheMode: { + clsName: 'Apache.Ignite.Core.Cache.Configuration.CacheMode', + mapper: enumValueMapper + }, + atomicityMode: { + clsName: 'Apache.Ignite.Core.Cache.Configuration.CacheAtomicityMode', + mapper: enumValueMapper + }, + memoryMode: { + clsName: 'Apache.Ignite.Core.Cache.Configuration.CacheMemoryMode', + value: 'ONHEAP_TIERED', + mapper: enumValueMapper + }, + atomicWriteOrderMode: { + clsName: 'org.apache.ignite.cache.CacheAtomicWriteOrderMode', + mapper: enumValueMapper + }, + writeSynchronizationMode: { + clsName: 'org.apache.ignite.cache.CacheWriteSynchronizationMode', + value: 'PRIMARY_SYNC', + mapper: enumValueMapper + }, + rebalanceMode: { + clsName: 'org.apache.ignite.cache.CacheRebalanceMode', + value: 'ASYNC', + mapper: enumValueMapper + } +}; + +export default class IgniteCachePlatformDefaults { + constructor() { + Object.assign(this, DFLT_CACHE); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.service.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.service.js new file mode 100644 index 0000000..14b315f --- /dev/null +++ b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cache.service.js @@ -0,0 +1,131 @@ +/* + * 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. + */ + +const DFLT_CACHE = { + cacheMode: { + clsName: 'org.apache.ignite.cache.CacheMode' + }, + atomicityMode: { + clsName: 'org.apache.ignite.cache.CacheAtomicityMode' + }, + memoryMode: { + clsName: 'org.apache.ignite.cache.CacheMemoryMode', + value: 'ONHEAP_TIERED' + }, + offHeapMaxMemory: -1, + startSize: 1500000, + swapEnabled: false, + sqlOnheapRowCacheSize: 10240, + longQueryWarningTimeout: 3000, + snapshotableIndex: false, + sqlEscapeAll: false, + storeKeepBinary: false, + loadPreviousValue: false, + cacheStoreFactory: { + CacheJdbcPojoStoreFactory: { + batchSize: 512, + maximumWriteAttempts: 2, + parallelLoadCacheMinimumThreshold: 512, + sqlEscapeAll: false + } + }, + readThrough: false, + writeThrough: false, + writeBehindEnabled: false, + writeBehindBatchSize: 512, + writeBehindFlushSize: 10240, + writeBehindFlushFrequency: 5000, + writeBehindFlushThreadCount: 1, + maxConcurrentAsyncOperations: 500, + defaultLockTimeout: 0, + atomicWriteOrderMode: { + clsName: 'org.apache.ignite.cache.CacheAtomicWriteOrderMode' + }, + writeSynchronizationMode: { + clsName: 'org.apache.ignite.cache.CacheWriteSynchronizationMode', + value: 'PRIMARY_SYNC' + }, + rebalanceMode: { + clsName: 'org.apache.ignite.cache.CacheRebalanceMode', + value: 'ASYNC' + }, + rebalanceThreadPoolSize: 1, + rebalanceBatchSize: 524288, + rebalanceBatchesPrefetchCount: 2, + rebalanceOrder: 0, + rebalanceDelay: 0, + rebalanceTimeout: 10000, + rebalanceThrottle: 0, + statisticsEnabled: false, + managementEnabled: false, + nearConfiguration: { + nearStartSize: 375000 + }, + clientNearConfiguration: { + nearStartSize: 375000 + }, + evictionPolicy: { + LRU: { + batchSize: 1, + maxSize: 100000 + }, + FIFO: { + batchSize: 1, + maxSize: 100000 + }, + SORTED: { + batchSize: 1, + maxSize: 100000 + } + }, + queryMetadata: 'Configuration', + fields: { + keyClsName: 'java.lang.String', + valClsName: 'java.lang.String', + valField: 'className', + entries: [] + }, + aliases: { + keyClsName: 'java.lang.String', + valClsName: 'java.lang.String', + keyField: 'field', + valField: 'alias', + entries: [] + }, + indexes: { + indexType: { + clsName: 'org.apache.ignite.cache.QueryIndexType' + }, + fields: { + keyClsName: 'java.lang.String', + valClsName: 'java.lang.Boolean', + valField: 'direction', + entries: [] + } + }, + typeField: { + databaseFieldType: { + clsName: 'java.sql.Types' + } + } +}; + +export default class IgniteCacheDefaults { + constructor() { + Object.assign(this, DFLT_CACHE); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.platform.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.platform.service.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.platform.service.js new file mode 100644 index 0000000..b701951 --- /dev/null +++ b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.platform.service.js @@ -0,0 +1,43 @@ +/* + * 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. + */ + +const enumValueMapper = (val) => _.capitalize(val); + +const DFLT_CLUSTER = { + atomics: { + cacheMode: { + clsName: 'Apache.Ignite.Core.Cache.Configuration.CacheMode', + mapper: enumValueMapper + } + }, + transactionConfiguration: { + defaultTxConcurrency: { + clsName: 'Apache.Ignite.Core.Transactions.TransactionConcurrency', + mapper: enumValueMapper + }, + defaultTxIsolation: { + clsName: 'Apache.Ignite.Core.Transactions.TransactionIsolation', + mapper: enumValueMapper + } + } +}; + +export default class IgniteClusterPlatformDefaults { + constructor() { + Object.assign(this, DFLT_CLUSTER); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.service.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.service.js new file mode 100644 index 0000000..6333ef9 --- /dev/null +++ b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Cluster.service.js @@ -0,0 +1,289 @@ +/* + * 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. + */ + +const DFLT_CLUSTER = { + localHost: '0.0.0.0', + discovery: { + localPort: 47500, + localPortRange: 100, + socketTimeout: 5000, + ackTimeout: 5000, + maxAckTimeout: 600000, + networkTimeout: 5000, + joinTimeout: 0, + threadPriority: 10, + heartbeatFrequency: 2000, + maxMissedHeartbeats: 1, + maxMissedClientHeartbeats: 5, + topHistorySize: 1000, + reconnectCount: 10, + statisticsPrintFrequency: 0, + ipFinderCleanFrequency: 60000, + forceServerMode: false, + clientReconnectDisabled: false, + Multicast: { + multicastGroup: '228.1.2.4', + multicastPort: 47400, + responseWaitTime: 500, + addressRequestAttempts: 2, + localAddress: '0.0.0.0' + }, + Jdbc: { + initSchema: false + }, + SharedFs: { + path: 'disco/tcp' + }, + ZooKeeper: { + basePath: '/services', + serviceName: 'ignite', + allowDuplicateRegistrations: false, + ExponentialBackoff: { + baseSleepTimeMs: 1000, + maxRetries: 10 + }, + BoundedExponentialBackoffRetry: { + baseSleepTimeMs: 1000, + maxSleepTimeMs: 2147483647, + maxRetries: 10 + }, + UntilElapsed: { + maxElapsedTimeMs: 60000, + sleepMsBetweenRetries: 1000 + }, + RetryNTimes: { + n: 10, + sleepMsBetweenRetries: 1000 + }, + OneTime: { + sleepMsBetweenRetry: 1000 + }, + Forever: { + retryIntervalMs: 1000 + } + } + }, + atomics: { + atomicSequenceReserveSize: 1000, + backups: 0, + cacheMode: { + clsName: 'org.apache.ignite.cache.CacheMode', + value: 'PARTITIONED' + } + }, + binary: { + compactFooter: true, + typeConfigurations: { + enum: false + } + }, + collision: { + kind: null, + JobStealing: { + activeJobsThreshold: 95, + waitJobsThreshold: 0, + messageExpireTime: 1000, + maximumStealingAttempts: 5, + stealingEnabled: true, + stealingAttributes: { + keyClsName: 'java.lang.String', + valClsName: 'java.io.Serializable', + items: [] + } + }, + PriorityQueue: { + priorityAttributeKey: 'grid.task.priority', + jobPriorityAttributeKey: 'grid.job.priority', + defaultPriority: 0, + starvationIncrement: 1, + starvationPreventionEnabled: true + } + }, + communication: { + localPort: 47100, + localPortRange: 100, + sharedMemoryPort: 48100, + directBuffer: false, + directSendBuffer: false, + idleConnectionTimeout: 30000, + connectTimeout: 5000, + maxConnectTimeout: 600000, + reconnectCount: 10, + socketSendBuffer: 32768, + socketReceiveBuffer: 32768, + messageQueueLimit: 1024, + tcpNoDelay: true, + ackSendThreshold: 16, + unacknowledgedMessagesBufferSize: 0, + socketWriteTimeout: 2000 + }, + networkTimeout: 5000, + networkSendRetryDelay: 1000, + networkSendRetryCount: 3, + discoveryStartupDelay: 60000, + connector: { + port: 11211, + portRange: 100, + idleTimeout: 7000, + idleQueryCursorTimeout: 600000, + idleQueryCursorCheckFrequency: 60000, + receiveBufferSize: 32768, + sendBufferSize: 32768, + sendQueueLimit: 0, + directBuffer: false, + noDelay: true, + sslEnabled: false, + sslClientAuth: false + }, + deploymentMode: { + clsName: 'org.apache.ignite.configuration.DeploymentMode', + value: 'SHARED' + }, + peerClassLoadingEnabled: false, + peerClassLoadingMissedResourcesCacheSize: 100, + peerClassLoadingThreadPoolSize: 2, + failoverSpi: { + JobStealing: { + maximumFailoverAttempts: 5 + }, + Always: { + maximumFailoverAttempts: 5 + } + }, + logger: { + Log4j: { + level: { + clsName: 'org.apache.log4j.Level' + } + }, + Log4j2: { + level: { + clsName: 'org.apache.logging.log4j.Level' + } + } + }, + marshalLocalJobs: false, + marshallerCacheKeepAliveTime: 10000, + metricsHistorySize: 10000, + metricsLogFrequency: 60000, + metricsUpdateFrequency: 2000, + clockSyncSamples: 8, + clockSyncFrequency: 120000, + timeServerPortBase: 31100, + timeServerPortRange: 100, + transactionConfiguration: { + defaultTxConcurrency: { + clsName: 'org.apache.ignite.transactions.TransactionConcurrency', + value: 'PESSIMISTIC' + }, + defaultTxIsolation: { + clsName: 'org.apache.ignite.transactions.TransactionIsolation', + value: 'REPEATABLE_READ' + }, + defaultTxTimeout: 0, + pessimisticTxLogLinger: 10000 + }, + attributes: { + keyClsName: 'java.lang.String', + valClsName: 'java.lang.String', + items: [] + }, + odbcConfiguration: { + endpointAddress: '0.0.0.0:10800..10810', + maxOpenCursors: 128 + }, + eventStorage: { + Memory: { + expireCount: 10000 + } + }, + checkpointSpi: { + S3: { + bucketNameSuffix: 'default-bucket', + clientConfiguration: { + protocol: { + clsName: 'com.amazonaws.Protocol', + value: 'HTTPS' + }, + maxConnections: 50, + retryPolicy: { + retryCondition: { + clsName: 'com.amazonaws.retry.PredefinedRetryPolicies' + }, + backoffStrategy: { + clsName: 'com.amazonaws.retry.PredefinedRetryPolicies' + }, + maxErrorRetry: { + clsName: 'com.amazonaws.retry.PredefinedRetryPolicies' + } + }, + maxErrorRetry: -1, + socketTimeout: 50000, + connectionTimeout: 50000, + requestTimeout: 0, + socketSendBufferSizeHints: 0, + connectionTTL: -1, + connectionMaxIdleMillis: 60000, + responseMetadataCacheSize: 50, + useReaper: true, + useGzip: false, + preemptiveBasicProxyAuth: false, + useTcpKeepAlive: false + } + }, + JDBC: { + checkpointTableName: 'CHECKPOINTS', + keyFieldName: 'NAME', + keyFieldType: 'VARCHAR', + valueFieldName: 'VALUE', + valueFieldType: 'BLOB', + expireDateFieldName: 'EXPIRE_DATE', + expireDateFieldType: 'DATETIME', + numberOfRetries: 2 + } + }, + loadBalancingSpi: { + RoundRobin: { + perTask: false + }, + Adaptive: { + loadProbe: { + Job: { + useAverage: true + }, + CPU: { + useAverage: true, + useProcessors: true, + processorCoefficient: 1 + }, + ProcessingTime: { + useAverage: true + } + } + }, + WeightedRandom: { + nodeWeight: 10, + useWeights: false + } + } +}; + +export default class IgniteClusterDefaults { + constructor() { + Object.assign(this, DFLT_CLUSTER); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/Event-groups.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/Event-groups.service.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Event-groups.service.js new file mode 100644 index 0000000..315da1f --- /dev/null +++ b/modules/web-console/frontend/app/modules/configuration/generator/defaults/Event-groups.service.js @@ -0,0 +1,27 @@ +/* + * 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. + */ + +import _ from 'lodash'; + +// Events groups. +import EVENT_GROUPS from 'app/data/event-groups.json'; + +export default class IgniteEventGroups { + constructor() { + return _.clone(EVENT_GROUPS); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/IGFS.service.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/IGFS.service.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/IGFS.service.js new file mode 100644 index 0000000..985a56e --- /dev/null +++ b/modules/web-console/frontend/app/modules/configuration/generator/defaults/IGFS.service.js @@ -0,0 +1,64 @@ +/* + * 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. + */ + +const DFLT_IGFS = { + defaultMode: { + clsName: 'org.apache.ignite.igfs.IgfsMode', + value: 'DUAL_ASYNC' + }, + secondaryFileSystem: { + + }, + ipcEndpointConfiguration: { + type: { + clsName: 'org.apache.ignite.igfs.IgfsIpcEndpointType' + }, + host: '127.0.0.1', + port: 10500, + memorySize: 262144, + tokenDirectoryPath: 'ipc/shmem' + }, + fragmentizerConcurrentFiles: 0, + fragmentizerThrottlingBlockLength: 16777216, + fragmentizerThrottlingDelay: 200, + dualModeMaxPendingPutsSize: 0, + dualModePutExecutorServiceShutdown: false, + blockSize: 65536, + streamBufferSize: 65536, + maxSpaceSize: 0, + maximumTaskRangeLength: 0, + managementPort: 11400, + perNodeBatchSize: 100, + perNodeParallelBatchCount: 8, + prefetchBlocks: 0, + sequentialReadsBeforePrefetch: 0, + trashPurgeTimeout: 1000, + colocateMetadata: true, + relaxedConsistency: true, + pathModes: { + keyClsName: 'java.lang.String', + keyField: 'path', + valClsName: 'org.apache.ignite.igfs.IgfsMode', + valField: 'mode' + } +}; + +export default class IgniteIGFSDefaults { + constructor() { + Object.assign(this, DFLT_IGFS); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.platform.provider.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.platform.provider.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.platform.provider.js deleted file mode 100644 index f06e11b..0000000 --- a/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.platform.provider.js +++ /dev/null @@ -1,60 +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. - */ - -import _ from 'lodash'; - -const enumValueMapper = (val) => _.capitalize(val); - -const DFLT_CACHE = { - cacheMode: { - clsName: 'Apache.Ignite.Core.Cache.Configuration.CacheMode', - mapper: enumValueMapper - }, - atomicityMode: { - clsName: 'Apache.Ignite.Core.Cache.Configuration.CacheAtomicityMode', - mapper: enumValueMapper - }, - memoryMode: { - clsName: 'Apache.Ignite.Core.Cache.Configuration.CacheMemoryMode', - value: 'ONHEAP_TIERED', - mapper: enumValueMapper - }, - atomicWriteOrderMode: { - clsName: 'org.apache.ignite.cache.CacheAtomicWriteOrderMode', - mapper: enumValueMapper - }, - writeSynchronizationMode: { - clsName: 'org.apache.ignite.cache.CacheWriteSynchronizationMode', - value: 'PRIMARY_SYNC', - mapper: enumValueMapper - }, - rebalanceMode: { - clsName: 'org.apache.ignite.cache.CacheRebalanceMode', - value: 'ASYNC', - mapper: enumValueMapper - } -}; - -export default function() { - this.append = (dflts) => { - _.merge(DFLT_CACHE, dflts); - }; - - this.$get = ['igniteCacheDefaults', (cacheDefaults) => { - return _.merge({}, cacheDefaults, DFLT_CACHE); - }]; -} http://git-wip-us.apache.org/repos/asf/ignite/blob/2b3a180f/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.provider.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.provider.js b/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.provider.js deleted file mode 100644 index f50e493..0000000 --- a/modules/web-console/frontend/app/modules/configuration/generator/defaults/cache.provider.js +++ /dev/null @@ -1,137 +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. - */ - -import _ from 'lodash'; - -const DFLT_CACHE = { - cacheMode: { - clsName: 'org.apache.ignite.cache.CacheMode' - }, - atomicityMode: { - clsName: 'org.apache.ignite.cache.CacheAtomicityMode' - }, - memoryMode: { - clsName: 'org.apache.ignite.cache.CacheMemoryMode', - value: 'ONHEAP_TIERED' - }, - offHeapMaxMemory: -1, - startSize: 1500000, - swapEnabled: false, - sqlOnheapRowCacheSize: 10240, - longQueryWarningTimeout: 3000, - snapshotableIndex: false, - sqlEscapeAll: false, - storeKeepBinary: false, - loadPreviousValue: false, - cacheStoreFactory: { - CacheJdbcPojoStoreFactory: { - batchSize: 512, - maximumWriteAttempts: 2, - parallelLoadCacheMinimumThreshold: 512, - sqlEscapeAll: false - } - }, - readThrough: false, - writeThrough: false, - writeBehindEnabled: false, - writeBehindBatchSize: 512, - writeBehindFlushSize: 10240, - writeBehindFlushFrequency: 5000, - writeBehindFlushThreadCount: 1, - maxConcurrentAsyncOperations: 500, - defaultLockTimeout: 0, - atomicWriteOrderMode: { - clsName: 'org.apache.ignite.cache.CacheAtomicWriteOrderMode' - }, - writeSynchronizationMode: { - clsName: 'org.apache.ignite.cache.CacheWriteSynchronizationMode', - value: 'PRIMARY_SYNC' - }, - rebalanceMode: { - clsName: 'org.apache.ignite.cache.CacheRebalanceMode', - value: 'ASYNC' - }, - rebalanceThreadPoolSize: 1, - rebalanceBatchSize: 524288, - rebalanceBatchesPrefetchCount: 2, - rebalanceOrder: 0, - rebalanceDelay: 0, - rebalanceTimeout: 10000, - rebalanceThrottle: 0, - statisticsEnabled: false, - managementEnabled: false, - nearConfiguration: { - nearStartSize: 375000 - }, - clientNearConfiguration: { - nearStartSize: 375000 - }, - evictionPolicy: { - LRU: { - batchSize: 1, - maxSize: 100000 - }, - FIFO: { - batchSize: 1, - maxSize: 100000 - }, - SORTED: { - batchSize: 1, - maxSize: 100000 - } - }, - queryMetadata: 'Configuration', - fields: { - keyClsName: 'java.lang.String', - valClsName: 'java.lang.String', - valField: 'className', - entries: [] - }, - aliases: { - keyClsName: 'java.lang.String', - valClsName: 'java.lang.String', - keyField: 'field', - valField: 'alias', - entries: [] - }, - indexes: { - indexType: { - clsName: 'org.apache.ignite.cache.QueryIndexType' - }, - fields: { - keyClsName: 'java.lang.String', - valClsName: 'java.lang.Boolean', - valField: 'direction', - entries: [] - } - }, - typeField: { - databaseFieldType: { - clsName: 'java.sql.Types' - } - } -}; - -export default function() { - this.append = (dflts) => { - _.merge(DFLT_CACHE, dflts); - }; - - this.$get = [() => { - return DFLT_CACHE; - }]; -}