ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [1/2] ignite git commit: IGNITE-843 Rework cluster remove.
Date Mon, 15 Feb 2016 10:45:20 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 02d4c1ec4 -> 5110d98dc


IGNITE-843 Rework cluster remove.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d29110fb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d29110fb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d29110fb

Branch: refs/heads/ignite-843-rc2
Commit: d29110fb5113aa9a1aa55eccccc00c88880efba6
Parents: 053ba44
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Feb 15 17:44:57 2016 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Feb 15 17:44:57 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/clusters.js        | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d29110fb/modules/control-center-web/src/main/js/serve/routes/clusters.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/clusters.js b/modules/control-center-web/src/main/js/serve/routes/clusters.js
index 9410ffc..acfb2aa 100644
--- a/modules/control-center-web/src/main/js/serve/routes/clusters.js
+++ b/modules/control-center-web/src/main/js/serve/routes/clusters.js
@@ -137,14 +137,24 @@ module.exports.factory = function(_, express, mongo) {
          * Remove cluster by ._id.
          */
         router.post('/remove', (req, res) => {
-            mongo.Cluster.remove(req.body, (err) => {
-                if (err)
-                    return res.status(500).send(err.message);
-
-                // TODO add IGFS and caches cleanup
-
-                res.sendStatus(200);
-            });
+            const userId = req.currentUserId();
+            const clusterId = req.body;
+
+            let spacesIds = [];
+
+            mongo.Cluster.remove(clusterId)
+                .then(() => mongo.Space.find({$or: [{owner: userId}, {usedBy: {$elemMatch:
{account: userId}}}]}))
+                .then((spaces) => {
+                    spacesIds = spaces.map((value) => value._id);
+
+                    return mongo.Cache.update(mongo.Cache.update({space: {$in: spacesIds}},
{$pull: {clusters: clusterId}}, {multi: true}));
+                })
+                .then(() => mongo.Cache.update(mongo.Igfs.update({space: {$in: spacesIds}},
{$pull: {clusters: clusterId}}, {multi: true})))
+                .then(() => res.sendStatus(200))
+                .catch((err) => {
+                    // TODO IGNITE-843 Send error to admin
+                    res.status(500).send(err.message);
+                });
         });
 
         /**


Mime
View raw message