浏览代码

AMBARI-1482. Reassign Master Wizard - Step 1. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1449226 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 年之前
父节点
当前提交
40ace6619a

+ 2 - 0
CHANGES.txt

@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1482. Reassign Master Wizard - Step 1. (yusaku)
+
  AMBARI-1481. Stack Upgrade Wizard - Step 2 (confirm and check all master
  components are running). (yusaku)
 

+ 2 - 0
ambari-web/app/controllers.js

@@ -39,6 +39,7 @@ require('controllers/main/service/info/summary');
 require('controllers/main/service/info/configs');
 require('controllers/main/service/info/audit');
 require('controllers/main/service/add_controller');
+require('controllers/main/service/reassign_controller');
 require('controllers/main/host');
 require('controllers/main/host/details');
 require('controllers/main/host/add_controller');
@@ -71,6 +72,7 @@ require('controllers/wizard/step7_controller');
 require('controllers/wizard/step8_controller');
 require('controllers/wizard/step9_controller');
 require('controllers/wizard/step10_controller');
+require('controllers/wizard/step11_controller');
 require('controllers/wizard/stack_upgrade/step1_controller');
 require('controllers/wizard/stack_upgrade/step2_controller');
 require('controllers/global/cluster_controller');

+ 2 - 8
ambari-web/app/controllers/main/service/item.js

@@ -193,14 +193,8 @@ App.MainServiceItemController = Em.Controller.extend({
    */
   reassignMaster: function (hostComponent) {
     console.log('In Reassign Master', hostComponent);
-    App.ModalPopup.show({
-      header: 'Reassign Master Wizard',
-      body: 'Reassign Master Wizard',
-      secondary: false,
-      onPrimary: function() {
-        this.hide();
-      }
-    });
+    App.router.get('reassignMasterController').saveComponentToReassign(hostComponent);
+    App.router.transitionTo('reassignMaster');
   },
 
   /**

+ 200 - 0
ambari-web/app/controllers/main/service/reassign_controller.js

@@ -0,0 +1,200 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+
+App.ReassignMasterController = App.WizardController.extend({
+
+  name: 'reassignMasterController',
+
+  totalSteps: 6,
+
+  /**
+   * Used for hiding back button in wizard
+   */
+  hideBackButton: true,
+
+  /**
+   * All wizards data will be stored in this variable
+   *
+   * cluster - cluster name
+   * installOptions - ssh key, repo info, etc.
+   * services - services list
+   * hosts - list of selected hosts
+   * slaveComponentHosts, - info about slave hosts
+   * masterComponentHosts - info about master hosts
+   * config??? - to be described later
+   */
+  content: Em.Object.create({
+    cluster: null,
+    hosts: null,
+    installOptions: null,
+    services: null,
+    slaveComponentHosts: null,
+    masterComponentHosts: null,
+    serviceConfigProperties: null,
+    advancedServiceConfig: null,
+    controllerName: 'reassignMasterController',
+    isWizard: true,
+    reassign: null
+  }),
+
+  /**
+   * return new object extended from clusterStatusTemplate
+   * @return Object
+   */
+  getCluster: function(){
+    return jQuery.extend({}, this.get('clusterStatusTemplate'), {name: App.router.getClusterName()});
+  },
+
+  /**
+   * return true if cluster data is loaded and false otherwise
+   */
+  dataLoading: function(){
+    var dfd = $.Deferred();
+    this.connectOutlet('loading');
+    if (App.router.get('clusterController.isLoaded')){
+      dfd.resolve();
+    } else{
+      var interval = setInterval(function(){
+        if (App.router.get('clusterController.isLoaded')){
+          dfd.resolve();
+          clearInterval(interval);
+        }
+      },50);
+    }
+    return dfd.promise();
+  },
+
+  /**
+   * Load services data from server.
+   */
+  loadServicesFromServer: function() {
+    var displayOrderConfig = require('data/services');
+    var apiUrl = App.get('stackVersionURL');
+    var apiService = this.loadServiceComponents(displayOrderConfig, apiUrl);
+    //
+    apiService.forEach(function(item, index){
+      apiService[index].isSelected = App.Service.find().someProperty('id', item.serviceName);
+      apiService[index].isDisabled = apiService[index].isSelected;
+      apiService[index].isInstalled = apiService[index].isSelected;
+    });
+    this.set('content.services', apiService);
+    App.db.setService(apiService);
+  },
+
+  /**
+   * Load confirmed hosts.
+   * Will be used at <code>Assign Masters(step5)</code> step
+   */
+  loadConfirmedHosts: function(){
+    var hosts = App.db.getHosts();
+    if(!hosts || !hosts.length){
+      var hosts = {};
+
+      App.Host.find().forEach(function(item){
+        hosts[item.get('id')] = {
+          name: item.get('id'),
+          cpu: item.get('cpu'),
+          memory: item.get('memory'),
+          disk_info: item.get('diskInfo'),
+          bootStatus: "REGISTERED",
+          isInstalled: true
+        };
+      });
+      App.db.setHosts(hosts);
+    }
+
+    this.set('content.hosts', hosts);
+    console.log('ReassignMasterController.loadConfirmedHosts: loaded hosts', hosts);
+  },
+
+  /**
+   * Load master component hosts data for using in required step controllers
+   */
+  loadMasterComponentHosts: function () {
+    var masterComponentHosts = App.db.getMasterComponentHosts();
+    if(!masterComponentHosts){
+      masterComponentHosts = [];
+      App.HostComponent.find().filterProperty('isMaster', true).forEach(function(item){
+        masterComponentHosts.push({
+          component: item.get('componentName'),
+          hostName: item.get('host.hostName'),
+          isInstalled: true
+        })
+      });
+
+    }
+    this.set("content.masterComponentHosts", masterComponentHosts);
+    console.log("ReassignMasterController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
+
+    this.set('content.missMasterStep', this.get('content.masterComponentHosts').everyProperty('isInstalled', true));
+  },
+
+  loadComponentToReassign: function () {
+    var masterComponent = App.db.getMasterToReassign();
+    if (masterComponent) {
+      this.set('content.reassign', masterComponent);
+    }
+  },
+
+  saveComponentToReassign: function (masterComponent) {
+      App.db.setMasterToReassign(masterComponent);
+  },
+
+  /**
+   * Load data for all steps until <code>current step</code>
+   */
+  loadAllPriorSteps: function () {
+    var step = this.get('currentStep');
+    switch (step) {
+      case '6':
+      case '5':
+      case '4':
+      case '3':
+      case '2':
+        this.loadServicesFromServer();
+        this.loadMasterComponentHosts();
+        this.loadConfirmedHosts();
+      case '1':
+        this.loadComponentToReassign();
+    }
+  },
+
+  /**
+   * Remove all loaded data.
+   * Created as copy for App.router.clearAllSteps
+   */
+  clearAllSteps: function () {
+    this.clearInstallOptions();
+    // clear temporary information stored during the install
+    this.set('content.cluster', this.getCluster());
+  },
+
+  /**
+   * Clear all temporary data
+   */
+  finish: function () {
+    this.setCurrentStep('1');
+    this.clearAllSteps();
+    this.clearStorageData();
+    App.router.get('updateController').updateAll();
+  }
+
+});

+ 22 - 0
ambari-web/app/controllers/wizard/step11_controller.js

@@ -0,0 +1,22 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.WizardStep11Controller = Em.Controller.extend();
+

+ 2 - 0
ambari-web/app/messages.js

@@ -388,6 +388,7 @@ Em.I18n.translations = {
   'installer.step10.startStatus.started':'All services started',
   'installer.step10.installTime.seconds':'Install and start completed in {0} seconds',
   'installer.step10.installTime.minutes':'Install and start completed in {0} minutes and {1} seconds',
+  'installer.step11.header':'Prerequisites',
 
   'installer.stackUpgrade.header':'Stack Upgrade Wizard',
   'installer.stackUpgrade.step1.newVersion':'New Version',
@@ -621,6 +622,7 @@ Em.I18n.translations = {
   'services.service.config.failSaveConfig':'Failure in applying service configuration',
 
   'services.add.header':'Add Service Wizard',
+  'services.reassign.header':'Reassign Master Wizard',
   'services.service.add':'Add Service',
 
 

+ 1 - 0
ambari-web/app/router.js

@@ -39,6 +39,7 @@ App.Router = Em.Router.extend({
     this.get('addHostController').clear();
     this.get('addServiceController').clear();
     this.get('stackUpgradeController').clear();
+    this.get('reassignMasterController').clear();
     for (i = 1; i < 11; i++) {
       this.set('wizardStep' + i + 'Controller.hasSubmitted', false);
       this.set('wizardStep' + i + 'Controller.isDisabled', true);

+ 2 - 0
ambari-web/app/routes/main.js

@@ -355,6 +355,8 @@ module.exports = Em.Route.extend({
   }),
 
   serviceAdd:require('routes/add_service_routes'),
+  reassignMaster:require('routes/reassign_master_routes'),
+
 
   selectService:Em.Route.transitionTo('services.service'),
   selectHost:function (router, event) {

+ 88 - 0
ambari-web/app/routes/reassign_master_routes.js

@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = Em.Route.extend({
+  route: '/services/reassign',
+
+  enter: function (router) {
+    console.log('in /service/reassign:enter');
+      Em.run.next(function () {
+        var reassignMasterController = router.get('reassignMasterController');
+        App.router.get('updateController').set('isWorking', false);
+        App.ModalPopup.show({
+          classNames: ['full-width-modal'],
+          header:Em.I18n.t('services.reassign.header'),
+          bodyClass:  App.ReassignMasterView.extend({
+            controller: reassignMasterController
+          }),
+          primary:Em.I18n.t('form.cancel'),
+          showFooter: false,
+          secondary: null,
+
+          onPrimary:function () {
+            this.hide();
+            App.router.get('updateController').set('isWorking', true);
+            App.router.transitionTo('main.services');
+          },
+          onClose: function() {
+            this.hide();
+            App.router.get('updateController').set('isWorking', true);
+            App.router.transitionTo('main.services')
+          },
+          didInsertElement: function(){
+            this.fitHeight();
+          }
+        });
+        router.transitionTo('step' + reassignMasterController.get('currentStep'));
+      });
+  },
+
+  step1: Em.Route.extend({
+    route: '/step1',
+    connectOutlets: function (router) {
+      console.log('in reassignMaster.step1:connectOutlets');
+      var controller = router.get('reassignMasterController');
+      controller.setCurrentStep('1');
+      controller.dataLoading().done(function () {
+        controller.loadAllPriorSteps();
+        controller.connectOutlet('wizardStep11');
+      })
+    },
+    next: function (router) {
+      //router.transitionTo('step2');
+    }
+  }),
+
+  gotoStep1: Em.Router.transitionTo('step1'),
+
+  gotoStep2: Em.Router.transitionTo('step2'),
+
+  gotoStep3: Em.Router.transitionTo('step3'),
+
+  gotoStep4: Em.Router.transitionTo('step4'),
+
+  gotoStep5: Em.Router.transitionTo('step5'),
+
+  gotoStep6: Em.Router.transitionTo('step6'),
+
+  backToServices: function (router) {
+    App.router.get('updateController').set('isWorking', true);
+    router.transitionTo('services');
+  }
+
+});

+ 2 - 2
ambari-web/app/styles/application.less

@@ -253,7 +253,7 @@ h1 {
   border-left-color: #dedede;
 }
 
-#installer, #add-host, #add-service {
+.wizard {
   h2 {
     margin-top: 0;
   }
@@ -263,7 +263,7 @@ h1 {
   .btn-area {
     margin-top: 20px;
   }
-  #installer-content, #add-host-content, #add-service-content {
+  .wizard-content {
     padding: 25px;
     background-color: #fff;
 

+ 2 - 2
ambari-web/app/templates/installer.hbs

@@ -16,7 +16,7 @@
 * limitations under the License.
 }}
 
-<div id="installer">
+<div class="wizard">
   <div class="container">
     <div class="container-fluid">
       <div class="row-fluid">
@@ -38,7 +38,7 @@
             </ul>
           </div>
         </div>
-        <div id="installer-content" class="well span9">
+        <div class="wizard-content well span9">
           {{outlet}}
         </div>
       </div>

+ 2 - 2
ambari-web/app/templates/main/host/add.hbs

@@ -16,7 +16,7 @@
 * limitations under the License.
 }}
 
-<div id="add-host">
+<div class="wizard">
   <div class="container">
     <div class="container-fluid">
 
@@ -37,7 +37,7 @@
             </ul>
           </div>
         </div>
-        <div id="add-host-content" class="well span9">
+        <div class="wizard-content well span9">
           {{outlet}}
         </div>
       </div>

+ 2 - 2
ambari-web/app/templates/main/service/add.hbs

@@ -16,7 +16,7 @@
 * limitations under the License.
 }}
 
-<div id="add-service">
+<div class="wizard">
   <div class="container">
     <div class="container-fluid">
 
@@ -38,7 +38,7 @@
             </ul>
           </div>
         </div>
-        <div id="add-service-content" class="well span9">
+        <div class="wizard-content well span9">
           {{outlet}}
         </div>
       </div>

+ 38 - 0
ambari-web/app/templates/main/service/reassign.hbs

@@ -0,0 +1,38 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+<div class="wizard">
+  <div class="container">
+    <div class="container-fluid">
+      <div class="row-fluid">
+        <div class="span3">
+          <!--Sidebar content-->
+          <div class="well">
+            <ul class="nav nav-pills nav-stacked">
+              <li class="nav-header">{{t services.reassign.header}}</li>
+              <li {{bindAttr class="isStep1:active view.isStep1Disabled:disabled"}}><a href="javascript:void(null);"  {{action gotoStep1 target="controller"}}>{{t installer.step11.header}}</a></li>
+            </ul>
+          </div>
+        </div>
+        <div class="wizard-content well span9">
+          {{outlet}}
+        </div>
+      </div>
+    </div>
+  </div>
+</div>

+ 22 - 0
ambari-web/app/templates/wizard/step11.hbs

@@ -0,0 +1,22 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+<h2>{{t installer.step11.header}}</h2>
+<div class="btn-area">
+  <a class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action next}}>{{t common.next}} &rarr;</a>
+</div>

+ 13 - 1
ambari-web/app/utils/db.js

@@ -54,7 +54,8 @@ App.db.cleanUp = function () {
     'Installer' : {},
     'AddHost' : {},
     'AddService' : {},
-    'StackUpgrade' : {}
+    'StackUpgrade' : {},
+    'ReassignMaster' : {}
   };
   console.log("In cleanup./..");
   localStorage.setObject('ambari', App.db.data);
@@ -220,6 +221,12 @@ App.db.setUpgradeOptions = function (upgradeOptions) {
   localStorage.setObject('ambari', App.db.data);
 };
 
+App.db.setMasterToReassign = function (masterComponent) {
+  App.db.data = localStorage.getObject('ambari');
+  App.db.data.ReassignMaster.masterComponent = masterComponent;
+  localStorage.setObject('ambari', App.db.data);
+};
+
 /**
  * Set current step value for specified Wizard Type
  * @param wizardType
@@ -364,6 +371,11 @@ App.db.getCluster = function () {
   return App.db.data.Installer.clusterStatus;
 };
 
+App.db.getMasterToReassign = function () {
+  App.db.data = localStorage.getObject('ambari');
+  return App.db.data.ReassignMaster.masterComponent;
+};
+
 App.db.getUpgradeOptions = function () {
   console.log('TRACE: Entering db:getUpgradeOptions function');
   App.db.data = localStorage.getObject('ambari');

+ 2 - 0
ambari-web/app/views.js

@@ -100,6 +100,7 @@ require('views/main/service/info/metrics/hbase/regionserver_queuesize');
 require('views/main/service/info/metrics/hbase/hlog_split_time');
 require('views/main/service/info/metrics/hbase/hlog_split_size');
 require('views/main/service/add_view');
+require('views/main/service/reassign_view');
 require('views/main/charts/menu');
 require('views/main/charts/heatmap');
 require('views/main/charts/heatmap/heatmap_rack');
@@ -121,6 +122,7 @@ require('views/wizard/step7_view');
 require('views/wizard/step8_view');
 require('views/wizard/step9_view');
 require('views/wizard/step10_view');
+require('views/wizard/step11_view');
 require('views/wizard/stack_upgrade/step1_view');
 require('views/wizard/stack_upgrade/step2_view');
 require('views/loading');

+ 54 - 0
ambari-web/app/views/main/service/reassign_view.js

@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+
+App.ReassignMasterView = Em.View.extend({
+
+  templateName: require('templates/main/service/reassign'),
+
+  isStep1Disabled: function () {
+    return this.isStepDisabled(1);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep2Disabled: function () {
+    return this.isStepDisabled(2);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep3Disabled: function () {
+    return this.isStepDisabled(3);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep4Disabled: function () {
+    return this.isStepDisabled(4);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep5Disabled: function () {
+    return this.isStepDisabled(5);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep6Disabled: function () {
+    return this.isStepDisabled(6);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStepDisabled: function (index) {
+    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
+  }
+
+});

+ 26 - 0
ambari-web/app/views/wizard/step11_view.js

@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+
+App.WizardStep11View = Em.View.extend({
+
+  templateName: require('templates/wizard/step11')
+
+});