You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/03/23 05:50:36 UTC
svn commit: r1460098 - in /incubator/ambari/trunk: ./ ambari-web/app/
ambari-web/app/controllers/main/host/ ambari-web/app/models/
ambari-web/app/styles/ ambari-web/app/templates/main/host/
ambari-web/app/views/main/host/
Author: yusaku
Date: Sat Mar 23 04:50:35 2013
New Revision: 1460098
URL: http://svn.apache.org/r1460098
Log:
AMBARI-1663. Allow adding host components to existing hosts. (Xi Wang via yusaku)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js
incubator/ambari/trunk/ambari-web/app/messages.js
incubator/ambari/trunk/ambari-web/app/models/host_component.js
incubator/ambari/trunk/ambari-web/app/styles/application.less
incubator/ambari/trunk/ambari-web/app/templates/main/host/summary.hbs
incubator/ambari/trunk/ambari-web/app/views/main/host/summary.js
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1460098&r1=1460097&r2=1460098&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Mar 23 04:50:35 2013
@@ -12,6 +12,9 @@ Trunk (unreleased changes):
NEW FEATURES
+ AMBARI-1663. Allow adding host components to existing hosts. (Xi Wang via
+ yusaku)
+
AMBARI-1653. HDFS Mirroring: Display DataSets table. (yusaku)
AMBARI-1658. Implement API/Service Provider for HDFS mirroring. (tbeerbower)
Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js?rev=1460098&r1=1460097&r2=1460098&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/host/details.js Sat Mar 23 04:50:35 2013
@@ -52,12 +52,12 @@ App.MainHostDetailsController = Em.Contr
* @param url
* @param data Object to send
*/
- sendCommandToServer : function(url, postData, callback){
+ sendCommandToServer : function(url, postData, _method, callback){
var url = (App.testMode) ?
'/data/wizard/deploy/poll_1.json' : //content is the same as ours
App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
- var method = App.testMode ? 'GET' : 'PUT';
+ var method = App.testMode ? 'GET' : _method;
$.ajax({
type: method,
@@ -97,7 +97,8 @@ App.MainHostDetailsController = Em.Contr
HostRoles:{
state: 'STARTED'
}
- }, function(requestId){
+ }, 'PUT',
+ function(requestId){
if(!requestId){
return;
@@ -138,14 +139,14 @@ App.MainHostDetailsController = Em.Contr
var self = this;
App.showConfirmationPopup(function() {
var component = event.context;
-
self.sendCommandToServer('/hosts/' + self.get('content.hostName') + '/host_components/' + component.get('componentName').toUpperCase(),{
HostRoles:{
state: 'INSTALLED'
}
- }, function(requestId){
+ }, 'PUT',
+ function(requestId){
if(!requestId){
- return
+ return;
}
console.log('Send request for STOPPING successfully');
@@ -177,6 +178,69 @@ App.MainHostDetailsController = Em.Contr
},
/**
+ * send command to server to install selected host component
+ * @param event
+ */
+ addComponent: function (event, context) {
+ var self = this;
+ var component = event.context;
+ var componentName = component.get('componentName').toUpperCase().toString();
+
+ App.showConfirmationPopup(function() {
+
+ self.sendCommandToServer('/hosts?Hosts/host_name=' + self.get('content.hostName'),{
+ host_components: [{
+ HostRoles:{
+ component_name: componentName
+ }
+ }]
+
+ },
+ 'POST',
+ function(requestId){
+
+ console.log('Send request for ADDING NEW COMPONENT successfully');
+
+ self.sendCommandToServer('/host_components?HostRoles/host_name=' + self.get('content.hostName') + '\&HostRoles/component_name=' + componentName + '\&HostRoles/state=INIT',{
+ HostRoles:{
+ state: 'INSTALLED'
+ }
+ },
+ 'PUT',
+ function(requestId){
+ if(!requestId){
+ return;
+ }
+
+ console.log('Send request for INSTALLING NEW COMPONENT successfully');
+
+ if (App.testMode) {
+ component.set('workStatus', App.HostComponentStatus.installing);
+ setTimeout(function(){
+ component.set('workStatus', App.HostComponentStatus.stopped);
+ },App.testModeDelayForActions);
+ } else {
+ App.router.get('clusterController').loadUpdatedStatus();
+ App.router.get('backgroundOperationsController.eventsArray').push({
+ "when" : function(controller){
+ var result = (controller.getOperationsForRequestId(requestId).length == 0);
+ console.log('installComponent.when = ', result)
+ return result;
+ },
+ "do" : function(){
+ App.router.get('clusterController').loadUpdatedStatus();
+ }
+ });
+ }
+
+ App.router.get('backgroundOperationsController').showPopup();
+
+ });
+ return;
+ });
+ });
+ },
+ /**
* send command to server to run decommission on DATANODE
* @param event
*/
Modified: incubator/ambari/trunk/ambari-web/app/messages.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/messages.js?rev=1460098&r1=1460097&r2=1460098&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/messages.js (original)
+++ incubator/ambari/trunk/ambari-web/app/messages.js Sat Mar 23 04:50:35 2013
@@ -52,6 +52,7 @@ Em.I18n.translations = {
'common.progress':'Progress',
'common.status':'Status',
'common.action':'Action',
+ 'common.addComponent':'Add Component',
'common.remove':'Remove',
'common.retry':'Retry',
'common.show':'Show',
Modified: incubator/ambari/trunk/ambari-web/app/models/host_component.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/host_component.js?rev=1460098&r1=1460097&r2=1460098&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/host_component.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/host_component.js Sat Mar 23 04:50:35 2013
@@ -97,6 +97,7 @@ App.HostComponentStatus = {
stop_failed: "STOP_FAILED",
start_failed: "START_FAILED",
install_failed: "INSTALL_FAILED",
+ installing: "INSTALLING",
getKeyName:function(value){
switch(value){
@@ -114,6 +115,8 @@ App.HostComponentStatus = {
return 'start_failed';
case this.install_failed:
return 'install_failed';
+ case this.installing:
+ return 'installing';
}
return 'none';
}
Modified: incubator/ambari/trunk/ambari-web/app/styles/application.less
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/styles/application.less?rev=1460098&r1=1460097&r2=1460098&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/styles/application.less (original)
+++ incubator/ambari/trunk/ambari-web/app/styles/application.less Sat Mar 23 04:50:35 2013
@@ -1858,10 +1858,16 @@ hr {
border: 1px solid #DEDEDE;
border-radius: 4px;
background: #FFF;
+
+ #add_component{
+ width: 160px;
+ height: 30px;
+ }
}
.host-components .btn-group {
margin: 0 5px 10px 0;
+
}
.background-operations {
Modified: incubator/ambari/trunk/ambari-web/app/templates/main/host/summary.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/host/summary.hbs?rev=1460098&r1=1460097&r2=1460098&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/host/summary.hbs (original)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/host/summary.hbs Sat Mar 23 04:50:35 2013
@@ -90,23 +90,42 @@
{{/view}}
</div>
{{/each}}
- {{#if view.clients.length}}
+ {{!clients and add component button}}
<div class="clients row-fluid">
- <div class="span8 row">
- <div class="span2">{{t common.clients}} / </div>
- <div class="span8">
- {{#each component in view.clients}}
- {{#if component.isLast}}
- {{component.displayName}}
- {{else}}
- {{component.displayName}},
- {{/if}}
- {{/each}}
- </div>
+ <div class="span7 row">
+ {{#if view.clients.length}}
+ <div class="span2">{{t common.clients}} / </div>
+ <div class="span8">
+ {{#each component in view.clients}}
+ {{#if component.isLast}}
+ {{component.displayName}}
+ {{else}}
+ {{component.displayName}},
+ {{/if}}
+ {{/each}}
+ </div>
+ {{/if}}
+ </div>
+ <div class="span5 row">
+ {{#if view.addableComponents.length}}
+ <div class="btn-group">
+ <button id="add_component" class="btn btn-info dropdown-toggle" data-toggle="dropdown">
+ {{t common.addComponent}}
+ <span class="caret pull-right"></span>
+ </button>
+ <ul class="dropdown-menu">
+ {{#each component in view.addableComponents}}
+ <li>
+ <a href="javascript:void(null)" data-toggle="modal" {{action addComponent component target="controller"}}>
+ {{component.displayName}}
+ </a>
+ </li>
+ {{/each}}
+ </ul>
+ </div>
+ {{/if}}
</div>
</div>
- {{/if}}
-
</div>
{{/if}}
</div>
Modified: incubator/ambari/trunk/ambari-web/app/views/main/host/summary.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/host/summary.js?rev=1460098&r1=1460097&r2=1460098&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/host/summary.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/main/host/summary.js Sat Mar 23 04:50:35 2013
@@ -94,14 +94,17 @@ App.MainHostSummaryView = Em.View.extend
var slaveComponents = [];
var masterComponents = [];
this.get('content.hostComponents').forEach(function(component){
- if(component.get('isMaster')){
- masterComponents.push(component);
- } else if(component.get('isSlave')) {
- slaveComponents.push(component);
+ if(component.get('workStatus') != 'INSTALLING'){
+ if(component.get('isMaster')){
+ masterComponents.push(component);
+ } else if(component.get('isSlave')) {
+ slaveComponents.push(component);
+ }
}
+
}, this);
return masterComponents.concat(slaveComponents);
- }.property('content'),
+ }.property('content', 'content.hostComponents.length'),
clients: function(){
var clients = [];
this.get('content.hostComponents').forEach(function(component){
@@ -120,6 +123,46 @@ App.MainHostSummaryView = Em.View.extend
return clients;
}.property('content'),
+ addableComponentObject: Em.Object.extend({
+ componentName: '',
+ displayName: function(){
+ return App.format.role(this.get('componentName'));
+ }.property('componentName')
+ }),
+
+ addableComponents:function(){
+ var components = [];
+ var services = App.Service.find();
+ var dataNodeExists = false;
+ var taskTrackerExists = false;
+ var regionServerExists = false;
+
+ this.get('content.hostComponents').forEach(function(component) {
+ switch (component.get('componentName')) {
+ case 'DATANODE':
+ dataNodeExists = true;
+ break;
+ case 'TASKTRACKER':
+ taskTrackerExists = true;
+ break;
+ case 'HBASE_REGIONSERVER':
+ regionServerExists = true;
+ break;
+ }
+ }, this);
+
+ if (!dataNodeExists) {
+ components.pushObject(this.addableComponentObject.create({ 'componentName': 'DATANODE' }));
+ }
+ if (!taskTrackerExists && services.findProperty('serviceName', 'MAPREDUCE')) {
+ components.pushObject(this.addableComponentObject.create({ 'componentName': 'TASKTRACKER' }));
+ }
+ if (!regionServerExists && services.findProperty('serviceName', 'HBASE')) {
+ components.pushObject(this.addableComponentObject.create({ 'componentName': 'HBASE_REGIONSERVER' }));
+ }
+ return components;
+ }.property('content'),
+
ComponentView: Em.View.extend({
content: null,
didInsertElement: function () {