http://git-wip-us.apache.org/repos/asf/ignite/blob/8e7c852b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js ---------------------------------------------------------------------- diff --git a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js index 5887832..8770bf6 100644 --- a/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js +++ b/modules/web-console/frontend/app/modules/configuration/generator/ConfigurationGenerator.js @@ -19,1776 +19,1825 @@ import DFLT_DIALECTS from 'app/data/dialects.json'; import { EmptyBean, Bean } from './Beans'; -export default ['JavaTypes', 'igniteClusterDefaults', 'igniteCacheDefaults', 'igniteIgfsDefaults', (JavaTypes, clusterDflts, cacheDflts, igfsDflts) => { - class ConfigurationGenerator { - static igniteConfigurationBean(cluster) { - return new Bean('org.apache.ignite.configuration.IgniteConfiguration', 'cfg', cluster, clusterDflts); - } +import IgniteClusterDefaults from './defaults/Cluster.service'; +import IgniteCacheDefaults from './defaults/Cache.service'; +import IgniteIGFSDefaults from './defaults/IGFS.service'; - static igfsConfigurationBean(igfs) { - return new Bean('org.apache.ignite.configuration.FileSystemConfiguration', 'igfs', igfs, igfsDflts); - } +import JavaTypes from '../../../services/JavaTypes.service'; - static cacheConfigurationBean(cache) { - return new Bean('org.apache.ignite.configuration.CacheConfiguration', 'ccfg', cache, cacheDflts); - } +const clusterDflts = new IgniteClusterDefaults(); +const cacheDflts = new IgniteCacheDefaults(); +const igfsDflts = new IgniteIGFSDefaults(); - static domainConfigurationBean(domain) { - return new Bean('org.apache.ignite.cache.QueryEntity', 'qryEntity', domain, cacheDflts); - } +const javaTypes = new JavaTypes(clusterDflts, cacheDflts, igfsDflts); - static discoveryConfigurationBean(discovery) { - return new Bean('org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi', 'discovery', discovery, clusterDflts.discovery); - } +export default class IgniteConfigurationGenerator { + static igniteConfigurationBean(cluster) { + return new Bean('org.apache.ignite.configuration.IgniteConfiguration', 'cfg', cluster, clusterDflts); + } - /** - * Function to generate ignite configuration. - * - * @param {Object} cluster Cluster to process. - * @param {Boolean} client - * @return {Bean} Generated ignite configuration. - */ - static igniteConfiguration(cluster, client) { - const cfg = this.igniteConfigurationBean(cluster); - - this.clusterGeneral(cluster, cfg, client); - this.clusterAtomics(cluster.atomicConfiguration, cfg); - this.clusterBinary(cluster.binaryConfiguration, cfg); - this.clusterCacheKeyConfiguration(cluster.cacheKeyConfiguration, cfg); - this.clusterCheckpoint(cluster, cluster.caches, cfg); - this.clusterCollision(cluster.collision, cfg); - this.clusterCommunication(cluster, cfg); - this.clusterConnector(cluster.connector, cfg); - this.clusterDeployment(cluster, cfg); - this.clusterEvents(cluster, cfg); - this.clusterFailover(cluster, cfg); - this.clusterLoadBalancing(cluster, cfg); - this.clusterLogger(cluster.logger, cfg); - this.clusterODBC(cluster.odbc, cfg); - this.clusterMarshaller(cluster, cfg); - this.clusterMetrics(cluster, cfg); - this.clusterSwap(cluster, cfg); - this.clusterTime(cluster, cfg); - this.clusterPools(cluster, cfg); - this.clusterTransactions(cluster.transactionConfiguration, cfg); - this.clusterSsl(cluster, cfg); - this.clusterUserAttributes(cluster, cfg); - - this.clusterCaches(cluster, cluster.caches, cluster.igfss, client, cfg); - - if (!client) - this.clusterIgfss(cluster.igfss, cfg); + static igfsConfigurationBean(igfs) { + return new Bean('org.apache.ignite.configuration.FileSystemConfiguration', 'igfs', igfs, igfsDflts); + } - return cfg; - } + static cacheConfigurationBean(cache) { + return new Bean('org.apache.ignite.configuration.CacheConfiguration', 'ccfg', cache, cacheDflts); + } - static dialectClsName(dialect) { - return DFLT_DIALECTS[dialect] || 'Unknown database: ' + (dialect || 'Choose JDBC dialect'); - } + static domainConfigurationBean(domain) { + return new Bean('org.apache.ignite.cache.QueryEntity', 'qryEntity', domain, cacheDflts); + } - static dataSourceBean(id, dialect) { - let dsBean; + static discoveryConfigurationBean(discovery) { + return new Bean('org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi', 'discovery', discovery, clusterDflts.discovery); + } - switch (dialect) { - case 'Generic': - dsBean = new Bean('com.mchange.v2.c3p0.ComboPooledDataSource', id, {}) - .property('jdbcUrl', `${id}.jdbc.url`, 'jdbc:your_database'); + /** + * Function to generate ignite configuration. + * + * @param {Object} cluster Cluster to process. + * @param {Boolean} client + * @return {Bean} Generated ignite configuration. + */ + static igniteConfiguration(cluster, client) { + const cfg = this.igniteConfigurationBean(cluster); + + this.clusterGeneral(cluster, cfg, client); + this.clusterAtomics(cluster.atomicConfiguration, cfg); + this.clusterBinary(cluster.binaryConfiguration, cfg); + this.clusterCacheKeyConfiguration(cluster.cacheKeyConfiguration, cfg); + this.clusterCheckpoint(cluster, cluster.caches, cfg); + this.clusterCollision(cluster.collision, cfg); + this.clusterCommunication(cluster, cfg); + this.clusterConnector(cluster.connector, cfg); + this.clusterDeployment(cluster, cfg); + this.clusterEvents(cluster, cfg); + this.clusterFailover(cluster, cfg); + this.clusterLoadBalancing(cluster, cfg); + this.clusterLogger(cluster.logger, cfg); + this.clusterODBC(cluster.odbc, cfg); + this.clusterMarshaller(cluster, cfg); + this.clusterMetrics(cluster, cfg); + this.clusterSwap(cluster, cfg); + this.clusterTime(cluster, cfg); + this.clusterPools(cluster, cfg); + this.clusterTransactions(cluster.transactionConfiguration, cfg); + this.clusterSsl(cluster, cfg); + this.clusterUserAttributes(cluster, cfg); + + this.clusterCaches(cluster, cluster.caches, cluster.igfss, client, cfg); + + if (!client) + this.clusterIgfss(cluster.igfss, cfg); + + return cfg; + } - break; - case 'Oracle': - dsBean = new Bean('oracle.jdbc.pool.OracleDataSource', id, {}) - .property('URL', `${id}.jdbc.url`, 'jdbc:oracle:thin:@[host]:[port]:[database]'); + static dialectClsName(dialect) { + return DFLT_DIALECTS[dialect] || 'Unknown database: ' + (dialect || 'Choose JDBC dialect'); + } - break; - case 'DB2': - dsBean = new Bean('com.ibm.db2.jcc.DB2DataSource', id, {}) - .property('serverName', `${id}.jdbc.server_name`, 'YOUR_DATABASE_SERVER_NAME') - .propertyInt('portNumber', `${id}.jdbc.port_number`, 'YOUR_JDBC_PORT_NUMBER') - .property('databaseName', `${id}.jdbc.database_name`, 'YOUR_DATABASE_NAME') - .propertyInt('driverType', `${id}.jdbc.driver_type`, 'YOUR_JDBC_DRIVER_TYPE'); + static dataSourceBean(id, dialect) { + let dsBean; + + switch (dialect) { + case 'Generic': + dsBean = new Bean('com.mchange.v2.c3p0.ComboPooledDataSource', id, {}) + .property('jdbcUrl', `${id}.jdbc.url`, 'jdbc:your_database'); + + break; + case 'Oracle': + dsBean = new Bean('oracle.jdbc.pool.OracleDataSource', id, {}) + .property('URL', `${id}.jdbc.url`, 'jdbc:oracle:thin:@[host]:[port]:[database]'); + + break; + case 'DB2': + dsBean = new Bean('com.ibm.db2.jcc.DB2DataSource', id, {}) + .property('serverName', `${id}.jdbc.server_name`, 'YOUR_DATABASE_SERVER_NAME') + .propertyInt('portNumber', `${id}.jdbc.port_number`, 'YOUR_JDBC_PORT_NUMBER') + .property('databaseName', `${id}.jdbc.database_name`, 'YOUR_DATABASE_NAME') + .propertyInt('driverType', `${id}.jdbc.driver_type`, 'YOUR_JDBC_DRIVER_TYPE'); + + break; + case 'SQLServer': + dsBean = new Bean('com.microsoft.sqlserver.jdbc.SQLServerDataSource', id, {}) + .property('URL', `${id}.jdbc.url`, 'jdbc:sqlserver://[host]:[port][;databaseName=database]'); + + break; + case 'MySQL': + dsBean = new Bean('com.mysql.jdbc.jdbc2.optional.MysqlDataSource', id, {}) + .property('URL', `${id}.jdbc.url`, 'jdbc:mysql://[host]:[port]/[database]'); + + break; + case 'PostgreSQL': + dsBean = new Bean('org.postgresql.ds.PGPoolingDataSource', id, {}) + .property('url', `${id}.jdbc.url`, 'jdbc:postgresql://[host]:[port]/[database]'); + + break; + case 'H2': + dsBean = new Bean('org.h2.jdbcx.JdbcDataSource', id, {}) + .property('URL', `${id}.jdbc.url`, 'jdbc:h2:tcp://[host]/[database]'); + + break; + default: + } - break; - case 'SQLServer': - dsBean = new Bean('com.microsoft.sqlserver.jdbc.SQLServerDataSource', id, {}) - .property('URL', `${id}.jdbc.url`, 'jdbc:sqlserver://[host]:[port][;databaseName=database]'); + if (dsBean) { + dsBean.property('user', `${id}.jdbc.username`, 'YOUR_USER_NAME') + .property('password', `${id}.jdbc.password`, 'YOUR_PASSWORD'); + } - break; - case 'MySQL': - dsBean = new Bean('com.mysql.jdbc.jdbc2.optional.MysqlDataSource', id, {}) - .property('URL', `${id}.jdbc.url`, 'jdbc:mysql://[host]:[port]/[database]'); + return dsBean; + } - break; - case 'PostgreSQL': - dsBean = new Bean('org.postgresql.ds.PGPoolingDataSource', id, {}) - .property('url', `${id}.jdbc.url`, 'jdbc:postgresql://[host]:[port]/[database]'); + // Generate general section. + static clusterGeneral(cluster, cfg = this.igniteConfigurationBean(cluster), client = false) { + if (client) + cfg.prop('boolean', 'clientMode', true); - break; - case 'H2': - dsBean = new Bean('org.h2.jdbcx.JdbcDataSource', id, {}) - .property('URL', `${id}.jdbc.url`, 'jdbc:h2:tcp://[host]/[database]'); + cfg.stringProperty('name', 'gridName') + .stringProperty('localHost'); - break; - default: - } - - if (dsBean) { - dsBean.property('user', `${id}.jdbc.username`, 'YOUR_USER_NAME') - .property('password', `${id}.jdbc.password`, 'YOUR_PASSWORD'); - } + if (_.isNil(cluster.discovery)) + return cfg; - return dsBean; - } + const discovery = new Bean('org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi', 'discovery', + cluster.discovery, clusterDflts.discovery); - // Generate general section. - static clusterGeneral(cluster, cfg = this.igniteConfigurationBean(cluster), client = false) { - if (client) - cfg.prop('boolean', 'clientMode', true); + let ipFinder; - cfg.stringProperty('name', 'gridName') - .stringProperty('localHost'); + switch (discovery.valueOf('kind')) { + case 'Vm': + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder', + 'ipFinder', cluster.discovery.Vm, clusterDflts.discovery.Vm); - if (_.isNil(cluster.discovery)) - return cfg; + ipFinder.collectionProperty('addrs', 'addresses', cluster.discovery.Vm.addresses); - const discovery = new Bean('org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi', 'discovery', - cluster.discovery, clusterDflts.discovery); + break; + case 'Multicast': + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder', + 'ipFinder', cluster.discovery.Multicast, clusterDflts.discovery.Multicast); - let ipFinder; + ipFinder.stringProperty('multicastGroup') + .intProperty('multicastPort') + .intProperty('responseWaitTime') + .intProperty('addressRequestAttempts') + .stringProperty('localAddress') + .collectionProperty('addrs', 'addresses', cluster.discovery.Multicast.addresses); - switch (discovery.valueOf('kind')) { - case 'Vm': - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder', - 'ipFinder', cluster.discovery.Vm, clusterDflts.discovery.Vm); + break; + case 'S3': + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder', + 'ipFinder', cluster.discovery.S3, clusterDflts.discovery.S3); - ipFinder.collectionProperty('addrs', 'addresses', cluster.discovery.Vm.addresses); + ipFinder.stringProperty('bucketName'); - break; - case 'Multicast': - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder', - 'ipFinder', cluster.discovery.Multicast, clusterDflts.discovery.Multicast); + break; + case 'Cloud': + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder', + 'ipFinder', cluster.discovery.Cloud, clusterDflts.discovery.Cloud); - ipFinder.stringProperty('multicastGroup') - .intProperty('multicastPort') - .intProperty('responseWaitTime') - .intProperty('addressRequestAttempts') - .stringProperty('localAddress') - .collectionProperty('addrs', 'addresses', cluster.discovery.Multicast.addresses); + ipFinder.stringProperty('credential') + .pathProperty('credentialPath') + .stringProperty('identity') + .stringProperty('provider') + .collectionProperty('regions', 'regions', cluster.discovery.Cloud.regions) + .collectionProperty('zones', 'zones', cluster.discovery.Cloud.zones); - break; - case 'S3': - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.s3.TcpDiscoveryS3IpFinder', - 'ipFinder', cluster.discovery.S3, clusterDflts.discovery.S3); + break; + case 'GoogleStorage': + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder', + 'ipFinder', cluster.discovery.GoogleStorage, clusterDflts.discovery.GoogleStorage); - ipFinder.stringProperty('bucketName'); + ipFinder.stringProperty('projectName') + .stringProperty('bucketName') + .pathProperty('serviceAccountP12FilePath') + .stringProperty('serviceAccountId'); - break; - case 'Cloud': - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.cloud.TcpDiscoveryCloudIpFinder', - 'ipFinder', cluster.discovery.Cloud, clusterDflts.discovery.Cloud); + break; + case 'Jdbc': + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder', + 'ipFinder', cluster.discovery.Jdbc, clusterDflts.discovery.Jdbc); - ipFinder.stringProperty('credential') - .pathProperty('credentialPath') - .stringProperty('identity') - .stringProperty('provider') - .collectionProperty('regions', 'regions', cluster.discovery.Cloud.regions) - .collectionProperty('zones', 'zones', cluster.discovery.Cloud.zones); + ipFinder.intProperty('initSchema'); - break; - case 'GoogleStorage': - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.gce.TcpDiscoveryGoogleStorageIpFinder', - 'ipFinder', cluster.discovery.GoogleStorage, clusterDflts.discovery.GoogleStorage); + if (ipFinder.includes('dataSourceBean', 'dialect')) { + const id = ipFinder.valueOf('dataSourceBean'); - ipFinder.stringProperty('projectName') - .stringProperty('bucketName') - .pathProperty('serviceAccountP12FilePath') - .stringProperty('serviceAccountId'); + ipFinder.dataSource(id, 'dataSource', this.dataSourceBean(id, ipFinder.valueOf('dialect'))); + } - break; - case 'Jdbc': - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder', - 'ipFinder', cluster.discovery.Jdbc, clusterDflts.discovery.Jdbc); + break; + case 'SharedFs': + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder', + 'ipFinder', cluster.discovery.SharedFs, clusterDflts.discovery.SharedFs); + + ipFinder.pathProperty('path'); + + break; + case 'ZooKeeper': + const src = cluster.discovery.ZooKeeper; + const dflt = clusterDflts.discovery.ZooKeeper; + + ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder', + 'ipFinder', src, dflt); + + ipFinder.emptyBeanProperty('curator') + .stringProperty('zkConnectionString'); + + const kind = _.get(src, 'retryPolicy.kind'); + + if (kind) { + const policy = src.retryPolicy; + + let retryPolicyBean; + + switch (kind) { + case 'ExponentialBackoff': + retryPolicyBean = new Bean('org.apache.curator.retry.ExponentialBackoffRetry', null, + policy.ExponentialBackoff, dflt.ExponentialBackoff) + .intConstructorArgument('baseSleepTimeMs') + .intConstructorArgument('maxRetries') + .intConstructorArgument('maxSleepMs'); + + break; + case 'BoundedExponentialBackoff': + retryPolicyBean = new Bean('org.apache.curator.retry.BoundedExponentialBackoffRetry', + null, policy.BoundedExponentialBackoff, dflt.BoundedExponentialBackoffRetry) + .intConstructorArgument('baseSleepTimeMs') + .intConstructorArgument('maxSleepTimeMs') + .intConstructorArgument('maxRetries'); + + break; + case 'UntilElapsed': + retryPolicyBean = new Bean('org.apache.curator.retry.RetryUntilElapsed', null, + policy.UntilElapsed, dflt.UntilElapsed) + .intConstructorArgument('maxElapsedTimeMs') + .intConstructorArgument('sleepMsBetweenRetries'); + + break; + + case 'NTimes': + retryPolicyBean = new Bean('org.apache.curator.retry.RetryNTimes', null, + policy.NTimes, dflt.NTimes) + .intConstructorArgument('n') + .intConstructorArgument('sleepMsBetweenRetries'); + + break; + case 'OneTime': + retryPolicyBean = new Bean('org.apache.curator.retry.RetryOneTime', null, + policy.OneTime, dflt.OneTime) + .intConstructorArgument('sleepMsBetweenRetry'); + + break; + case 'Forever': + retryPolicyBean = new Bean('org.apache.curator.retry.RetryForever', null, + policy.Forever, dflt.Forever) + .intConstructorArgument('retryIntervalMs'); + + break; + case 'Custom': + const className = _.get(policy, 'Custom.className'); + + if (_.nonEmpty(className)) + retryPolicyBean = new EmptyBean(className); + + break; + default: + // No-op. + } - ipFinder.intProperty('initSchema'); + if (retryPolicyBean) + ipFinder.beanProperty('retryPolicy', retryPolicyBean); + } - if (ipFinder.includes('dataSourceBean', 'dialect')) { - const id = ipFinder.valueOf('dataSourceBean'); + ipFinder.pathProperty('basePath', '/services') + .stringProperty('serviceName') + .boolProperty('allowDuplicateRegistrations'); - ipFinder.dataSource(id, 'dataSource', this.dataSourceBean(id, ipFinder.valueOf('dialect'))); - } + break; + default: + // No-op. + } - break; - case 'SharedFs': - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.sharedfs.TcpDiscoverySharedFsIpFinder', - 'ipFinder', cluster.discovery.SharedFs, clusterDflts.discovery.SharedFs); + if (ipFinder) + discovery.beanProperty('ipFinder', ipFinder); - ipFinder.pathProperty('path'); + this.clusterDiscovery(cluster.discovery, cfg, discovery); - break; - case 'ZooKeeper': - const src = cluster.discovery.ZooKeeper; - const dflt = clusterDflts.discovery.ZooKeeper; + return cfg; + } - ipFinder = new Bean('org.apache.ignite.spi.discovery.tcp.ipfinder.zk.TcpDiscoveryZookeeperIpFinder', - 'ipFinder', src, dflt); + static igfsDataCache(igfs) { + return this.cacheConfiguration({ + name: igfs.name + '-data', + cacheMode: 'PARTITIONED', + atomicityMode: 'TRANSACTIONAL', + writeSynchronizationMode: 'FULL_SYNC', + backups: 0, + igfsAffinnityGroupSize: igfs.affinnityGroupSize || 512 + }); + } - ipFinder.emptyBeanProperty('curator') - .stringProperty('zkConnectionString'); + static igfsMetaCache(igfs) { + return this.cacheConfiguration({ + name: igfs.name + '-meta', + cacheMode: 'REPLICATED', + atomicityMode: 'TRANSACTIONAL', + writeSynchronizationMode: 'FULL_SYNC' + }); + } - const kind = _.get(src, 'retryPolicy.kind'); + static clusterCaches(cluster, caches, igfss, client, cfg = this.igniteConfigurationBean(cluster)) { + const ccfgs = _.map(caches, (cache) => this.cacheConfiguration(cache)); - if (kind) { - const policy = src.retryPolicy; + if (!client) { + _.forEach(igfss, (igfs) => { + ccfgs.push(this.igfsDataCache(igfs)); + ccfgs.push(this.igfsMetaCache(igfs)); + }); + } - let retryPolicyBean; + cfg.varArgProperty('ccfgs', 'cacheConfiguration', ccfgs, 'org.apache.ignite.configuration.CacheConfiguration'); - switch (kind) { - case 'ExponentialBackoff': - retryPolicyBean = new Bean('org.apache.curator.retry.ExponentialBackoffRetry', null, - policy.ExponentialBackoff, dflt.ExponentialBackoff) - .intConstructorArgument('baseSleepTimeMs') - .intConstructorArgument('maxRetries') - .intConstructorArgument('maxSleepMs'); + return cfg; + } - break; - case 'BoundedExponentialBackoff': - retryPolicyBean = new Bean('org.apache.curator.retry.BoundedExponentialBackoffRetry', - null, policy.BoundedExponentialBackoffRetry, dflt.BoundedExponentialBackoffRetry) - .intConstructorArgument('baseSleepTimeMs') - .intConstructorArgument('maxSleepTimeMs') - .intConstructorArgument('maxRetries'); + // Generate atomics group. + static clusterAtomics(atomics, cfg = this.igniteConfigurationBean()) { + const acfg = new Bean('org.apache.ignite.configuration.AtomicConfiguration', 'atomicCfg', + atomics, clusterDflts.atomics); - break; - case 'UntilElapsed': - retryPolicyBean = new Bean('org.apache.curator.retry.RetryUntilElapsed', null, - policy.UntilElapsed, dflt.UntilElapsed) - .intConstructorArgument('maxElapsedTimeMs') - .intConstructorArgument('sleepMsBetweenRetries'); + acfg.enumProperty('cacheMode') + .intProperty('atomicSequenceReserveSize'); - break; + if (acfg.valueOf('cacheMode') === 'PARTITIONED') + acfg.intProperty('backups'); - case 'NTimes': - retryPolicyBean = new Bean('org.apache.curator.retry.RetryNTimes', null, - policy.NTimes, dflt.NTimes) - .intConstructorArgument('n') - .intConstructorArgument('sleepMsBetweenRetries'); + if (acfg.isEmpty()) + return cfg; - break; - case 'OneTime': - retryPolicyBean = new Bean('org.apache.curator.retry.RetryOneTime', null, - policy.OneTime, dflt.OneTime) - .intConstructorArgument('sleepMsBetweenRetry'); + cfg.beanProperty('atomicConfiguration', acfg); - break; - case 'Forever': - retryPolicyBean = new Bean('org.apache.curator.retry.RetryForever', null, - policy.Forever, dflt.Forever) - .intConstructorArgument('retryIntervalMs'); + return cfg; + } - break; - case 'Custom': - if (_.nonEmpty(policy.Custom.className)) - retryPolicyBean = new EmptyBean(policy.Custom.className); + // Generate binary group. + static clusterBinary(binary, cfg = this.igniteConfigurationBean()) { + const binaryCfg = new Bean('org.apache.ignite.configuration.BinaryConfiguration', 'binaryCfg', + binary, clusterDflts.binary); - break; - default: - // No-op. - } + binaryCfg.emptyBeanProperty('idMapper') + .emptyBeanProperty('nameMapper') + .emptyBeanProperty('serializer'); - if (retryPolicyBean) - ipFinder.beanProperty('retryPolicy', retryPolicyBean); - } + const typeCfgs = []; - ipFinder.pathProperty('basePath', '/services') - .stringProperty('serviceName') - .boolProperty('allowDuplicateRegistrations'); + _.forEach(binary.typeConfigurations, (type) => { + const typeCfg = new Bean('org.apache.ignite.binary.BinaryTypeConfiguration', + javaTypes.toJavaName('binaryType', type.typeName), type, clusterDflts.binary.typeConfigurations); - break; - default: - // No-op. - } + typeCfg.stringProperty('typeName') + .emptyBeanProperty('idMapper') + .emptyBeanProperty('nameMapper') + .emptyBeanProperty('serializer') + .intProperty('enum'); - if (ipFinder) - discovery.beanProperty('ipFinder', ipFinder); + if (typeCfg.nonEmpty()) + typeCfgs.push(typeCfg); + }); - this.clusterDiscovery(cluster.discovery, cfg, discovery); + binaryCfg.collectionProperty('types', 'typeConfigurations', typeCfgs, 'org.apache.ignite.binary.BinaryTypeConfiguration') + .boolProperty('compactFooter'); + if (binaryCfg.isEmpty()) return cfg; - } - - static igfsDataCache(igfs) { - return this.cacheConfiguration({ - name: igfs.name + '-data', - cacheMode: 'PARTITIONED', - atomicityMode: 'TRANSACTIONAL', - writeSynchronizationMode: 'FULL_SYNC', - backups: 0, - igfsAffinnityGroupSize: igfs.affinnityGroupSize || 512 - }); - } - static igfsMetaCache(igfs) { - return this.cacheConfiguration({ - name: igfs.name + '-meta', - cacheMode: 'REPLICATED', - atomicityMode: 'TRANSACTIONAL', - writeSynchronizationMode: 'FULL_SYNC' - }); - } + cfg.beanProperty('binaryConfiguration', binaryCfg); - static clusterCaches(cluster, caches, igfss, client, cfg = this.igniteConfigurationBean(cluster)) { - const ccfgs = _.map(caches, (cache) => this.cacheConfiguration(cache)); + return cfg; + } - if (!client) { - _.forEach(igfss, (igfs) => { - ccfgs.push(this.igfsDataCache(igfs)); - ccfgs.push(this.igfsMetaCache(igfs)); - }); + // Generate cache key configurations. + static clusterCacheKeyConfiguration(keyCfgs, cfg = this.igniteConfigurationBean()) { + const items = _.reduce(keyCfgs, (acc, keyCfg) => { + if (keyCfg.typeName && keyCfg.affinityKeyFieldName) { + acc.push(new Bean('org.apache.ignite.cache.CacheKeyConfiguration', null, keyCfg) + .stringConstructorArgument('typeName') + .stringConstructorArgument('affinityKeyFieldName')); } - cfg.varArgProperty('ccfgs', 'cacheConfiguration', ccfgs, 'org.apache.ignite.configuration.CacheConfiguration'); + return acc; + }, []); + if (_.isEmpty(items)) return cfg; - } - // Generate atomics group. - static clusterAtomics(atomics, cfg = this.igniteConfigurationBean()) { - const acfg = new Bean('org.apache.ignite.configuration.AtomicConfiguration', 'atomicCfg', - atomics, clusterDflts.atomics); + cfg.arrayProperty('cacheKeyConfiguration', 'cacheKeyConfiguration', items, + 'org.apache.ignite.cache.CacheKeyConfiguration'); - acfg.enumProperty('cacheMode') - .intProperty('atomicSequenceReserveSize'); + return cfg; + } - if (acfg.valueOf('cacheMode') === 'PARTITIONED') - acfg.intProperty('backups'); + // Generate checkpoint configurations. + static clusterCheckpoint(cluster, caches, cfg = this.igniteConfigurationBean()) { + const cfgs = _.filter(_.map(cluster.checkpointSpi, (spi) => { + switch (_.get(spi, 'kind')) { + case 'FS': + const fsBean = new Bean('org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi', + 'checkpointSpiFs', spi.FS); - if (acfg.isEmpty()) - return cfg; + fsBean.collectionProperty('directoryPaths', 'directoryPaths', _.get(spi, 'FS.directoryPaths')) + .emptyBeanProperty('checkpointListener'); - cfg.beanProperty('atomicConfiguration', acfg); + return fsBean; - return cfg; - } + case 'Cache': + const cacheBean = new Bean('org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi', + 'checkpointSpiCache', spi.Cache); - // Generate binary group. - static clusterBinary(binary, cfg = this.igniteConfigurationBean()) { - const binaryCfg = new Bean('org.apache.ignite.configuration.BinaryConfiguration', 'binaryCfg', - binary, clusterDflts.binary); + const curCache = _.get(spi, 'Cache.cache'); - binaryCfg.emptyBeanProperty('idMapper') - .emptyBeanProperty('nameMapper') - .emptyBeanProperty('serializer'); + const cache = _.find(caches, (c) => curCache && (c._id === curCache || _.get(c, 'cache._id') === curCache)); - const typeCfgs = []; + if (cache) + cacheBean.prop('java.lang.String', 'cacheName', cache.name || cache.cache.name); - _.forEach(binary.typeConfigurations, (type) => { - const typeCfg = new Bean('org.apache.ignite.binary.BinaryTypeConfiguration', - JavaTypes.toJavaName('binaryType', type.typeName), type, clusterDflts.binary.typeConfigurations); + cacheBean.stringProperty('cacheName') + .emptyBeanProperty('checkpointListener'); - typeCfg.stringProperty('typeName') - .emptyBeanProperty('idMapper') - .emptyBeanProperty('nameMapper') - .emptyBeanProperty('serializer') - .intProperty('enum'); + return cacheBean; - if (typeCfg.nonEmpty()) - typeCfgs.push(typeCfg); - }); + case 'S3': + const s3Bean = new Bean('org.apache.ignite.spi.checkpoint.s3.S3CheckpointSpi', + 'checkpointSpiS3', spi.S3, clusterDflts.checkpointSpi.S3); - binaryCfg.collectionProperty('types', 'typeConfigurations', typeCfgs, 'org.apache.ignite.binary.BinaryTypeConfiguration') - .boolProperty('compactFooter'); + let credentialsBean = null; - if (binaryCfg.isEmpty()) - return cfg; + switch (_.get(spi.S3, 'awsCredentials.kind')) { + case 'Basic': + credentialsBean = new Bean('com.amazonaws.auth.BasicAWSCredentials', 'awsCredentials', {}); - cfg.beanProperty('binaryConfiguration', binaryCfg); + credentialsBean.propertyConstructorArgument('checkpoint.s3.credentials.accessKey', 'YOUR_S3_ACCESS_KEY') + .propertyConstructorArgument('checkpoint.s3.credentials.secretKey', 'YOUR_S3_SECRET_KEY'); - return cfg; - } + break; - // Generate cache key configurations. - static clusterCacheKeyConfiguration(keyCfgs, cfg = this.igniteConfigurationBean()) { - const items = _.reduce(keyCfgs, (acc, keyCfg) => { - if (keyCfg.typeName && keyCfg.affinityKeyFieldName) { - acc.push(new Bean('org.apache.ignite.cache.CacheKeyConfiguration', null, keyCfg) - .stringConstructorArgument('typeName') - .stringConstructorArgument('affinityKeyFieldName')); - } + case 'Properties': + credentialsBean = new Bean('com.amazonaws.auth.PropertiesCredentials', 'awsCredentials', {}); - return acc; - }, []); + const fileBean = new Bean('java.io.File', '', spi.S3.awsCredentials.Properties) + .pathConstructorArgument('path'); - if (_.isEmpty(items)) - return cfg; + if (fileBean.nonEmpty()) + credentialsBean.beanConstructorArgument('file', fileBean); - cfg.arrayProperty('cacheKeyConfiguration', 'cacheKeyConfiguration', items, - 'org.apache.ignite.cache.CacheKeyConfiguration'); + break; - return cfg; - } + case 'Anonymous': + credentialsBean = new Bean('com.amazonaws.auth.AnonymousAWSCredentials', 'awsCredentials', {}); - // Generate checkpoint configurations. - static clusterCheckpoint(cluster, caches, cfg = this.igniteConfigurationBean()) { - const cfgs = _.filter(_.map(cluster.checkpointSpi, (spi) => { - switch (_.get(spi, 'kind')) { - case 'FS': - const fsBean = new Bean('org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi', - 'checkpointSpiFs', spi.FS); + break; - fsBean.collectionProperty('directoryPaths', 'directoryPaths', _.get(spi, 'FS.directoryPaths')) - .emptyBeanProperty('checkpointListener'); + case 'BasicSession': + credentialsBean = new Bean('com.amazonaws.auth.BasicSessionCredentials', 'awsCredentials', {}); - return fsBean; + // TODO 2054 Arguments in one line is very long string. + credentialsBean.propertyConstructorArgument('checkpoint.s3.credentials.accessKey') + .propertyConstructorArgument('checkpoint.s3.credentials.secretKey') + .propertyConstructorArgument('checkpoint.s3.credentials.sessionToken'); - case 'Cache': - const cacheBean = new Bean('org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi', - 'checkpointSpiCache', spi.Cache); + break; - const curCache = _.get(spi, 'Cache.cache'); + case 'Custom': + const className = _.get(spi.S3.awsCredentials, 'Custom.className'); - const cache = _.find(caches, (c) => curCache && (c._id === curCache || _.get(c, 'cache._id') === curCache)); + if (className) + credentialsBean = new Bean(className, 'awsCredentials', {}); - if (cache) - cacheBean.prop('java.lang.String', 'cacheName', cache.name || cache.cache.name); + break; - cacheBean.stringProperty('cacheName') - .emptyBeanProperty('checkpointListener'); + default: + break; + } - return cacheBean; + if (credentialsBean) + s3Bean.beanProperty('awsCredentials', credentialsBean); - case 'S3': - const s3Bean = new Bean('org.apache.ignite.spi.checkpoint.s3.S3CheckpointSpi', - 'checkpointSpiS3', spi.S3, clusterDflts.checkpointSpi.S3); + s3Bean.stringProperty('bucketNameSuffix'); - let credentialsBean = null; + const clientBean = new Bean('com.amazonaws.ClientConfiguration', 'clientCfg', spi.S3.clientConfiguration, + clusterDflts.checkpointSpi.S3.clientConfiguration); - switch (_.get(spi.S3, 'awsCredentials.kind')) { - case 'Basic': - credentialsBean = new Bean('com.amazonaws.auth.BasicAWSCredentials', 'awsCredentials', {}); + clientBean.enumProperty('protocol') + .intProperty('maxConnections') + .stringProperty('userAgent'); - credentialsBean.propertyConstructorArgument('checkpoint.s3.credentials.accessKey', 'YOUR_S3_ACCESS_KEY') - .propertyConstructorArgument('checkpoint.s3.credentials.secretKey', 'YOUR_S3_SECRET_KEY'); + const locAddr = new Bean('java.net.InetAddress', '', spi.S3.clientConfiguration) + .factoryMethod('getByName') + .stringConstructorArgument('localAddress'); - break; + if (locAddr.nonEmpty()) + clientBean.beanProperty('localAddress', locAddr); - case 'Properties': - credentialsBean = new Bean('com.amazonaws.auth.PropertiesCredentials', 'awsCredentials', {}); + clientBean.stringProperty('proxyHost') + .intProperty('proxyPort') + .stringProperty('proxyUsername'); - const fileBean = new Bean('java.io.File', '', spi.S3.awsCredentials.Properties) - .pathConstructorArgument('path'); + const userName = clientBean.valueOf('proxyUsername'); - if (fileBean.nonEmpty()) - credentialsBean.beanConstructorArgument('file', fileBean); + if (userName) + clientBean.property('proxyPassword', `checkpoint.s3.proxy.${userName}.password`); - break; + clientBean.stringProperty('proxyDomain') + .stringProperty('proxyWorkstation'); - case 'Anonymous': - credentialsBean = new Bean('com.amazonaws.auth.AnonymousAWSCredentials', 'awsCredentials', {}); + const retryPolicy = spi.S3.clientConfiguration.retryPolicy; - break; + if (retryPolicy) { + const kind = retryPolicy.kind; - case 'BasicSession': - credentialsBean = new Bean('com.amazonaws.auth.BasicSessionCredentials', 'awsCredentials', {}); + const policy = retryPolicy[kind]; - // TODO 2054 Arguments in one line is very long string. - credentialsBean.propertyConstructorArgument('checkpoint.s3.credentials.accessKey') - .propertyConstructorArgument('checkpoint.s3.credentials.secretKey') - .propertyConstructorArgument('checkpoint.s3.credentials.sessionToken'); + let retryBean; + + switch (kind) { + case 'Default': + retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { + retryCondition: 'DEFAULT_RETRY_CONDITION', + backoffStrategy: 'DEFAULT_BACKOFF_STRATEGY', + maxErrorRetry: 'DEFAULT_MAX_ERROR_RETRY', + honorMaxErrorRetryInClientConfig: true + }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); + + retryBean.constantConstructorArgument('retryCondition') + .constantConstructorArgument('backoffStrategy') + .constantConstructorArgument('maxErrorRetry') + .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); break; - case 'Custom': - const className = _.get(spi.S3.awsCredentials, 'Custom.className'); + case 'DefaultMaxRetries': + retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { + retryCondition: 'DEFAULT_RETRY_CONDITION', + backoffStrategy: 'DEFAULT_BACKOFF_STRATEGY', + maxErrorRetry: _.get(policy, 'maxErrorRetry') || -1, + honorMaxErrorRetryInClientConfig: false + }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); - credentialsBean = new Bean(className, 'awsCredentials', {}); + retryBean.constantConstructorArgument('retryCondition') + .constantConstructorArgument('backoffStrategy') + .constructorArgument('java.lang.Integer', retryBean.valueOf('maxErrorRetry')) + .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); break; - default: - break; - } + case 'DynamoDB': + retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { + retryCondition: 'DEFAULT_RETRY_CONDITION', + backoffStrategy: 'DYNAMODB_DEFAULT_BACKOFF_STRATEGY', + maxErrorRetry: 'DYNAMODB_DEFAULT_MAX_ERROR_RETRY', + honorMaxErrorRetryInClientConfig: true + }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); - if (credentialsBean) - s3Bean.beanProperty('awsCredentials', credentialsBean); + retryBean.constantConstructorArgument('retryCondition') + .constantConstructorArgument('backoffStrategy') + .constantConstructorArgument('maxErrorRetry') + .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); - s3Bean.stringProperty('bucketNameSuffix'); + break; - const clientBean = new Bean('com.amazonaws.ClientConfiguration', 'clientCfg', spi.S3.clientConfiguration, - clusterDflts.checkpointSpi.S3.clientConfiguration); + case 'DynamoDBMaxRetries': + retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { + retryCondition: 'DEFAULT_RETRY_CONDITION', + backoffStrategy: 'DYNAMODB_DEFAULT_BACKOFF_STRATEGY', + maxErrorRetry: _.get(policy, 'maxErrorRetry') || -1, + honorMaxErrorRetryInClientConfig: false + }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); - clientBean.enumProperty('protocol') - .intProperty('maxConnections') - .stringProperty('userAgent'); + retryBean.constantConstructorArgument('retryCondition') + .constantConstructorArgument('backoffStrategy') + .constructorArgument('java.lang.Integer', retryBean.valueOf('maxErrorRetry')) + .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); - const locAddr = new Bean('java.net.InetAddress', '', spi.S3.clientConfiguration) - .factoryMethod('getByName') - .stringConstructorArgument('localAddress'); + break; - if (locAddr.nonEmpty()) - clientBean.beanProperty('localAddress', locAddr); + case 'Custom': + retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', policy); - clientBean.stringProperty('proxyHost') - .intProperty('proxyPort') - .stringProperty('proxyUsername'); + retryBean.beanConstructorArgument('retryCondition', retryBean.valueOf('retryCondition') ? new EmptyBean(retryBean.valueOf('retryCondition')) : null) + .beanConstructorArgument('backoffStrategy', retryBean.valueOf('backoffStrategy') ? new EmptyBean(retryBean.valueOf('backoffStrategy')) : null) + .constructorArgument('java.lang.Integer', retryBean.valueOf('maxErrorRetry')) + .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); - const userName = clientBean.valueOf('proxyUsername'); + break; - if (userName) - clientBean.property('proxyPassword', `checkpoint.s3.proxy.${userName}.password`); + default: + break; + } - clientBean.stringProperty('proxyDomain') - .stringProperty('proxyWorkstation'); + if (retryBean) + clientBean.beanProperty('retryPolicy', retryBean); + } - const retryPolicy = spi.S3.clientConfiguration.retryPolicy; + clientBean.intProperty('maxErrorRetry') + .intProperty('socketTimeout') + .intProperty('connectionTimeout') + .intProperty('requestTimeout') + .intProperty('socketSendBufferSizeHints') + .stringProperty('signerOverride') + .intProperty('connectionTTL') + .intProperty('connectionMaxIdleMillis') + .emptyBeanProperty('dnsResolver') + .intProperty('responseMetadataCacheSize') + .emptyBeanProperty('secureRandom') + .boolProperty('useReaper') + .boolProperty('useGzip') + .boolProperty('preemptiveBasicProxyAuth') + .boolProperty('useTcpKeepAlive'); + + if (clientBean.nonEmpty()) + s3Bean.beanProperty('clientConfiguration', clientBean); + + s3Bean.emptyBeanProperty('checkpointListener'); + + return s3Bean; + + case 'JDBC': + const jdbcBean = new Bean('org.apache.ignite.spi.checkpoint.jdbc.JdbcCheckpointSpi', + 'checkpointSpiJdbc', spi.JDBC, clusterDflts.checkpointSpi.JDBC); + + const id = jdbcBean.valueOf('dataSourceBean'); + const dialect = _.get(spi.JDBC, 'dialect'); + + jdbcBean.dataSource(id, 'dataSource', this.dataSourceBean(id, dialect)); + + if (!_.isEmpty(jdbcBean.valueOf('user'))) { + jdbcBean.stringProperty('user') + .property('pwd', `checkpoint.${jdbcBean.valueOf('dataSourceBean')}.${jdbcBean.valueOf('user')}.jdbc.password`, 'YOUR_PASSWORD'); + } - if (retryPolicy) { - const kind = retryPolicy.kind; + jdbcBean.stringProperty('checkpointTableName') + .stringProperty('keyFieldName') + .stringProperty('keyFieldType') + .stringProperty('valueFieldName') + .stringProperty('valueFieldType') + .stringProperty('expireDateFieldName') + .stringProperty('expireDateFieldType') + .intProperty('numberOfRetries') + .emptyBeanProperty('checkpointListener'); - const policy = retryPolicy[kind]; + return jdbcBean; - let retryBean; + case 'Custom': + const clsName = _.get(spi, 'Custom.className'); - switch (kind) { - case 'Default': - retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { - retryCondition: 'DEFAULT_RETRY_CONDITION', - backoffStrategy: 'DEFAULT_BACKOFF_STRATEGY', - maxErrorRetry: 'DEFAULT_MAX_ERROR_RETRY', - honorMaxErrorRetryInClientConfig: true - }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); + if (clsName) + return new Bean(clsName, 'checkpointSpiCustom', spi.Cache); - retryBean.constantConstructorArgument('retryCondition') - .constantConstructorArgument('backoffStrategy') - .constantConstructorArgument('maxErrorRetry') - .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); + return null; - break; + default: + return null; + } + }), (checkpointBean) => _.nonNil(checkpointBean)); - case 'DefaultMaxRetries': - retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { - retryCondition: 'DEFAULT_RETRY_CONDITION', - backoffStrategy: 'DEFAULT_BACKOFF_STRATEGY', - maxErrorRetry: _.get(policy, 'maxErrorRetry') || -1, - honorMaxErrorRetryInClientConfig: false - }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); + cfg.arrayProperty('checkpointSpi', 'checkpointSpi', cfgs, 'org.apache.ignite.spi.checkpoint.CheckpointSpi'); - retryBean.constantConstructorArgument('retryCondition') - .constantConstructorArgument('backoffStrategy') - .constructorArgument('java.lang.Integer', retryBean.valueOf('maxErrorRetry')) - .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); + return cfg; + } - break; + // Generate collision group. + static clusterCollision(collision, cfg = this.igniteConfigurationBean()) { + let colSpi; + + switch (_.get(collision, 'kind')) { + case 'JobStealing': + colSpi = new Bean('org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi', + 'colSpi', collision.JobStealing, clusterDflts.collision.JobStealing); + + colSpi.intProperty('activeJobsThreshold') + .intProperty('waitJobsThreshold') + .intProperty('messageExpireTime') + .intProperty('maximumStealingAttempts') + .boolProperty('stealingEnabled') + .emptyBeanProperty('externalCollisionListener') + .mapProperty('stealingAttrs', 'stealingAttributes'); + + break; + case 'FifoQueue': + colSpi = new Bean('org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi', + 'colSpi', collision.FifoQueue, clusterDflts.collision.FifoQueue); + + colSpi.intProperty('parallelJobsNumber') + .intProperty('waitingJobsNumber'); + + break; + case 'PriorityQueue': + colSpi = new Bean('org.apache.ignite.spi.collision.priorityqueue.PriorityQueueCollisionSpi', + 'colSpi', collision.PriorityQueue, clusterDflts.collision.PriorityQueue); + + colSpi.intProperty('parallelJobsNumber') + .intProperty('waitingJobsNumber') + .intProperty('priorityAttributeKey') + .intProperty('jobPriorityAttributeKey') + .intProperty('defaultPriority') + .intProperty('starvationIncrement') + .boolProperty('starvationPreventionEnabled'); + + break; + case 'Custom': + if (_.nonNil(_.get(collision, 'Custom.class'))) + colSpi = new EmptyBean(collision.Custom.class); + + break; + default: + return cfg; + } - case 'DynamoDB': - retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { - retryCondition: 'DEFAULT_RETRY_CONDITION', - backoffStrategy: 'DYNAMODB_DEFAULT_BACKOFF_STRATEGY', - maxErrorRetry: 'DYNAMODB_DEFAULT_MAX_ERROR_RETRY', - honorMaxErrorRetryInClientConfig: true - }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); + if (_.nonNil(colSpi)) + cfg.beanProperty('collisionSpi', colSpi); - retryBean.constantConstructorArgument('retryCondition') - .constantConstructorArgument('backoffStrategy') - .constantConstructorArgument('maxErrorRetry') - .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); + return cfg; + } - break; + // Generate communication group. + static clusterCommunication(cluster, cfg = this.igniteConfigurationBean(cluster)) { + const commSpi = new Bean('org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi', 'communicationSpi', + cluster.communication, clusterDflts.communication); + + commSpi.emptyBeanProperty('listener') + .stringProperty('localAddress') + .intProperty('localPort') + .intProperty('localPortRange') + .intProperty('sharedMemoryPort') + .intProperty('directBuffer') + .intProperty('directSendBuffer') + .intProperty('idleConnectionTimeout') + .intProperty('connectTimeout') + .intProperty('maxConnectTimeout') + .intProperty('reconnectCount') + .intProperty('socketSendBuffer') + .intProperty('socketReceiveBuffer') + .intProperty('messageQueueLimit') + .intProperty('slowClientQueueLimit') + .intProperty('tcpNoDelay') + .intProperty('ackSendThreshold') + .intProperty('unacknowledgedMessagesBufferSize') + .intProperty('socketWriteTimeout') + .intProperty('selectorsCount') + .emptyBeanProperty('addressResolver'); + + if (commSpi.nonEmpty()) + cfg.beanProperty('communicationSpi', commSpi); + + cfg.intProperty('networkTimeout') + .intProperty('networkSendRetryDelay') + .intProperty('networkSendRetryCount') + .intProperty('discoveryStartupDelay'); + + return cfg; + } - case 'DynamoDBMaxRetries': - retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', { - retryCondition: 'DEFAULT_RETRY_CONDITION', - backoffStrategy: 'DYNAMODB_DEFAULT_BACKOFF_STRATEGY', - maxErrorRetry: _.get(policy, 'maxErrorRetry') || -1, - honorMaxErrorRetryInClientConfig: false - }, clusterDflts.checkpointSpi.S3.clientConfiguration.retryPolicy); + // Generate REST access configuration. + static clusterConnector(connector, cfg = this.igniteConfigurationBean()) { + const connCfg = new Bean('org.apache.ignite.configuration.ConnectorConfiguration', + 'connectorConfiguration', connector, clusterDflts.connector); + + if (connCfg.valueOf('enabled')) { + connCfg.pathProperty('jettyPath') + .stringProperty('host') + .intProperty('port') + .intProperty('portRange') + .intProperty('idleTimeout') + .intProperty('idleQueryCursorTimeout') + .intProperty('idleQueryCursorCheckFrequency') + .intProperty('receiveBufferSize') + .intProperty('sendBufferSize') + .intProperty('sendQueueLimit') + .intProperty('directBuffer') + .intProperty('noDelay') + .intProperty('selectorCount') + .intProperty('threadPoolSize') + .emptyBeanProperty('messageInterceptor') + .stringProperty('secretKey'); + + if (connCfg.valueOf('sslEnabled')) { + connCfg.intProperty('sslClientAuth') + .emptyBeanProperty('sslFactory'); + } - retryBean.constantConstructorArgument('retryCondition') - .constantConstructorArgument('backoffStrategy') - .constructorArgument('java.lang.Integer', retryBean.valueOf('maxErrorRetry')) - .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); + if (connCfg.nonEmpty()) + cfg.beanProperty('connectorConfiguration', connCfg); + } - break; + return cfg; + } - case 'Custom': - retryBean = new Bean('com.amazonaws.retry.RetryPolicy', 'retryPolicy', policy); + // Generate deployment group. + static clusterDeployment(cluster, cfg = this.igniteConfigurationBean(cluster)) { + cfg.enumProperty('deploymentMode') + .boolProperty('peerClassLoadingEnabled'); - retryBean.beanConstructorArgument('retryCondition', retryBean.valueOf('retryCondition') ? new EmptyBean(retryBean.valueOf('retryCondition')) : null) - .beanConstructorArgument('backoffStrategy', retryBean.valueOf('backoffStrategy') ? new EmptyBean(retryBean.valueOf('backoffStrategy')) : null) - .constructorArgument('java.lang.Integer', retryBean.valueOf('maxErrorRetry')) - .constructorArgument('java.lang.Boolean', retryBean.valueOf('honorMaxErrorRetryInClientConfig')); + if (cfg.valueOf('peerClassLoadingEnabled')) { + cfg.intProperty('peerClassLoadingMissedResourcesCacheSize') + .intProperty('peerClassLoadingThreadPoolSize') + .varArgProperty('p2pLocClsPathExcl', 'peerClassLoadingLocalClassPathExclude', + cluster.peerClassLoadingLocalClassPathExclude); + } - break; + let deploymentBean = null; - default: - break; - } + switch (_.get(cluster, 'deploymentSpi.kind')) { + case 'URI': + const uriDeployment = cluster.deploymentSpi.URI; - if (retryBean) - clientBean.beanProperty('retryPolicy', retryBean); - } + deploymentBean = new Bean('org.apache.ignite.spi.deployment.uri.UriDeploymentSpi', 'deploymentSpi', uriDeployment); - clientBean.intProperty('maxErrorRetry') - .intProperty('socketTimeout') - .intProperty('connectionTimeout') - .intProperty('requestTimeout') - .intProperty('socketSendBufferSizeHints') - .stringProperty('signerOverride') - .intProperty('connectionTTL') - .intProperty('connectionMaxIdleMillis') - .emptyBeanProperty('dnsResolver') - .intProperty('responseMetadataCacheSize') - .emptyBeanProperty('secureRandom') - .boolProperty('useReaper') - .boolProperty('useGzip') - .boolProperty('preemptiveBasicProxyAuth') - .boolProperty('useTcpKeepAlive'); - - if (clientBean.nonEmpty()) - s3Bean.beanProperty('clientConfiguration', clientBean); - - s3Bean.emptyBeanProperty('checkpointListener'); - - return s3Bean; - - case 'JDBC': - const jdbcBean = new Bean('org.apache.ignite.spi.checkpoint.jdbc.JdbcCheckpointSpi', - 'checkpointSpiJdbc', spi.JDBC, clusterDflts.checkpointSpi.JDBC); - - const id = jdbcBean.valueOf('dataSourceBean'); - const dialect = _.get(spi.JDBC, 'dialect'); - - jdbcBean.dataSource(id, 'dataSource', this.dataSourceBean(id, dialect)); - - if (!_.isEmpty(jdbcBean.valueOf('user'))) { - jdbcBean.stringProperty('user') - .property('pwd', `checkpoint.${jdbcBean.valueOf('dataSourceBean')}.${jdbcBean.valueOf('user')}.jdbc.password`, 'YOUR_PASSWORD'); - } + const scanners = _.map(uriDeployment.scanners, (scanner) => new EmptyBean(scanner)); - jdbcBean.stringProperty('checkpointTableName') - .stringProperty('keyFieldName') - .stringProperty('keyFieldType') - .stringProperty('valueFieldName') - .stringProperty('valueFieldType') - .stringProperty('expireDateFieldName') - .stringProperty('expireDateFieldType') - .intProperty('numberOfRetries') - .emptyBeanProperty('checkpointListener'); + deploymentBean.collectionProperty('uriList', 'uriList', uriDeployment.uriList) + .stringProperty('temporaryDirectoryPath') + .varArgProperty('scanners', 'scanners', scanners, + 'org.apache.ignite.spi.deployment.uri.scanners.UriDeploymentScanner') + .emptyBeanProperty('listener') + .boolProperty('checkMd5') + .boolProperty('encodeUri'); - return jdbcBean; + cfg.beanProperty('deploymentSpi', deploymentBean); - case 'Custom': - const clsName = _.get(spi, 'Custom.className'); + break; - if (clsName) - return new Bean(clsName, 'checkpointSpiCustom', spi.Cache); + case 'Local': + deploymentBean = new Bean('org.apache.ignite.spi.deployment.local.LocalDeploymentSpi', 'deploymentSpi', cluster.deploymentSpi.Local); - return null; + deploymentBean.emptyBeanProperty('listener'); - default: - return null; - } - }), (checkpointBean) => _.nonNil(checkpointBean)); + cfg.beanProperty('deploymentSpi', deploymentBean); - cfg.arrayProperty('checkpointSpi', 'checkpointSpi', cfgs, 'org.apache.ignite.spi.checkpoint.CheckpointSpi'); + break; - return cfg; - } + case 'Custom': + cfg.emptyBeanProperty('deploymentSpi.Custom.className'); - // Generate collision group. - static clusterCollision(collision, cfg = this.igniteConfigurationBean()) { - let colSpi; + break; - switch (_.get(collision, 'kind')) { - case 'JobStealing': - colSpi = new Bean('org.apache.ignite.spi.collision.jobstealing.JobStealingCollisionSpi', - 'colSpi', collision.JobStealing, clusterDflts.collision.JobStealing); + default: + // No-op. + } - colSpi.intProperty('activeJobsThreshold') - .intProperty('waitJobsThreshold') - .intProperty('messageExpireTime') - .intProperty('maximumStealingAttempts') - .boolProperty('stealingEnabled') - .emptyBeanProperty('externalCollisionListener') - .mapProperty('stealingAttrs', 'stealingAttributes'); + return cfg; + } - break; - case 'FifoQueue': - colSpi = new Bean('org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi', - 'colSpi', collision.FifoQueue, clusterDflts.collision.FifoQueue); + // Generate discovery group. + static clusterDiscovery(discovery, cfg = this.igniteConfigurationBean(), discoSpi = this.discoveryConfigurationBean(discovery)) { + discoSpi.stringProperty('localAddress') + .intProperty('localPort') + .intProperty('localPortRange') + .emptyBeanProperty('addressResolver') + .intProperty('socketTimeout') + .intProperty('ackTimeout') + .intProperty('maxAckTimeout') + .intProperty('networkTimeout') + .intProperty('joinTimeout') + .intProperty('threadPriority') + .intProperty('heartbeatFrequency') + .intProperty('maxMissedHeartbeats') + .intProperty('maxMissedClientHeartbeats') + .intProperty('topHistorySize') + .emptyBeanProperty('listener') + .emptyBeanProperty('dataExchange') + .emptyBeanProperty('metricsProvider') + .intProperty('reconnectCount') + .intProperty('statisticsPrintFrequency') + .intProperty('ipFinderCleanFrequency') + .emptyBeanProperty('authenticator') + .intProperty('forceServerMode') + .intProperty('clientReconnectDisabled'); + + if (discoSpi.nonEmpty()) + cfg.beanProperty('discoverySpi', discoSpi); + + return discoSpi; + } - colSpi.intProperty('parallelJobsNumber') - .intProperty('waitingJobsNumber'); + // Generate events group. + static clusterEvents(cluster, cfg = this.igniteConfigurationBean(cluster)) { + const eventStorage = cluster.eventStorage; - break; - case 'PriorityQueue': - colSpi = new Bean('org.apache.ignite.spi.collision.priorityqueue.PriorityQueueCollisionSpi', - 'colSpi', collision.PriorityQueue, clusterDflts.collision.PriorityQueue); - - colSpi.intProperty('parallelJobsNumber') - .intProperty('waitingJobsNumber') - .intProperty('priorityAttributeKey') - .intProperty('jobPriorityAttributeKey') - .intProperty('defaultPriority') - .intProperty('starvationIncrement') - .boolProperty('starvationPreventionEnabled'); + let eventStorageBean = null; - break; - case 'Custom': - if (_.nonNil(_.get(collision, 'Custom.class'))) - colSpi = new EmptyBean(collision.Custom.class); + switch (_.get(eventStorage, 'kind')) { + case 'Memory': + eventStorageBean = new Bean('org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi', 'eventStorage', eventStorage.Memory, clusterDflts.eventStorage.Memory); - break; - default: - return cfg; - } + eventStorageBean.intProperty('expireAgeMs') + .intProperty('expireCount') + .emptyBeanProperty('filter'); - if (_.nonNil(colSpi)) - cfg.beanProperty('collisionSpi', colSpi); + break; - return cfg; - } + case 'Custom': + const className = _.get(eventStorage, 'Custom.className'); - // Generate communication group. - static clusterCommunication(cluster, cfg = this.igniteConfigurationBean(cluster)) { - const commSpi = new Bean('org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi', 'communicationSpi', - cluster.communication, clusterDflts.communication); + if (className) + eventStorageBean = new EmptyBean(className); - commSpi.emptyBeanProperty('listener') - .stringProperty('localAddress') - .intProperty('localPort') - .intProperty('localPortRange') - .intProperty('sharedMemoryPort') - .intProperty('directBuffer') - .intProperty('directSendBuffer') - .intProperty('idleConnectionTimeout') - .intProperty('connectTimeout') - .intProperty('maxConnectTimeout') - .intProperty('reconnectCount') - .intProperty('socketSendBuffer') - .intProperty('socketReceiveBuffer') - .intProperty('messageQueueLimit') - .intProperty('slowClientQueueLimit') - .intProperty('tcpNoDelay') - .intProperty('ackSendThreshold') - .intProperty('unacknowledgedMessagesBufferSize') - .intProperty('socketWriteTimeout') - .intProperty('selectorsCount') - .emptyBeanProperty('addressResolver'); - - if (commSpi.nonEmpty()) - cfg.beanProperty('communicationSpi', commSpi); - - cfg.intProperty('networkTimeout') - .intProperty('networkSendRetryDelay') - .intProperty('networkSendRetryCount') - .intProperty('discoveryStartupDelay'); + break; - return cfg; + default: + // No-op. } - // Generate REST access configuration. - static clusterConnector(connector, cfg = this.igniteConfigurationBean()) { - const connCfg = new Bean('org.apache.ignite.configuration.ConnectorConfiguration', - 'connectorConfiguration', connector, clusterDflts.connector); - - if (connCfg.valueOf('enabled')) { - connCfg.pathProperty('jettyPath') - .stringProperty('host') - .intProperty('port') - .intProperty('portRange') - .intProperty('idleTimeout') - .intProperty('idleQueryCursorTimeout') - .intProperty('idleQueryCursorCheckFrequency') - .intProperty('receiveBufferSize') - .intProperty('sendBufferSize') - .intProperty('sendQueueLimit') - .intProperty('directBuffer') - .intProperty('noDelay') - .intProperty('selectorCount') - .intProperty('threadPoolSize') - .emptyBeanProperty('messageInterceptor') - .stringProperty('secretKey'); - - if (connCfg.valueOf('sslEnabled')) { - connCfg.intProperty('sslClientAuth') - .emptyBeanProperty('sslFactory'); - } - - if (connCfg.nonEmpty()) - cfg.beanProperty('connectorConfiguration', connCfg); - } + if (eventStorageBean && eventStorageBean.nonEmpty()) + cfg.beanProperty('eventStorageSpi', eventStorageBean); - return cfg; - } + if (_.nonEmpty(cluster.includeEventTypes)) + cfg.eventTypes('evts', 'includeEventTypes', cluster.includeEventTypes); - // Generate deployment group. - static clusterDeployment(cluster, cfg = this.igniteConfigurationBean(cluster)) { - cfg.enumProperty('deploymentMode') - .boolProperty('peerClassLoadingEnabled'); + return cfg; + } - if (cfg.valueOf('peerClassLoadingEnabled')) { - cfg.intProperty('peerClassLoadingMissedResourcesCacheSize') - .intProperty('peerClassLoadingThreadPoolSize') - .varArgProperty('p2pLocClsPathExcl', 'peerClassLoadingLocalClassPathExclude', - cluster.peerClassLoadingLocalClassPathExclude); - } + // Generate failover group. + static clusterFailover(cluster, cfg = this.igniteConfigurationBean(cluster)) { + const spis = []; - return cfg; - } + _.forEach(cluster.failoverSpi, (spi) => { + let failoverSpi; - // Generate discovery group. - static clusterDiscovery(discovery, cfg = this.igniteConfigurationBean(), discoSpi = this.discoveryConfigurationBean(discovery)) { - discoSpi.stringProperty('localAddress') - .intProperty('localPort') - .intProperty('localPortRange') - .emptyBeanProperty('addressResolver') - .intProperty('socketTimeout') - .intProperty('ackTimeout') - .intProperty('maxAckTimeout') - .intProperty('networkTimeout') - .intProperty('joinTimeout') - .intProperty('threadPriority') - .intProperty('heartbeatFrequency') - .intProperty('maxMissedHeartbeats') - .intProperty('maxMissedClientHeartbeats') - .intProperty('topHistorySize') - .emptyBeanProperty('listener') - .emptyBeanProperty('dataExchange') - .emptyBeanProperty('metricsProvider') - .intProperty('reconnectCount') - .intProperty('statisticsPrintFrequency') - .intProperty('ipFinderCleanFrequency') - .emptyBeanProperty('authenticator') - .intProperty('forceServerMode') - .intProperty('clientReconnectDisabled'); - - if (discoSpi.nonEmpty()) - cfg.beanProperty('discoverySpi', discoSpi); - - return discoSpi; - } + switch (_.get(spi, 'kind')) { + case 'JobStealing': + failoverSpi = new Bean('org.apache.ignite.spi.failover.jobstealing.JobStealingFailoverSpi', + 'failoverSpi', spi.JobStealing, clusterDflts.failoverSpi.JobStealing); - // Generate events group. - static clusterEvents(cluster, cfg = this.igniteConfigurationBean(cluster)) { - const eventStorage = cluster.eventStorage; + failoverSpi.intProperty('maximumFailoverAttempts'); - let eventStorageBean = null; + break; + case 'Never': + failoverSpi = new Bean('org.apache.ignite.spi.failover.never.NeverFailoverSpi', + 'failoverSpi', spi.Never); - switch (_.get(eventStorage, 'kind')) { - case 'Memory': - eventStorageBean = new Bean('org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi', 'eventStorage', eventStorage.Memory, clusterDflts.eventStorage.Memory); + break; + case 'Always': + failoverSpi = new Bean('org.apache.ignite.spi.failover.always.AlwaysFailoverSpi', + 'failoverSpi', spi.Always, clusterDflts.failoverSpi.Always); - eventStorageBean.intProperty('expireAgeMs') - .intProperty('expireCount') - .emptyBeanProperty('filter'); + failoverSpi.intProperty('maximumFailoverAttempts'); break; - case 'Custom': - const className = _.get(eventStorage, 'Custom.className'); + const className = _.get(spi, 'Custom.class'); if (className) - eventStorageBean = new EmptyBean(className); + failoverSpi = new EmptyBean(className); break; - default: // No-op. } - if (eventStorageBean && eventStorageBean.nonEmpty()) - cfg.beanProperty('eventStorageSpi', eventStorageBean); - - if (_.nonEmpty(cluster.includeEventTypes)) - cfg.eventTypes('evts', 'includeEventTypes', cluster.includeEventTypes); - - return cfg; - } - - // Generate failover group. - static clusterFailover(cluster, cfg = this.igniteConfigurationBean(cluster)) { - const spis = []; - - _.forEach(cluster.failoverSpi, (spi) => { - let failoverSpi; + if (failoverSpi) + spis.push(failoverSpi); + }); - switch (_.get(spi, 'kind')) { - case 'JobStealing': - failoverSpi = new Bean('org.apache.ignite.spi.failover.jobstealing.JobStealingFailoverSpi', - 'failoverSpi', spi.JobStealing, clusterDflts.failoverSpi.JobStealing); + if (spis.length) + cfg.arrayProperty('failoverSpi', 'failoverSpi', spis, 'org.apache.ignite.spi.failover.FailoverSpi'); - failoverSpi.intProperty('maximumFailoverAttempts'); - - break; - case 'Never': - failoverSpi = new Bean('org.apache.ignite.spi.failover.never.NeverFailoverSpi', - 'failoverSpi', spi.Never); - - break; - case 'Always': - failoverSpi = new Bean('org.apache.ignite.spi.failover.always.AlwaysFailoverSpi', - 'failoverSpi', spi.Always, clusterDflts.failoverSpi.Always); + return cfg; + } - failoverSpi.intProperty('maximumFailoverAttempts'); + // Generate load balancing configuration group. + static clusterLoadBalancing(cluster, cfg = this.igniteConfigurationBean(cluster)) { + const spis = []; - break; - case 'Custom': - const className = _.get(spi, 'Custom.class'); + _.forEach(cluster.loadBalancingSpi, (spi) => { + let loadBalancingSpi; - if (className) - failoverSpi = new EmptyBean(className); + switch (_.get(spi, 'kind')) { + case 'RoundRobin': + loadBalancingSpi = new Bean('org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi', 'loadBalancingSpiRR', spi.RoundRobin, clusterDflts.loadBalancingSpi.RoundRobin); - break; - default: - // No-op. - } + loadBalancingSpi.boolProperty('perTask'); - if (failoverSpi) - spis.push(failoverSpi); - }); + break; + case 'Adaptive': + loadBalancingSpi = new Bean('org.apache.ignite.spi.loadbalancing.adaptive.AdaptiveLoadBalancingSpi', 'loadBalancingSpiAdaptive', spi.Adaptive); - if (spis.length) - cfg.arrayProperty('failoverSpi', 'failoverSpi', spis, 'org.apache.ignite.spi.failover.FailoverSpi'); + let probeBean; - return cfg; - } + switch (_.get(spi, 'Adaptive.loadProbe.kind')) { + case 'Job': + probeBean = new Bean('org.apache.ignite.spi.loadbalancing.adaptive.AdaptiveJobCountLoadProbe', 'jobProbe', spi.Adaptive.loadProbe.Job, clusterDflts.loadBalancingSpi.Adaptive.loadProbe.Job); - // Generate load balancing configuration group. - static clusterLoadBalancing(cluster, cfg = this.igniteConfigurationBean(cluster)) { - const spis = []; + probeBean.boolProperty('useAverage'); - _.forEach(cluster.loadBalancingSpi, (spi) => { - let loadBalancingSpi; + break; + case 'CPU': + probeBean = new Bean('org.apache.ignite.spi.loadbalancing.adaptive.AdaptiveCpuLoadProbe', 'cpuProbe', spi.Adaptive.loadProbe.CPU, clusterDflts.loadBalancingSpi.Adaptive
<TRUNCATED>
