You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2016/06/20 02:58:40 UTC
[17/50] [abbrv] ignite git commit: IGNITE-3236 Fixed eslint warnigs +
fixed several typos.
IGNITE-3236 Fixed eslint warnigs + fixed several typos.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f97b7576
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f97b7576
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f97b7576
Branch: refs/heads/ignite-3262
Commit: f97b7576f3e7ddc418d39f3bc37c76c07f0dbeff
Parents: 512180a
Author: vsisko <vs...@gridgain.com>
Authored: Mon Jun 6 21:50:41 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Jun 6 21:50:41 2016 +0700
----------------------------------------------------------------------
.../main/js/controllers/caches-controller.js | 102 +++++---------
.../main/js/controllers/clusters-controller.js | 137 +++++++++----------
.../src/main/js/controllers/common-module.js | 35 +++++
.../main/js/controllers/domains-controller.js | 70 +++-------
4 files changed, 160 insertions(+), 184 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f97b7576/modules/web-console/src/main/js/controllers/caches-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/src/main/js/controllers/caches-controller.js b/modules/web-console/src/main/js/controllers/caches-controller.js
index e8714e7..2d27164 100644
--- a/modules/web-console/src/main/js/controllers/caches-controller.js
+++ b/modules/web-console/src/main/js/controllers/caches-controller.js
@@ -243,88 +243,60 @@ consoleModule.controller('cachesController', [
return true;
}
- // Check cache logical consistency.
- function validate(item) {
- $common.hidePopover();
-
- if ($common.isEmptyString(item.name))
- return showPopoverMessage($scope.ui, 'general', 'cacheName', 'Cache name should not be empty!');
-
- if (item.memoryMode === 'ONHEAP_TIERED' && item.offHeapMaxMemory > 0 && !$common.isDefined(item.evictionPolicy.kind))
- return showPopoverMessage($scope.ui, 'memory', 'evictionPolicyKind', 'Eviction policy should not be configured!');
-
- const form = $scope.ui.inputForm;
- const errors = form.$error;
- const errKeys = Object.keys(errors);
-
- if (errKeys && errKeys.length > 0) {
- const firstErrorKey = errKeys[0];
+ function checkStoreFactoryBean(storeFactory, beanFieldId) {
+ if (!$common.isValidJavaIdentifier('Data source bean', storeFactory.dataSourceBean, beanFieldId, $scope.ui, 'store'))
+ return false;
- const firstError = errors[firstErrorKey][0];
- const actualError = firstError.$error[firstErrorKey][0];
+ return checkDataSources();
+ }
- const errNameFull = actualError.$name;
- const errNameShort = errNameFull.endsWith('TextInput') ? errNameFull.substring(0, errNameFull.length - 9) : errNameFull;
+ function checkStoreFactory(item) {
+ const cacheStoreFactorySelected = item.cacheStoreFactory && item.cacheStoreFactory.kind;
- const extractErrorMessage = function(errName) {
- try {
- return errors[firstErrorKey][0].$errorMessages[errName][firstErrorKey];
- }
- catch (ignored) {
- try {
- return form[firstError.$name].$errorMessages[errName][firstErrorKey];
- }
- catch (ignited) {
- return false;
- }
- }
- };
+ if (cacheStoreFactorySelected) {
+ const storeFactory = item.cacheStoreFactory[item.cacheStoreFactory.kind];
- const msg = extractErrorMessage(errNameFull) || extractErrorMessage(errNameShort) || 'Invalid value!';
+ if (item.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory' && !checkStoreFactoryBean(storeFactory, 'pojoDataSourceBean'))
+ return false;
- return showPopoverMessage($scope.ui, firstError.$name, errNameFull, msg);
+ if (item.cacheStoreFactory.kind === 'CacheJdbcBlobStoreFactory' && storeFactory.connectVia !== 'URL'
+ && !checkStoreFactoryBean(storeFactory, 'blobDataSourceBean'))
+ return false;
}
- if (item.memoryMode === 'OFFHEAP_VALUES' && !_.isEmpty(item.domains))
- return showPopoverMessage($scope.ui, 'memory', 'memoryMode', 'Query indexing could not be enabled while values are stored off-heap!');
+ if ((item.readThrough || item.writeThrough) && !cacheStoreFactorySelected)
+ return showPopoverMessage($scope.ui, 'store', 'cacheStoreFactory', (item.readThrough ? 'Read' : 'Write') + ' through are enabled but store is not configured!');
- if (item.memoryMode === 'OFFHEAP_TIERED' && (!$common.isDefined(item.offHeapMaxMemory) || item.offHeapMaxMemory < 0))
- return showPopoverMessage($scope.ui, 'memory', 'offHeapMaxMemory', 'Off-heap max memory should be specified!');
+ if (item.writeBehindEnabled && !cacheStoreFactorySelected)
+ return showPopoverMessage($scope.ui, 'store', 'cacheStoreFactory', 'Write behind enabled but store is not configured!');
- const cacheStoreFactorySelected = item.cacheStoreFactory && item.cacheStoreFactory.kind;
+ if (cacheStoreFactorySelected && !item.readThrough && !item.writeThrough)
+ return showPopoverMessage($scope.ui, 'store', 'readThroughTooltip', 'Store is configured but read/write through are not enabled!');
- if (cacheStoreFactorySelected) {
- const storeFactory = item.cacheStoreFactory[item.cacheStoreFactory.kind];
+ return true;
+ }
- if (item.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory') {
- if (!$common.isValidJavaIdentifier('Data source bean', storeFactory.dataSourceBean, 'pojoDataSourceBean', $scope.ui, 'store'))
- return false;
+ // Check cache logical consistency.
+ function validate(item) {
+ $common.hidePopover();
- if (!checkDataSources())
- return false;
- }
+ if ($common.isEmptyString(item.name))
+ return showPopoverMessage($scope.ui, 'general', 'cacheName', 'Cache name should not be empty!');
- if (item.cacheStoreFactory.kind === 'CacheJdbcBlobStoreFactory') {
- if (storeFactory.connectVia !== 'URL') {
- if (!$common.isValidJavaIdentifier('Data source bean', storeFactory.dataSourceBean, 'blobDataSourceBean', $scope.ui, 'store'))
- return false;
+ if (item.memoryMode === 'ONHEAP_TIERED' && item.offHeapMaxMemory > 0 && !$common.isDefined(item.evictionPolicy.kind))
+ return showPopoverMessage($scope.ui, 'memory', 'evictionPolicyKind', 'Eviction policy should not be configured!');
- if (!checkDataSources())
- return false;
- }
- }
- }
+ if (!$common.checkFieldValidators($scope.ui))
+ return false;
- if ((item.readThrough || item.writeThrough) && !cacheStoreFactorySelected)
- return showPopoverMessage($scope.ui, 'store', 'cacheStoreFactory', (item.readThrough ? 'Read' : 'Write') + ' through are enabled but store is not configured!');
+ if (item.memoryMode === 'OFFHEAP_VALUES' && !_.isEmpty(item.domains))
+ return showPopoverMessage($scope.ui, 'memory', 'memoryMode', 'Query indexing could not be enabled while values are stored off-heap!');
- if (item.writeBehindEnabled && !cacheStoreFactorySelected)
- return showPopoverMessage($scope.ui, 'store', 'cacheStoreFactory', 'Write behind enabled but store is not configured!');
+ if (item.memoryMode === 'OFFHEAP_TIERED' && (!$common.isDefined(item.offHeapMaxMemory) || item.offHeapMaxMemory < 0))
+ return showPopoverMessage($scope.ui, 'memory', 'offHeapMaxMemory', 'Off-heap max memory should be specified!');
- if (cacheStoreFactorySelected) {
- if (!item.readThrough && !item.writeThrough)
- return showPopoverMessage($scope.ui, 'store', 'readThroughTooltip', 'Store is configured but read/write through are not enabled!');
- }
+ if (!checkStoreFactory(item))
+ return false;
if (item.writeBehindFlushSize === 0 && item.writeBehindFlushFrequency === 0)
return showPopoverMessage($scope.ui, 'store', 'writeBehindFlushSize', 'Both "Flush frequency" and "Flush size" are not allowed as 0!');
http://git-wip-us.apache.org/repos/asf/ignite/blob/f97b7576/modules/web-console/src/main/js/controllers/clusters-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/src/main/js/controllers/clusters-controller.js b/modules/web-console/src/main/js/controllers/clusters-controller.js
index 5faadb5..7da00a5 100644
--- a/modules/web-console/src/main/js/controllers/clusters-controller.js
+++ b/modules/web-console/src/main/js/controllers/clusters-controller.js
@@ -334,47 +334,9 @@ consoleModule.controller('clustersController', [
return _.findIndex($scope.caches, (cache) => cache.value === cacheId);
};
- // Check cluster logical consistency.
- function validate(item) {
- $common.hidePopover();
-
- if ($common.isEmptyString(item.name))
- return showPopoverMessage($scope.ui, 'general', 'clusterName', 'Cluster name should not be empty!');
-
- const form = $scope.ui.inputForm;
- const errors = form.$error;
- const errKeys = Object.keys(errors);
-
- if (errKeys && errKeys.length > 0) {
- const firstErrorKey = errKeys[0];
-
- const firstError = errors[firstErrorKey][0];
- const actualError = firstError.$error[firstErrorKey][0];
-
- const errNameFull = actualError.$name;
- const errNameShort = errNameFull.endsWith('TextInput') ? errNameFull.substring(0, errNameFull.length - 9) : errNameFull;
-
- const extractErrorMessage = function(errName) {
- try {
- return errors[firstErrorKey][0].$errorMessages[errName][firstErrorKey];
- }
- catch (ignored) {
- try {
- return form[firstError.$name].$errorMessages[errName][firstErrorKey];
- }
- catch (ignited) {
- return false;
- }
- }
- };
-
- const msg = extractErrorMessage(errNameFull) || extractErrorMessage(errNameShort) || 'Invalid value!';
-
- return showPopoverMessage($scope.ui, firstError.$name, errNameFull, msg);
- }
-
+ function checkCacheDatasources(item) {
const caches = _.filter(_.map($scope.caches, (scopeCache) => scopeCache.cache),
- (cache) => _.includes($scope.backupItem.caches, cache._id));
+ (cache) => _.includes(item.caches, cache._id));
const checkRes = $common.checkCachesDataSources(caches);
@@ -386,6 +348,10 @@ consoleModule.controller('clustersController', [
$common.cacheStoreJdbcDialectsLabel(checkRes.secondDB) + '" in "' + checkRes.secondCache.name + '"', 10000);
}
+ return true;
+ }
+
+ function checkBinaryConfiguration(item) {
const b = item.binaryConfiguration;
if ($common.isDefined(b)) {
@@ -402,6 +368,10 @@ consoleModule.controller('clustersController', [
}
}
+ return true;
+ }
+
+ function checkCommunicationConfiguration(item) {
const c = item.communication;
if ($common.isDefined(c)) {
@@ -417,13 +387,10 @@ consoleModule.controller('clustersController', [
return showPopoverMessage($scope.ui, 'communication', 'sharedMemoryPort', 'Shared memory port should be more than "0" or equals to "-1"!');
}
- const r = item.connector;
-
- if ($common.isDefined(r)) {
- if (r.sslEnabled && $common.isEmptyString(r.sslFactory))
- return showPopoverMessage($scope.ui, 'connector', 'connectorSslFactory', 'SSL factory should not be empty!');
- }
+ return true;
+ }
+ function checkDiscoveryConfiguration(item) {
const d = item.discovery;
if (d) {
@@ -432,33 +399,12 @@ consoleModule.controller('clustersController', [
if (d.kind === 'Vm' && d.Vm && d.Vm.addresses.length === 0)
return showPopoverMessage($scope.ui, 'general', 'addresses', 'Addresses are not specified!');
-
- if (d.kind === 'S3' && d.S3 && $common.isEmptyString(d.S3.bucketName))
- return showPopoverMessage($scope.ui, 'general', 'bucketName', 'Bucket name should not be empty!');
-
- if (d.kind === 'Cloud' && d.Cloud) {
- if ($common.isEmptyString(d.Cloud.identity))
- return showPopoverMessage($scope.ui, 'general', 'identity', 'Identity should not be empty!');
-
- if ($common.isEmptyString(d.Cloud.provider))
- return showPopoverMessage($scope.ui, 'general', 'provider', 'Provider should not be empty!');
- }
-
- if (d.kind === 'GoogleStorage' && d.GoogleStorage) {
- if ($common.isEmptyString(d.GoogleStorage.projectName))
- return showPopoverMessage($scope.ui, 'general', 'projectName', 'Project name should not be empty!');
-
- if ($common.isEmptyString(d.GoogleStorage.bucketName))
- return showPopoverMessage($scope.ui, 'general', 'bucketName', 'Bucket name should not be empty!');
-
- if ($common.isEmptyString(d.GoogleStorage.serviceAccountP12FilePath))
- return showPopoverMessage($scope.ui, 'general', 'serviceAccountP12FilePath', 'Private key path should not be empty!');
-
- if ($common.isEmptyString(d.GoogleStorage.serviceAccountId))
- return showPopoverMessage($scope.ui, 'general', 'serviceAccountId', 'Account ID should not be empty!');
- }
}
+ return true;
+ }
+
+ function checkSwapConfiguration(item) {
const swapKind = item.swapSpaceSpi && item.swapSpaceSpi.kind;
if (swapKind && item.swapSpaceSpi[swapKind]) {
@@ -475,6 +421,17 @@ consoleModule.controller('clustersController', [
return showPopoverMessage($scope.ui, 'swap', 'readStripesNumber', 'Read stripe size must be positive and power of two!');
}
+ return true;
+ }
+
+ function checkSslConfiguration(item) {
+ const r = item.connector;
+
+ if ($common.isDefined(r)) {
+ if (r.sslEnabled && $common.isEmptyString(r.sslFactory))
+ return showPopoverMessage($scope.ui, 'connector', 'connectorSslFactory', 'SSL factory should not be empty!');
+ }
+
if (item.sslEnabled) {
if (!$common.isDefined(item.sslContextFactory) || $common.isEmptyString(item.sslContextFactory.keyStoreFilePath))
return showPopoverMessage($scope.ui, 'sslConfiguration', 'keyStoreFilePath', 'Key store file should not be empty!');
@@ -483,12 +440,50 @@ consoleModule.controller('clustersController', [
return showPopoverMessage($scope.ui, 'sslConfiguration', 'sslConfiguration-title', 'Trust storage file or managers should be configured!');
}
+ return true;
+ }
+
+ function checkPoolSizes(item) {
if (item.rebalanceThreadPoolSize && item.systemThreadPoolSize && item.systemThreadPoolSize <= item.rebalanceThreadPoolSize)
return showPopoverMessage($scope.ui, 'pools', 'rebalanceThreadPoolSize', 'Rebalance thread pool size exceed or equals System thread pool size!');
return true;
}
+ // Check cluster logical consistency.
+ function validate(item) {
+ $common.hidePopover();
+
+ if ($common.isEmptyString(item.name))
+ return showPopoverMessage($scope.ui, 'general', 'clusterName', 'Cluster name should not be empty!');
+
+ if (!$common.checkFieldValidators($scope.ui))
+ return false;
+
+ if (!checkCacheDatasources(item))
+ return false;
+
+ if (!checkBinaryConfiguration(item))
+ return false;
+
+ if (!checkCommunicationConfiguration(item))
+ return false;
+
+ if (!checkDiscoveryConfiguration(item))
+ return false;
+
+ if (!checkSwapConfiguration(item))
+ return false;
+
+ if (!checkSslConfiguration(item))
+ return false;
+
+ if (!checkPoolSizes(item))
+ return false;
+
+ return true;
+ }
+
// Save cluster in database.
function save(item) {
$http.post('/api/v1/configuration/clusters/save', item)
http://git-wip-us.apache.org/repos/asf/ignite/blob/f97b7576/modules/web-console/src/main/js/controllers/common-module.js
----------------------------------------------------------------------
diff --git a/modules/web-console/src/main/js/controllers/common-module.js b/modules/web-console/src/main/js/controllers/common-module.js
index 9ddcdbf..e744f79 100644
--- a/modules/web-console/src/main/js/controllers/common-module.js
+++ b/modules/web-console/src/main/js/controllers/common-module.js
@@ -1016,6 +1016,41 @@ consoleModule.service('$common', ['$alert', '$popover', '$anchorScroll', '$locat
res += possible.charAt(Math.floor(Math.random() * possibleLen));
return res;
+ },
+ checkFieldValidators(ui) {
+ const form = ui.inputForm;
+ const errors = form.$error;
+ const errKeys = Object.keys(errors);
+
+ if (errKeys && errKeys.length > 0) {
+ const firstErrorKey = errKeys[0];
+
+ const firstError = errors[firstErrorKey][0];
+ const actualError = firstError.$error[firstErrorKey][0];
+
+ const errNameFull = actualError.$name;
+ const errNameShort = errNameFull.endsWith('TextInput') ? errNameFull.substring(0, errNameFull.length - 9) : errNameFull;
+
+ const extractErrorMessage = function(errName) {
+ try {
+ return errors[firstErrorKey][0].$errorMessages[errName][firstErrorKey];
+ }
+ catch (ignored) {
+ try {
+ return form[firstError.$name].$errorMessages[errName][firstErrorKey];
+ }
+ catch (ignited) {
+ return false;
+ }
+ }
+ };
+
+ const msg = extractErrorMessage(errNameFull) || extractErrorMessage(errNameShort) || 'Invalid value!';
+
+ return showPopoverMessage(ui, firstError.$name, errNameFull, msg);
+ }
+
+ return true;
}
};
}]);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f97b7576/modules/web-console/src/main/js/controllers/domains-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/src/main/js/controllers/domains-controller.js b/modules/web-console/src/main/js/controllers/domains-controller.js
index c1523d5..df7d8a9 100644
--- a/modules/web-console/src/main/js/controllers/domains-controller.js
+++ b/modules/web-console/src/main/js/controllers/domains-controller.js
@@ -1203,53 +1203,8 @@ consoleModule.controller('domainsController', [
}
};
- // Check domain model logical consistency.
- function validate(item) {
- const form = $scope.ui.inputForm;
- const errors = form.$error;
- const errKeys = Object.keys(errors);
-
- if (errKeys && errKeys.length > 0) {
- const firstErrorKey = errKeys[0];
-
- const firstError = errors[firstErrorKey][0];
- const actualError = firstError.$error[firstErrorKey][0];
-
- const errNameFull = actualError.$name;
- const errNameShort = errNameFull.endsWith('TextInput') ? errNameFull.substring(0, errNameFull.length - 9) : errNameFull;
-
- const extractErrorMessage = function(errName) {
- try {
- return errors[firstErrorKey][0].$errorMessages[errName][firstErrorKey];
- }
- catch (ignored) {
- try {
- return form[firstError.$name].$errorMessages[errName][firstErrorKey];
- }
- catch (ignited) {
- return false;
- }
- }
- };
-
- const msg = extractErrorMessage(errNameFull) || extractErrorMessage(errNameShort) || 'Invalid value!';
-
- return showPopoverMessage($scope.ui, firstError.$name, errNameFull, msg);
- }
-
- if ($common.isEmptyString(item.keyType))
- return showPopoverMessage($scope.ui, 'general', 'keyType', 'Key type should not be empty');
- else if (!$common.isValidJavaClass('Key type', item.keyType, true, 'keyType', false, $scope.ui, 'general'))
- return false;
-
- if ($common.isEmptyString(item.valueType))
- return showPopoverMessage($scope.ui, 'general', 'valueType', 'Value type should not be empty');
- else if (!$common.isValidJavaClass('Value type', item.valueType, false, 'valueType', false, $scope.ui, 'general'))
- return false;
-
- const qry = $common.domainForQueryConfigured(item);
-
- if (item.queryMetadata === 'Configuration' && qry) {
+ function checkQueryConfiguration(item) {
+ if (item.queryMetadata === 'Configuration' && $common.domainForQueryConfigured(item)) {
if (_.isEmpty(item.fields))
return showPopoverMessage($scope.ui, 'query', 'queryFields', 'Query fields should not be empty');
@@ -1264,6 +1219,10 @@ consoleModule.controller('domainsController', [
}
}
+ return true;
+ }
+
+ function checkStoreConfiguration(item) {
if ($common.domainForStoreConfigured(item)) {
if ($common.isEmptyString(item.databaseSchema))
return showPopoverMessage($scope.ui, 'store', 'databaseSchema', 'Database schema should not be empty');
@@ -1280,7 +1239,22 @@ consoleModule.controller('domainsController', [
if (_.isEmpty(item.valueFields))
return showPopoverMessage($scope.ui, 'store', 'valueFields', 'Value fields are not specified');
}
- else if (!qry && item.queryMetadata === 'Configuration')
+
+ return true;
+ }
+
+ // Check domain model logical consistency.
+ function validate(item) {
+ if (!$common.checkFieldValidators($scope.ui))
+ return false;
+
+ if (!checkQueryConfiguration(item))
+ return false;
+
+ if (!checkStoreConfiguration(item))
+ return false;
+
+ if (!$common.domainForStoreConfigured(item) && !$common.domainForQueryConfigured(item) && item.queryMetadata === 'Configuration')
return showPopoverMessage($scope.ui, 'query', 'query-title', 'SQL query domain model should be configured');
return true;