This is an automated email from the ASF dual-hosted git repository.
ishanbha pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new b2bbc85 [AMBARI-24790] Restart Masters for Service Restart.
b2bbc85 is described below
commit b2bbc8536b2fd5f3f8a211c53f42b46467810229
Author: Ishan Bhatt <[email protected]>
AuthorDate: Tue Oct 16 09:23:56 2018 -0700
[AMBARI-24790] Restart Masters for Service Restart.
---
ambari-web/app/controllers/main/service/item.js | 68 +++++++++++++++++++++-
ambari-web/app/utils/batch_scheduled_requests.js | 58 +++++++++++++++++-
.../app/views/common/service_restart_view.js | 1 -
3 files changed, 122 insertions(+), 5 deletions(-)
diff --git a/ambari-web/app/controllers/main/service/item.js
b/ambari-web/app/controllers/main/service/item.js
index 6fb0522..d615548 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -967,8 +967,72 @@ App.MainServiceItemController =
Em.Controller.extend(App.SupportClientConfigsDow
},
chooseAndRestartHostComponents: function () {
- let serviceName = this.get('serviceName');
- batchUtils.showServicRestartPopup(serviceName);
+ let serviceName = this.get('content.serviceName');
+ const mastersForRestart = serviceName === 'HDFS' ?
this.getMastersForHdfsRestart(): this.getMastersForRestart(serviceName);
+ batchUtils.showServiceRestartPopup(serviceName, mastersForRestart);
+ },
+
+ getMastersForRestart: function (serviceName) {
+ return this.get('content.hostComponents').filter((component) =>{
+ return component.get('service.serviceName') === serviceName &&
component.get('isMaster');
+ });
+ },
+
+ getMastersForHdfsRestart: function () {
+ const self = this;
+ let hostCompOrdered = [];
+ const hdfsService = App.HDFSService.find().toArray()[0];
+
+ if (App.get('isHAEnabled')) {
+ let journalNodes =
this.get('content.hostComponents').filterProperty('componentName',
'JOURNALNODE');
+ //Restart journal nodes one by one
+ if (journalNodes && journalNodes.length) {
+ journalNodes.forEach((journalNode) =>
hostCompOrdered.push(journalNode));
+ }
+
+ //Restart Standby NN and then Standby ZKFC
+ const standbyNameNodes = hdfsService.get('standbyNameNodes').toArray();
+ if (standbyNameNodes.length > 0) {
+ hdfsService.get('standbyNameNodes').forEach(function (snn) {
+ hostCompOrdered.push(snn);
+ const snnHostName = snn.get('hostName');
+ const zkfcForSnn =
self.get('content.hostComponents').filter((component) => {
+ return component.get('componentName') === 'ZKFC' &&
component.get('hostName') === snnHostName;
+ });
+ if (zkfcForSnn) {
+ hostCompOrdered.push(zkfcForSnn[0]);
+ }
+ });
+ }
+
+ //Restart Active NN and then Active ZKFC
+ const activeNameNodes = hdfsService.get('activeNameNodes').toArray();
+ if (activeNameNodes.length > 0) {
+ hdfsService.get('activeNameNodes').forEach(function (ann) {
+ hostCompOrdered.push(ann);
+ const annHostName = ann.get('hostName');
+ const zkfcForAnn =
self.get('content.hostComponents').filter((component) => {
+ return component.get('componentName') === 'ZKFC' &&
component.get('hostName') === annHostName;
+ });
+ if (zkfcForAnn) {
+ hostCompOrdered.push(zkfcForAnn[0]);
+ }
+ });
+ }
+ } else {
+
+ //Add SNamenode
+ if (!standbyNameNodes.length > 0 && hdfsService.get('snameNode')) {
+ hostCompOrdered.push(hdfsService.get('snameNode'));
+ }
+ const sNameNode = hdfsService.get('snameNode') ||
App.HostComponent.find().findProperty('componentName', 'SECONDARY_NAMENODE')
+ if (sNameNode) hostCompOrdered.push(sNameNode);
+
+ //Add NameNode
+ const namenode = hdfsService.get('namenode') ||
App.HostComponent.find().findProperty('componentName', 'SECONDARY_NAMENODE');
+ if (namenode) hostCompOrdered.push(namenode);
+ }
+ return hostCompOrdered;
},
restartCertainHostComponents: function (context) {
diff --git a/ambari-web/app/utils/batch_scheduled_requests.js
b/ambari-web/app/utils/batch_scheduled_requests.js
index 33173cc..1ab73df 100644
--- a/ambari-web/app/utils/batch_scheduled_requests.js
+++ b/ambari-web/app/utils/batch_scheduled_requests.js
@@ -500,7 +500,9 @@ module.exports = {
},
- showServicRestartPopup: function (serviceName) {
+ showServiceRestartPopup: function (serviceName, masterComponents,
slaveComponents) {
+
+ let self = this;
App.ModalPopup.show({
header: Em.I18n.t('common.configure.restart'),
@@ -510,11 +512,63 @@ module.exports = {
primary: Em.I18n.t('common.restart'),
primaryClass: 'btn-warning',
classNames: ['common-modal-wrapper'],
- modalDialogClasses: ['modal-lg']
+ modalDialogClasses: ['modal-lg'],
+ onPrimary: function () {
+ let batches = [];
+ for (let i=0; i<masterComponents.length; i++) {
+ const hostName = masterComponents[i].get('hostName');
+ const component = masterComponents[i].get('componentName');
+ const context = "RESTART " + masterComponents[i].get('displayName');
+ batches.push({
+ "order_id": i+1,
+ "type": 'POST',
+ "uri": "/clusters/" + App.get('clusterName') + "/requests/",
+ "RequestBodyInfo": {
+ "RequestInfo": {
+ "command": "RESTART",
+ "context": context,
+ },
+ "Requests/resource_filters": [{
+ "service_name": serviceName,
+ "component_name": component,
+ "hosts": hostName
+ }]
+ }
+ })
+ }
+ App.ajax.send({
+ name: 'common.batch.request_schedules',
+ sender: self,
+ data: {
+ intervalTimeSeconds: 1,
+ tolerateSize: 0,
+ batches: batches
+ },
+ success: 'serviceRestartSuccess',
+ showLoadingPopup: true
+ });
+ this._super();
+ }
})
},
+ serviceRestartSuccess: function (data) {
+ if (data && (data.Requests || data.resources[0].RequestSchedule)) {
+
App.router.get('userSettingsController').dataLoading('show_bg').done(function
(initValue) {
+ if (initValue) {
+ App.router.get('backgroundOperationsController').showPopup();
+ }
+ if (typeof callback === 'function') {
+ callback();
+ }
+ });
+ return true;
+ } else {
+ return false;
+ }
+ },
+
/**
* Show warning popup about not supported host components
* @param {String} hostComponentName
diff --git a/ambari-web/app/views/common/service_restart_view.js
b/ambari-web/app/views/common/service_restart_view.js
index b6566e8..1351751 100644
--- a/ambari-web/app/views/common/service_restart_view.js
+++ b/ambari-web/app/views/common/service_restart_view.js
@@ -40,7 +40,6 @@ App.ServiceRestartView = Em.View.extend({
this.set('maxFailuresRack', 2);
this.set('suppressAlerts', true);
this.set('pauseAfterFirst', false);
-
},
rollingRestartRadioButton: App.RadioButtonView.extend({