Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8DCEF181AA for ; Thu, 14 Jan 2016 08:56:35 +0000 (UTC) Received: (qmail 43263 invoked by uid 500); 14 Jan 2016 08:56:35 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 43227 invoked by uid 500); 14 Jan 2016 08:56:35 -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 43218 invoked by uid 99); 14 Jan 2016 08:56:35 -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, 14 Jan 2016 08:56:35 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1B04EE0449; Thu, 14 Jan 2016 08:56:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: akuznetsov@apache.org To: commits@ignite.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: GNITE-2370 Added validation of database for data sources. Date: Thu, 14 Jan 2016 08:56:35 +0000 (UTC) Repository: ignite Updated Branches: refs/heads/ignite-843-rc2 978742051 -> 66cdf00be GNITE-2370 Added validation of database for data sources. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/66cdf00b Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/66cdf00b Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/66cdf00b Branch: refs/heads/ignite-843-rc2 Commit: 66cdf00be6ce4010379bd640f09fbc0516f61e6f Parents: 9787420 Author: vsisko Authored: Thu Jan 14 15:56:45 2016 +0700 Committer: Alexey Kuznetsov Committed: Thu Jan 14 15:56:45 2016 +0700 ---------------------------------------------------------------------- .../main/js/controllers/caches-controller.js | 48 +++++++++++++---- .../main/js/controllers/clusters-controller.js | 16 ++++++ .../src/main/js/controllers/common-module.js | 55 ++++++++++++++++++++ .../src/main/js/routes/caches.js | 4 +- 4 files changed, 112 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/66cdf00b/modules/control-center-web/src/main/js/controllers/caches-controller.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/caches-controller.js b/modules/control-center-web/src/main/js/controllers/caches-controller.js index da098a3..2dbd5e1 100644 --- a/modules/control-center-web/src/main/js/controllers/caches-controller.js +++ b/modules/control-center-web/src/main/js/controllers/caches-controller.js @@ -151,15 +151,7 @@ consoleModule.controller('cachesController', [ {value: 'DataSource', label: 'Data source'} ]; - $scope.cacheStoreJdbcDialects = [ - {value: 'Generic', label: 'Generic JDBC'}, - {value: 'Oracle', label: 'Oracle'}, - {value: 'DB2', label: 'IBM DB2'}, - {value: 'SQLServer', label: 'Microsoft SQL Server'}, - {value: 'MySQL', label: 'MySQL'}, - {value: 'PostgreSQL', label: 'PostgreSQL'}, - {value: 'H2', label: 'H2 database'} - ]; + $scope.cacheStoreJdbcDialects = $common.cacheStoreJdbcDialects; $scope.toggleExpanded = function () { $scope.ui.expanded = !$scope.ui.expanded; @@ -495,6 +487,38 @@ consoleModule.controller('cachesController', [ } }; + function checkDataSources() { + var clusters = _.filter($scope.clusters, function (cluster) { + return _.contains($scope.backupItem.clusters, cluster.value); + }); + + var checkRes = { checked: true }; + + var failCluster = _.find(clusters, function (cluster) { + var caches = _.filter($scope.caches, function (cache) { + return cache._id !== $scope.backupItem._id && _.find(cluster.caches, function (clusterCache) { + return clusterCache === cache._id; + }); + }); + + caches.push($scope.backupItem); + + checkRes = $common.checkCachesDataSources(caches); + + return !checkRes.checked; + }); + + if (!checkRes.checked) { + return showPopoverMessage($scope.panels, 'store', checkRes.secondCache.cacheStoreFactory.kind === 'CacheJdbcPojoStoreFactory' ? 'dialect' : 'database', + 'Found caches "' + checkRes.firstCache.name + '" and "' + checkRes.secondCache.name + '" in cluster "' + failCluster.label + '" ' + + 'with the same data source bean name "' + checkRes.firstCache.cacheStoreFactory[checkRes.firstCache.cacheStoreFactory.kind].dataSourceBean + + '" and different configured databases: "' + $common.cacheStoreJdbcDialectsLabel(checkRes.firstDB) + '" in "' + checkRes.firstCache.name + '" and "' + + $common.cacheStoreJdbcDialectsLabel(checkRes.secondDB) + '" in "' + checkRes.secondCache.name + '"'); + } + + return true; + } + // Check cache logical consistency. function validate(item) { if ($common.isEmptyString(item.name)) @@ -523,6 +547,9 @@ consoleModule.controller('cachesController', [ if (!storeFactory.dialect) return showPopoverMessage($scope.panels, 'store', 'dialect', 'Dialect should not be empty'); + + if (!checkDataSources()) + return false; } if (item.cacheStoreFactory.kind === 'CacheJdbcBlobStoreFactory') { @@ -546,6 +573,9 @@ consoleModule.controller('cachesController', [ if (!storeFactory.database) return showPopoverMessage($scope.panels, 'store', 'database', 'Database should not be empty'); + + if (!checkDataSources()) + return false; } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/66cdf00b/modules/control-center-web/src/main/js/controllers/clusters-controller.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/clusters-controller.js b/modules/control-center-web/src/main/js/controllers/clusters-controller.js index 0496772..10607ad 100644 --- a/modules/control-center-web/src/main/js/controllers/clusters-controller.js +++ b/modules/control-center-web/src/main/js/controllers/clusters-controller.js @@ -467,6 +467,22 @@ consoleModule.controller('clustersController', function ($http, $timeout, $scope if ($common.isEmptyString(item.name)) return showPopoverMessage($scope.panels, 'general', 'clusterName', 'Name should not be empty'); + var caches = _.filter(_.map($scope.caches, function (scopeCache) { + return scopeCache.cache; + }), function (cache) { + return _.contains($scope.backupItem.caches, cache._id); + }); + + var checkRes = $common.checkCachesDataSources(caches); + + if (!checkRes.checked) { + return showPopoverMessage($scope.panels, 'general', 'caches', + 'Found caches "' + checkRes.firstCache.name + '" and "' + checkRes.secondCache.name + '" ' + + 'with the same data source bean name "' + checkRes.firstCache.cacheStoreFactory[checkRes.firstCache.cacheStoreFactory.kind].dataSourceBean + + '" and different configured databases: "' + $common.cacheStoreJdbcDialectsLabel(checkRes.firstDB) + '" in "' + checkRes.firstCache.name + '" and "' + + $common.cacheStoreJdbcDialectsLabel(checkRes.secondDB) + '" in "' + checkRes.secondCache.name + '"'); + } + var b = item.binaryConfiguration; if ($common.isDefined(b)) { http://git-wip-us.apache.org/repos/asf/ignite/blob/66cdf00b/modules/control-center-web/src/main/js/controllers/common-module.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/controllers/common-module.js b/modules/control-center-web/src/main/js/controllers/common-module.js index 38fd56d..3180335 100644 --- a/modules/control-center-web/src/main/js/controllers/common-module.js +++ b/modules/control-center-web/src/main/js/controllers/common-module.js @@ -674,6 +674,27 @@ consoleModule.service('$common', [ return group.dirty; } + function extractDataSource(cache) { + if (cache.cacheStoreFactory && cache.cacheStoreFactory.kind) { + var storeFactory = cache.cacheStoreFactory[cache.cacheStoreFactory.kind]; + + if (storeFactory.dialect || (storeFactory.connectVia === 'DataSource')) + return storeFactory; + } + + return undefined; + } + + var cacheStoreJdbcDialects = [ + {value: 'Generic', label: 'Generic JDBC'}, + {value: 'Oracle', label: 'Oracle'}, + {value: 'DB2', label: 'IBM DB2'}, + {value: 'SQLServer', label: 'Microsoft SQL Server'}, + {value: 'MySQL', label: 'MySQL'}, + {value: 'PostgreSQL', label: 'PostgreSQL'}, + {value: 'H2', label: 'H2 database'} + ]; + return { getModel: getModel, joinTip: function (arr) { @@ -999,6 +1020,40 @@ consoleModule.service('$common', [ return true; return attr.substr(attr.indexOf('=') + 1); + }, + cacheStoreJdbcDialects: cacheStoreJdbcDialects, + cacheStoreJdbcDialectsLabel: function (dialect) { + var found = _.find(cacheStoreJdbcDialects, function (dialectVal) { + return dialectVal.value === dialect; + }); + + return found ? found.label : undefined; + }, + checkCachesDataSources: function (caches) { + var res = { checked: true }; + + res.checked = !isDefined(_.find(caches, function (curCache, curIx) { + return _.find(caches, function (checkCache, checkIx) { + if (checkIx < curIx) { + var curDs = extractDataSource(curCache); + var checkDs = extractDataSource(checkCache); + + var curDB = curDs.dialect || curDs.database; + var checkDB = checkDs.dialect || checkDs.database; + + var fail = curDs && checkDs && curDs.dataSourceBean === checkDs.dataSourceBean && curDB !== checkDB; + + if (fail) { + res = { checked: false, firstCache: checkCache, firstDB: checkDB, + secondCache: curCache, secondDB: curDB } + } + + return fail; + } + }) + })); + + return res; } }; }]); http://git-wip-us.apache.org/repos/asf/ignite/blob/66cdf00b/modules/control-center-web/src/main/js/routes/caches.js ---------------------------------------------------------------------- diff --git a/modules/control-center-web/src/main/js/routes/caches.js b/modules/control-center-web/src/main/js/routes/caches.js index bca0d2e..70f0e9b 100644 --- a/modules/control-center-web/src/main/js/routes/caches.js +++ b/modules/control-center-web/src/main/js/routes/caches.js @@ -36,7 +36,7 @@ router.post('/list', function (req, res) { }); // Get all clusters for spaces. - db.Cluster.find({space: {$in: space_ids}}, '_id name').sort('name').exec(function (err, clusters) { + db.Cluster.find({space: {$in: space_ids}}, '_id name caches').sort('name').exec(function (err, clusters) { if (db.processed(err, res)) { // Get all caches type metadata for spaces. db.CacheTypeMetadata.find({space: {$in: space_ids}}).sort('name').exec(function (err, metadatas) { @@ -63,7 +63,7 @@ router.post('/list', function (req, res) { res.json({ spaces: spaces, clusters: clusters.map(function (cluster) { - return {value: cluster._id, label: cluster.name}; + return {value: cluster._id, label: cluster.name, caches: cluster.caches}; }), metadatas: metadatas, caches: caches