Browse Source

AMBARI-5477. Flume host component should have stop/start/restart actions. (akovalenko)

Aleksandr Kovalenko 11 years ago
parent
commit
a0f09837ae

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

@@ -250,6 +250,7 @@ module.exports = Em.Application.create({
       deletable: this.StackServiceComponent.find().filterProperty('isDeletable',true).mapProperty('componentName'),
       rollinRestartAllowed: this.StackServiceComponent.find().filterProperty('isRollinRestartAllowed',true).mapProperty('componentName'),
       decommissionAllowed: this.StackServiceComponent.find().filterProperty('isDecommissionAllowed',true).mapProperty('componentName'),
+      refreshConfigsAllowed: this.StackServiceComponent.find().filterProperty('isRefreshConfigsAllowed',true).mapProperty('componentName'),
       addableToHost: this.StackServiceComponent.find().filterProperty('isAddableToHost',true).mapProperty('componentName'),
       slaves: this.StackServiceComponent.find().filterProperty('isMaster',false).filterProperty('isClient',false).mapProperty('componentName'),
       masters: this.StackServiceComponent.find().filterProperty('isMaster',true).mapProperty('componentName'),

+ 53 - 0
ambari-web/app/controllers/main/host/details.js

@@ -656,6 +656,59 @@ App.MainHostDetailsController = Em.Controller.extend({
     });
   },
 
+  /**
+   * Send command to server to resfresh configs of selected component
+   * @param {object} event
+   * @method refreshComponentConfigs
+   */
+  refreshComponentConfigs: function (event) {
+    var self = this;
+    App.showConfirmationPopup(function() {
+      var component = event.context;
+      var context = Em.I18n.t('requestInfo.refreshComponentConfigs').format(component.get('displayName'));
+      self.sendRefreshComponentConfigsCommand(component, context);
+    });
+  },
+
+  /**
+   * PUTs a command to server to refresh configs of host component.
+   * @param {object} component
+   * @param {object} context Context under which this command is beign sent.
+   * @method sendRefreshComponentConfigsCommand
+   */
+  sendRefreshComponentConfigsCommand: function (component, context) {
+    resource_filters = [
+      {
+        service_name: component.get('service.serviceName'),
+        component_name: component.get('componentName'),
+        hosts: component.get('host.hostName')
+      }
+    ];
+    App.ajax.send({
+      name: 'host.host_component.refresh_configs',
+      sender: this,
+      data: {
+        resource_filters: resource_filters,
+        context: context
+      },
+      success: 'refreshComponentConfigsSuccessCallback'
+    });
+  },
+
+  /**
+   * Success callback for refresh host component configs request
+   * @method refreshComponentConfigsSuccessCallback
+   */
+  refreshComponentConfigsSuccessCallback: function() {
+    console.log('Send request for refresh configs successfully');
+    // load data (if we need to show this background operations popup) from persist
+    App.router.get('applicationController').dataLoading().done(function (showPopup) {
+      if (showPopup) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
+    });
+  },
+
   /**
    * Load tags
    * @method checkZkConfigs

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

@@ -226,6 +226,7 @@ Em.I18n.translations = {
   'requestInfo.stopHostComponent':'Stop',
   'requestInfo.installHostComponent':'Install',
   'requestInfo.installNewHostComponent':'Install',
+  'requestInfo.refreshComponentConfigs':'Refresh {0} configs',
   'requestInfo.stop':'Stop {0}',
   'requestInfo.start':'Start {0}',
   'requestInfo.unspecified':'Request name not specified',

+ 4 - 0
ambari-web/app/models/stack_service_component.js

@@ -58,6 +58,10 @@ App.StackServiceComponent = DS.Model.extend({
     return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER"].contains(this.get('componentName'));
   }.property('componentName'),
 
+  isRefreshConfigsAllowed: function() {
+    return ["FLUME_HANDLER"].contains(this.get('componentName'));
+  }.property('componentName'),
+
   isAddableToHost: function() {
     return ["DATANODE", "TASKTRACKER", "NODEMANAGER", "HBASE_REGIONSERVER", "HBASE_MASTER", "ZOOKEEPER_SERVER", "SUPERVISOR"].contains(this.get('componentName'));
   }.property('componentName'),

+ 7 - 0
ambari-web/app/templates/main/host/details/host_component.hbs

@@ -115,6 +115,13 @@
                 </a>
             </li>
         {{/if}}
+        {{#if view.isRefreshConfigsAllowed}}
+            <li>
+                <a href="javascript:void(null)" data-toggle="modal" {{action "refreshComponentConfigs" view.content target="controller"}}>
+                  {{t hosts.host.details.refreshConfigs}}
+                </a>
+            </li>
+        {{/if}}
       </ul>
     </div>
   {{/if}}

+ 18 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -603,6 +603,24 @@ var urls = {
       }
     }
   },
+
+  'host.host_component.refresh_configs': {
+    'real':'/clusters/{clusterName}/requests',
+    'mock':'',
+    'format': function(data) {
+      return {
+        type : 'POST',
+        data : JSON.stringify({
+          "RequestInfo": {
+            "command": "CONFIGURE",
+            "context": data.context
+          },
+          "Requests/resource_filters": data.resource_filters
+        })
+      }
+    }
+  },
+
   'host.delete': {
     'real': '/clusters/{clusterName}/hosts/{hostName}',
     'mock': '',

+ 8 - 0
ambari-web/app/views/main/host/details/host_component_view.js

@@ -232,6 +232,14 @@ App.HostComponentView = Em.View.extend({
     return ![App.HostComponentStatus.started].contains(this.get('workStatus'));
   }.property('workStatus'),
 
+  /**
+   * Check if component configs can be refreshed
+   * @type {bool}
+   */
+  isRefreshConfigsAllowed: function() {
+    return App.get('components.refreshConfigsAllowed').contains(this.get('content.componentName'));
+  }.property('content'),
+
   didInsertElement: function () {
     App.tooltip($('[rel=componentHealthTooltip]'));
     App.tooltip($('[rel=passiveTooltip]'));