ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [26/29] git commit: AMBARI-7356.When the user completes Install Wizard, mark Clusters.provisioning_state as INSTALLED. (akovalenko)
Date Wed, 17 Sep 2014 12:34:16 GMT
AMBARI-7356.When the user completes Install Wizard, mark Clusters.provisioning_state as INSTALLED.
(akovalenko)


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

Branch: refs/heads/branch-alerts-dev
Commit: f63dd8a6eea79defd93837dbfc3011f42692ae91
Parents: e033815
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Wed Sep 17 14:06:44 2014 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Wed Sep 17 14:06:44 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/installer.js | 15 +++++
 ambari-web/app/models/cluster_states.js |  1 -
 ambari-web/app/router.js                | 84 ++++++++++++++++------------
 ambari-web/app/routes/installer.js      | 12 ++--
 ambari-web/app/utils/ajax/ajax.js       | 17 +++++-
 5 files changed, 84 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f63dd8a6/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index e45eaee..d933e9a 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -745,6 +745,21 @@ App.InstallerController = App.WizardController.extend({
     App.router.get('applicationController').postUserPref(persists, true);
   },
 
+  /**
+   * Save cluster provisioning state to the server
+   * @param state cluster provisioning state
+   * @param callback is called after request completes
+   */
+  setClusterProvisioningState: function (state, callback) {
+    App.ajax.send({
+      name: 'cluster.save_provisioning_state',
+      sender: this,
+      data: {
+        state: state
+      }
+    }).complete(callback());
+  },
+
   setStepsEnable: function () {
     for (var i = 0; i <= this.totalSteps; i++) {
       var step = this.get('isStepDisabled').findProperty('step', i);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f63dd8a6/ambari-web/app/models/cluster_states.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/cluster_states.js b/ambari-web/app/models/cluster_states.js
index 49760d6..95c1444 100644
--- a/ambari-web/app/models/cluster_states.js
+++ b/ambari-web/app/models/cluster_states.js
@@ -108,7 +108,6 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
    * @method updateFromServer
    */
   updateFromServer: function (overrideLocaldb) {
-    // if overrideLocaldb is undefined, set it to true
     this.set('additionalData', {
       user: App.db.getUser(),
       login: App.db.getLoginName(),

http://git-wip-us.apache.org/repos/asf/ambari/blob/f63dd8a6/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index 18203f2..bbc06dd 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -29,6 +29,12 @@ App.Router = Em.Router.extend({
   enableLogging: true,
   isFwdNavigation: true,
   backBtnForHigherStep: false,
+
+  /**
+   * Is true, if cluster.provisioning_state is equal to 'INSTALLED'
+   * @type {Boolean}
+   */
+  clusterInstallCompleted: false,
   /**
    * user prefered path to route
    */
@@ -119,6 +125,9 @@ App.Router = Em.Router.extend({
 
   onAuthenticationSuccess: function (data) {
     this.set('loggedIn', true);
+    if (data.items.length) {
+      this.set('clusterInstallCompleted', data.items[0].Clusters.provisioning_state === 'INSTALLED');
+    }
   },
 
   onAuthenticationError: function (data) {
@@ -265,7 +274,7 @@ App.Router = Em.Router.extend({
       App.usersMapper.map({"items": [loginData]});
       router.setUserLoggedIn(params.loginName);
       var permissionList = privileges.items.mapProperty('PrivilegeInfo.permission_name');
-      var isAdmin = permissionList.indexOf('AMBARI.ADMIN') > -1;
+      var isAdmin = permissionList.contains('AMBARI.ADMIN');
       var transitionToApp = false;
       if (isAdmin) {
         App.set('isAdmin', true);
@@ -277,14 +286,15 @@ App.Router = Em.Router.extend({
         }
       } else {
         if (clustersData.items.length) {
+          this.set('clusterInstallCompleted', clustersData.items[0].Clusters.provisioning_state
=== 'INSTALLED');
           //TODO: Iterate over clusters
           var clusterName = clustersData.items[0].Clusters.cluster_name;
           var clusterPermissions = privileges.items.filterProperty('PrivilegeInfo.cluster_name',
clusterName).mapProperty('PrivilegeInfo.permission_name');
-          if (clusterPermissions.indexOf('CLUSTER.OPERATE') > -1) {
+          if (clusterPermissions.contains('CLUSTER.OPERATE')) {
             App.set('isAdmin', true);
             App.set('isOperator', true);
             transitionToApp = true;
-          } else if (clusterPermissions.indexOf('CLUSTER.READ') > -1) {
+          } else if (clusterPermissions.contains('CLUSTER.READ')) {
             transitionToApp = true;
           }
         }
@@ -317,40 +327,42 @@ App.Router = Em.Router.extend({
       } else {
         callback('main.dashboard.index');
       }
-    }
-    App.clusterStatus.updateFromServer(false).complete(function () {
-      var clusterStatusOnServer = App.clusterStatus.get('value');
-      // if wizardControllerName == "installerController", then it means someone closed the
browser or the browser was crashed when we were last in Installer wizard
-      var route = 'installer';
-      if (!App.get('isAdmin') || clusterStatusOnServer && (clusterStatusOnServer.clusterState
=== 'DEFAULT' || clusterStatusOnServer.clusterState === 'CLUSTER_STARTED_5')) {
-        route = 'main.dashboard.index';
-      } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('addHostController.name')) {
-        // if wizardControllerName == "addHostController", then it means someone closed the
browser or the browser was crashed when we were last in Add Hosts wizard
-        route = 'main.hostAdd';
-      } else if (clusterStatusOnServer && (clusterStatusOnServer.wizardControllerName
=== App.router.get('addSecurityController.name') || clusterStatusOnServer.wizardControllerName
=== App.router.get('mainAdminSecurityDisableController.name'))) {
-        // if wizardControllerName == "addSecurityController", then it means someone closed
the browser or the browser was crashed when we were last in Add Security wizard
-        route = 'main.admin.adminSecurity';
-      } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('addServiceController.name')) {
-        // if wizardControllerName == "addHostController", then it means someone closed the
browser or the browser was crashed when we were last in Add Hosts wizard
-        route = 'main.serviceAdd';
-      } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('stackUpgradeController.name')) {
-        // if wizardControllerName == "stackUpgradeController", then it means someone closed
the browser or the browser was crashed when we were last in Stack Upgrade wizard
-        route = 'main.stackUpgrade';
-      } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('reassignMasterController.name')) {
-        // if wizardControllerName == "reassignMasterController", then it means someone closed
the browser or the browser was crashed when we were last in Reassign Master wizard
-        route = 'main.reassign';
-      } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('highAvailabilityWizardController.name')) {
-        // if wizardControllerName == "highAvailabilityWizardController", then it means someone
closed the browser or the browser was crashed when we were last in NameNode High Availability
wizard
-        route = 'main.services.enableHighAvailability';
-      } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('rMHighAvailabilityWizardController.name')) {
-        // if wizardControllerName == "highAvailabilityWizardController", then it means someone
closed the browser or the browser was crashed when we were last in NameNode High Availability
wizard
-        route = 'main.services.enableRMHighAvailability';
-      } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('rollbackHighAvailabilityWizardController.name')) {
-        // if wizardControllerName == "highAvailabilityRollbackController", then it means
someone closed the browser or the browser was crashed when we were last in NameNode High Availability
Rollback wizard
-        route = 'main.services.rollbackHighAvailability';
+    } else {
+      if (this.get('clusterInstallCompleted')) {
+        App.clusterStatus.updateFromServer(false).complete(function () {
+          var clusterStatusOnServer = App.clusterStatus.get('value');
+          var route = 'main.dashboard.index';
+          if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('addHostController.name')) {
+            // if wizardControllerName == "addHostController", then it means someone closed
the browser or the browser was crashed when we were last in Add Hosts wizard
+            route = 'main.hostAdd';
+          } else if (clusterStatusOnServer && (clusterStatusOnServer.wizardControllerName
=== App.router.get('addSecurityController.name') || clusterStatusOnServer.wizardControllerName
=== App.router.get('mainAdminSecurityDisableController.name'))) {
+            // if wizardControllerName == "addSecurityController", then it means someone
closed the browser or the browser was crashed when we were last in Add Security wizard
+            route = 'main.admin.adminSecurity';
+          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('addServiceController.name')) {
+            // if wizardControllerName == "addHostController", then it means someone closed
the browser or the browser was crashed when we were last in Add Hosts wizard
+            route = 'main.serviceAdd';
+          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('stackUpgradeController.name')) {
+            // if wizardControllerName == "stackUpgradeController", then it means someone
closed the browser or the browser was crashed when we were last in Stack Upgrade wizard
+            route = 'main.stackUpgrade';
+          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('reassignMasterController.name')) {
+            // if wizardControllerName == "reassignMasterController", then it means someone
closed the browser or the browser was crashed when we were last in Reassign Master wizard
+            route = 'main.reassign';
+          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('highAvailabilityWizardController.name')) {
+            // if wizardControllerName == "highAvailabilityWizardController", then it means
someone closed the browser or the browser was crashed when we were last in NameNode High Availability
wizard
+            route = 'main.services.enableHighAvailability';
+          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('rMHighAvailabilityWizardController.name')) {
+            // if wizardControllerName == "highAvailabilityWizardController", then it means
someone closed the browser or the browser was crashed when we were last in NameNode High Availability
wizard
+            route = 'main.services.enableRMHighAvailability';
+          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('rollbackHighAvailabilityWizardController.name')) {
+            // if wizardControllerName == "highAvailabilityRollbackController", then it means
someone closed the browser or the browser was crashed when we were last in NameNode High Availability
Rollback wizard
+            route = 'main.services.rollbackHighAvailability';
+          }
+          callback(route);
+        });
+      } else {
+        callback('installer');
       }
-      callback(route);
-    });
+    }
   },
 
   logOff: function (context) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/f63dd8a6/ambari-web/app/routes/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js
index 0ca109a..a414ff4 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -79,7 +79,7 @@ module.exports = Em.Route.extend({
             });
           } else {
             Em.run.next(function () {
-              App.router.transitionTo('main.services');
+              App.router.transitionTo('main.views.index');
             });
           }
 
@@ -436,11 +436,11 @@ module.exports = Em.Route.extend({
     complete: function (router, context) {
       var controller = router.get('installerController');
       controller.finish();
-
-      // We need to do recovery based on whether we are in Add Host or Installer wizard
-      controller.saveClusterState('DEFAULT');
-
-      router.transitionTo('main.dashboard.index');
+      controller.setClusterProvisioningState('INSTALLED', function () {
+        // We need to do recovery based on whether we are in Add Host or Installer wizard
+        controller.saveClusterState('DEFAULT');
+        router.transitionTo('main.dashboard.index');
+      });
     }
   }),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f63dd8a6/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 2dceaa5..4342195 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -911,6 +911,19 @@ var urls = {
       };
     }
   },
+  'cluster.save_provisioning_state': {
+    'real': '/clusters/{clusterName}',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          "Clusters": {
+            "provisioning_state": data.state
+          }
+        })
+      };
+    }
+  },
   'admin.high_availability.polling': {
     'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*,Requests/*',
     'mock': ''
@@ -1368,7 +1381,7 @@ var urls = {
     mock: '/data/users/privileges_{userName}.json'
   },
   'router.login.clusters': {
-    'real': '/clusters',
+    'real': '/clusters?fields=Clusters/provisioning_state',
     'mock': '/data/clusters/info.json'
   },
   'router.logoff': {
@@ -1376,7 +1389,7 @@ var urls = {
     'mock': ''
   },
   'router.authentication': {
-    'real': '/clusters',
+    'real': '/clusters?fields=Clusters/provisioning_state',
     'mock': '/data/clusters/info.json',
     'format': function() {
       return {


Mime
View raw message