|
@@ -17,322 +17,129 @@
|
|
|
|
|
|
var App = require('app');
|
|
|
|
|
|
-App.statusMapper = App.QuickDataMapper.create({
|
|
|
+var previousComponentStatuses = {};
|
|
|
+var previousHostStatuses = {};
|
|
|
|
|
|
- config:{
|
|
|
- id:'ServiceInfo.service_name',
|
|
|
- work_status:'ServiceInfo.state'
|
|
|
+App.statusMapper = App.QuickDataMapper.create({
|
|
|
+ model: App.HostComponent,
|
|
|
+ componentServiceMap: {
|
|
|
+ 'NAMENODE': 'HDFS',
|
|
|
+ 'SECONDARY_NAMENODE': 'HDFS',
|
|
|
+ 'DATANODE': 'HDFS',
|
|
|
+ 'HDFS_CLIENT': 'HDFS',
|
|
|
+ 'JOBTRACKER': 'MAPREDUCE',
|
|
|
+ 'TASKTRACKER': 'MAPREDUCE',
|
|
|
+ 'MAPREDUCE_CLIENT': 'MAPREDUCE',
|
|
|
+ 'MAPREDUCE2_CLIENT': 'MAPREDUCE2',
|
|
|
+ 'HISTORYSERVER': 'MAPREDUCE2',
|
|
|
+ 'TEZ_CLIENT': 'TEZ',
|
|
|
+ 'RESOURCEMANAGER': 'YARN',
|
|
|
+ 'YARN_CLIENT': 'YARN',
|
|
|
+ 'NODEMANAGER': 'YARN',
|
|
|
+ 'ZOOKEEPER_SERVER': 'ZOOKEEPER',
|
|
|
+ 'ZOOKEEPER_CLIENT': 'ZOOKEEPER',
|
|
|
+ 'HBASE_MASTER': 'HBASE',
|
|
|
+ 'HBASE_REGIONSERVER': 'HBASE',
|
|
|
+ 'HBASE_CLIENT': 'HBASE',
|
|
|
+ 'PIG': 'PIG',
|
|
|
+ 'SQOOP': 'SQOOP',
|
|
|
+ 'OOZIE_SERVER': 'OOZIE',
|
|
|
+ 'OOZIE_CLIENT': 'OOZIE',
|
|
|
+ 'HIVE_SERVER': 'HIVE',
|
|
|
+ 'HIVE_METASTORE': 'HIVE',
|
|
|
+ 'HIVE_CLIENT': 'HIVE',
|
|
|
+ 'MYSQL_SERVER': 'HIVE',
|
|
|
+ 'HCAT': 'HCATALOG',
|
|
|
+ 'WEBHCAT_SERVER': 'WEBHCAT',
|
|
|
+ 'NAGIOS_SERVER': 'NAGIOS',
|
|
|
+ 'GANGLIA_SERVER': 'GANGLIA',
|
|
|
+ 'GANGLIA_MONITOR': 'GANGLIA',
|
|
|
+ 'KERBEROS_SERVER': 'KERBEROS',
|
|
|
+ 'KERBEROS_ADMIN_CLIENT': 'KERBEROS',
|
|
|
+ 'KERBEROS_CLIENT': 'KERBEROS',
|
|
|
+ 'HUE_SERVER': 'HUE',
|
|
|
+ 'HCFS_CLIENT': 'HCFS'
|
|
|
},
|
|
|
|
|
|
- map:function (json) {
|
|
|
- var start = new Date().getTime();
|
|
|
- console.log('in status mapper');
|
|
|
-
|
|
|
+ map: function (json) {
|
|
|
+ console.time('App.statusMapper execution time');
|
|
|
if (json.items) {
|
|
|
- var result = {};
|
|
|
-
|
|
|
- //host_components
|
|
|
- result = this.parse_host_components(json);
|
|
|
-
|
|
|
- var hostComponents = App.HostComponent.find();
|
|
|
- var servicesMap = {};
|
|
|
- var hostsMap = {};
|
|
|
-
|
|
|
- hostComponents.forEach(function(hostComponent) {
|
|
|
- var item = result[hostComponent.get('id')];
|
|
|
- if (item) {
|
|
|
- hostComponent.set('workStatus', item.work_status);
|
|
|
- if (item.ha_status) {
|
|
|
- hostComponent.set('haStatus', item.ha_status);
|
|
|
- }
|
|
|
- this.countHostComponents(hostComponent, hostsMap, hostsMap[hostComponent.get('host.id')]);
|
|
|
- this.countServiceComponents(hostComponent, servicesMap, servicesMap[hostComponent.get('service.id')]);
|
|
|
+ var hostsCache = App.cache['Hosts'];
|
|
|
+ var hostStatuses = {};
|
|
|
+ var hostComponentStatuses = {};
|
|
|
+ var addedHostComponents = [];
|
|
|
+ var componentServiceMap = this.get('componentServiceMap');
|
|
|
+ var currentComponentStatuses = {};
|
|
|
+ var currentHostStatuses = {};
|
|
|
+
|
|
|
+ json.items.forEach(function (host) {
|
|
|
+ //update hosts, which have status changed
|
|
|
+ if (previousHostStatuses[host.Hosts.host_name] !== host.Hosts.host_status) {
|
|
|
+ hostStatuses[host.Hosts.host_name] = host.Hosts.host_status;
|
|
|
}
|
|
|
- }, this);
|
|
|
-
|
|
|
- json.items.forEach(function (item) {
|
|
|
- item = this.parseIt(item, this.config);
|
|
|
- result[item.id] = item;
|
|
|
- }, this);
|
|
|
-
|
|
|
- var services = App.Service.find();
|
|
|
- services.forEach(function(service) {
|
|
|
- var item = result[service.get('id')];
|
|
|
- if (item) {
|
|
|
- service.set('workStatus', item.work_status);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- this.updateHostsStatus(App.Host.find(), hostsMap);
|
|
|
- this.updateServicesStatus(App.Service.find(), servicesMap);
|
|
|
-
|
|
|
- console.log('out status mapper. Took ' + (new Date().getTime() - start) + 'ms');
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * fill serviceMap with aggregated data of hostComponents for each service
|
|
|
- * @param hostComponent
|
|
|
- * @param servicesMap
|
|
|
- * @param service
|
|
|
- */
|
|
|
- countServiceComponents: function(hostComponent, servicesMap, service){
|
|
|
- if (!service) {
|
|
|
- service = {
|
|
|
- everyStarted: true,
|
|
|
- everyStartedOrMaintenance: true,
|
|
|
- masterComponents: [],
|
|
|
- isStarted: false,
|
|
|
- isUnknown: false,
|
|
|
- isStarting: false,
|
|
|
- isStopped: false,
|
|
|
- isHbaseActive: false,
|
|
|
- serviceName: this.get('serviceName'),
|
|
|
- isRunning: true,
|
|
|
- runningHCs: [],
|
|
|
- unknownHCs: [],
|
|
|
- hdfsHealthStatus: '',
|
|
|
- toolTipContent: ''
|
|
|
- };
|
|
|
- servicesMap[hostComponent.get('service.id')] = service;
|
|
|
- }
|
|
|
- if (hostComponent.get('isMaster')) {
|
|
|
- if (service.everyStartedOrMaintenance) {
|
|
|
- service.everyStartedOrMaintenance = (((hostComponent.get('componentName') === 'NAMENODE' && !App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) || hostComponent.get('componentName') === 'JOURNALNODE') && App.HDFSService.find().filterProperty('activeNameNode.hostName').length > 0)
|
|
|
- ? true : service.everyStartedOrMaintenance = ([App.HostComponentStatus.started, App.HostComponentStatus.maintenance].contains(hostComponent.get('workStatus')));
|
|
|
- } else {
|
|
|
- service.everyStartedOrMaintenance = false;
|
|
|
- }
|
|
|
- service.everyStarted = (service.everyStarted)
|
|
|
- ? (hostComponent.get('workStatus') === App.HostComponentStatus.started)
|
|
|
- : false;
|
|
|
- service.isStarted = (!service.isStarted)
|
|
|
- ? (hostComponent.get('workStatus') === App.HostComponentStatus.started)
|
|
|
- : true;
|
|
|
- service.isUnknown = (!service.isUnknown)
|
|
|
- ? (hostComponent.get('workStatus') === App.HostComponentStatus.unknown)
|
|
|
- : true;
|
|
|
- service.isStarting = (!service.isStarting)
|
|
|
- ? (hostComponent.get('workStatus') === App.HostComponentStatus.starting)
|
|
|
- : true;
|
|
|
- service.isStopped = (!service.isStopped)
|
|
|
- ? (hostComponent.get('workStatus') === App.HostComponentStatus.stopped)
|
|
|
- : true;
|
|
|
- service.isHbaseActive = (!service.isHbaseActive)
|
|
|
- ? (hostComponent.get('haStatus') === 'true')
|
|
|
- : true;
|
|
|
-
|
|
|
- service.masterComponents.push(hostComponent);
|
|
|
-
|
|
|
- // set advanced nameNode display name for HA, active or standby NameNode
|
|
|
- // this is useful on three places: hdfs health status hover tooltip, hdfs service summary and NN component on host detail page
|
|
|
- if (hostComponent.get('componentName') === 'NAMENODE' && !App.HostComponent.find().someProperty('componentName', 'SECONDARY_NAMENODE')) {
|
|
|
- var hostName = hostComponent.get('host.hostName');
|
|
|
- var services = App.Service.find();
|
|
|
- var hdfs;
|
|
|
- services.forEach(function (item) {
|
|
|
- if (item.get("serviceName") == "HDFS") {
|
|
|
- hdfs = App.HDFSService.find(item.get('id'));
|
|
|
- }
|
|
|
- }, this);
|
|
|
- var activeNNText = Em.I18n.t('services.service.summary.nameNode.active');
|
|
|
- var standbyNNText = Em.I18n.t('services.service.summary.nameNode.standby');
|
|
|
- if (hdfs) {
|
|
|
- if (hdfs.get('activeNameNode') && hdfs.get('activeNameNode').get('hostName')) {
|
|
|
- var activeHostname = hdfs.get('activeNameNode').get('hostName');
|
|
|
- }
|
|
|
- if (hdfs.get('standbyNameNode') && hdfs.get('standbyNameNode').get('hostName')) {
|
|
|
- var standbyHostname1 = hdfs.get('standbyNameNode').get('hostName');
|
|
|
- }
|
|
|
- if (hdfs.get('standbyNameNode2') && hdfs.get('standbyNameNode2').get('hostName')) {
|
|
|
- var standbyHostname2 = hdfs.get('standbyNameNode2').get('hostName');
|
|
|
- }
|
|
|
- if ( hostName == activeHostname) {
|
|
|
- hostComponent.set('displayNameAdvanced', activeNNText);
|
|
|
- } else if ( hostName == standbyHostname1 || hostName == standbyHostname2) {
|
|
|
- hostComponent.set('displayNameAdvanced', standbyNNText);
|
|
|
+ currentHostStatuses[host.Hosts.host_name] = host.Hosts.host_status;
|
|
|
+ var hostComponentsOnHost = [];
|
|
|
+ host.host_components.forEach(function (host_component) {
|
|
|
+ host_component.id = host_component.HostRoles.component_name + "_" + host_component.HostRoles.host_name;
|
|
|
+ var existedComponent = previousComponentStatuses[host_component.id];
|
|
|
+ if (existedComponent) {
|
|
|
+ //update host-components, which have status changed
|
|
|
+ if (existedComponent !== host_component.HostRoles.state) {
|
|
|
+ hostComponentStatuses[host_component.id] = host_component.HostRoles.state;
|
|
|
+ }
|
|
|
} else {
|
|
|
- hostComponent.set('displayNameAdvanced', null);
|
|
|
+ addedHostComponents.push({
|
|
|
+ id: host_component.id,
|
|
|
+ component_name: host_component.HostRoles.component_name,
|
|
|
+ work_status: host_component.HostRoles.state,
|
|
|
+ host_id: host.Hosts.host_name,
|
|
|
+ service_id: componentServiceMap[host_component.HostRoles.component_name]
|
|
|
+ });
|
|
|
}
|
|
|
+ hostComponentsOnHost.push(host_component.id);
|
|
|
+ currentComponentStatuses[host_component.id] = host_component.HostRoles.state;
|
|
|
+ }, this);
|
|
|
+ /**
|
|
|
+ * updating relation between Host and his host-components
|
|
|
+ */
|
|
|
+ if (hostsCache[host.Hosts.host_name]) {
|
|
|
+ hostsCache[host.Hosts.host_name].host_components = hostComponentsOnHost;
|
|
|
}
|
|
|
- } else if(hostComponent.get('componentName') === 'HBASE_MASTER') {
|
|
|
- if (hostComponent.get('workStatus') === 'STARTED') {
|
|
|
- hostComponent.get('haStatus') == 'true' ? hostComponent.set('displayNameAdvanced', this.t('dashboard.services.hbase.masterServer.active')) : hostComponent.set('displayNameAdvanced', this.t('dashboard.services.hbase.masterServer.standby'));
|
|
|
- } else {
|
|
|
- hostComponent.set('displayNameAdvanced', null);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (hostComponent.get("displayNameAdvanced")) {
|
|
|
- service.toolTipContent += hostComponent.get("displayNameAdvanced") + " " + hostComponent.get("componentTextStatus") + "<br/>";
|
|
|
- } else {
|
|
|
- service.toolTipContent += hostComponent.get("displayName") + " " + hostComponent.get("componentTextStatus") + "<br/>";
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if (hostComponent.get('workStatus') !== App.HostComponentStatus.stopped &&
|
|
|
- hostComponent.get('workStatus') !== App.HostComponentStatus.install_failed &&
|
|
|
- hostComponent.get('workStatus') !== App.HostComponentStatus.unknown &&
|
|
|
- hostComponent.get('workStatus') !== App.HostComponentStatus.maintenance) {
|
|
|
- service.isRunning = false;
|
|
|
- service.runningHCs.addObject(hostComponent);
|
|
|
- } else if (hostComponent.get('workStatus') == App.HostComponentStatus.unknown) {
|
|
|
- service.unknownHCs.addObject(hostComponent);
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * compute service status and properties by servicesMap of hostComponents
|
|
|
- * @param services
|
|
|
- * @param servicesMap
|
|
|
- */
|
|
|
- updateServicesStatus: function(services, servicesMap){
|
|
|
- services.forEach(function(_service){
|
|
|
- var service = servicesMap[_service.get('id')];
|
|
|
- if (service) {
|
|
|
- var serviceName = _service.get('serviceName');
|
|
|
- var serviceSpecificObj = null;
|
|
|
- switch (serviceName) {
|
|
|
- case "HDFS":
|
|
|
- serviceSpecificObj = App.HDFSService.find(_service.get('id'));
|
|
|
- break;
|
|
|
- case "YARN":
|
|
|
- serviceSpecificObj = App.YARNService.find(_service.get('id'));
|
|
|
- break;
|
|
|
- case "MAPREDUCE":
|
|
|
- serviceSpecificObj = App.MapReduceService.find(_service.get('id'));
|
|
|
- break;
|
|
|
- case "HBASE":
|
|
|
- serviceSpecificObj = App.HBaseService.find(_service.get('id'));
|
|
|
- break;
|
|
|
- }
|
|
|
- //computation of service health status
|
|
|
- var isGreen = serviceName === 'HBASE' && App.supports.multipleHBaseMasters ? service.isStarted : service.everyStartedOrMaintenance;
|
|
|
- if (isGreen) {
|
|
|
- _service.set('healthStatus', 'green');
|
|
|
- if (serviceSpecificObj != null) {
|
|
|
- serviceSpecificObj.set('healthStatus', 'green');
|
|
|
- }
|
|
|
- } else if (service.isUnknown) {
|
|
|
- _service.set('healthStatus', 'yellow');
|
|
|
- if (serviceSpecificObj != null) {
|
|
|
- serviceSpecificObj.set('healthStatus', 'yellow');
|
|
|
- }
|
|
|
- } else if (service.isStarting) {
|
|
|
- _service.set('healthStatus', 'green-blinking');
|
|
|
- if (serviceSpecificObj != null) {
|
|
|
- serviceSpecificObj.set('healthStatus', 'green-blinking');
|
|
|
- }
|
|
|
- } else if (service.isStopped) {
|
|
|
- _service.set('healthStatus', 'red');
|
|
|
- if (serviceSpecificObj != null) {
|
|
|
- serviceSpecificObj.set('healthStatus', 'red');
|
|
|
- }
|
|
|
- } else {
|
|
|
- _service.set('healthStatus', 'red-blinking');
|
|
|
- if (serviceSpecificObj != null) {
|
|
|
- serviceSpecificObj.set('healthStatus', 'red-blinking');
|
|
|
- }
|
|
|
- }
|
|
|
+ }, this);
|
|
|
|
|
|
- if (serviceName === 'HBASE' && App.supports.multipleHBaseMasters) {
|
|
|
- if (!service.isHbaseActive) {
|
|
|
- _service.set('healthStatus', 'red');
|
|
|
- if (serviceSpecificObj != null) {
|
|
|
- serviceSpecificObj.set('healthStatus', 'red');
|
|
|
+ var hostComponents = App.HostComponent.find();
|
|
|
+ var hosts = App.Host.find();
|
|
|
+
|
|
|
+ hostComponents.forEach(function (hostComponent) {
|
|
|
+ if (hostComponent) {
|
|
|
+ var status = currentComponentStatuses[hostComponent.get('id')];
|
|
|
+ //check whether component present in current response
|
|
|
+ if (status) {
|
|
|
+ //check whether component has status changed
|
|
|
+ if (hostComponentStatuses[hostComponent.get('id')]) {
|
|
|
+ hostComponent.set('workStatus', status);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ hostComponent.deleteRecord();
|
|
|
+ hostComponent.get('stateManager').transitionTo('loading');
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }, this);
|
|
|
|
|
|
- _service.set('isStarted', service.everyStarted);
|
|
|
- _service.set('runningHostComponents', service.runningHCs);
|
|
|
- _service.set('unknownHostComponents', service.unknownHCs);
|
|
|
- _service.set('isStopped', service.isRunning);
|
|
|
- _service.set('toolTipContent', service.toolTipContent);
|
|
|
- if (serviceSpecificObj != null) {
|
|
|
- serviceSpecificObj.set('isStarted', service.everyStarted);
|
|
|
- serviceSpecificObj.set('isStopped', service.isRunning);
|
|
|
- serviceSpecificObj.set('toolTipContent', service.toolTipContent);
|
|
|
+ if (addedHostComponents.length) {
|
|
|
+ App.store.loadMany(this.get('model'), addedHostComponents);
|
|
|
}
|
|
|
- }
|
|
|
- }, this);
|
|
|
- },
|
|
|
|
|
|
- /**
|
|
|
- * fill hostsMap with aggregated data of hostComponents for each host
|
|
|
- * @param hostComponent
|
|
|
- * @param hostsMap
|
|
|
- * @param host
|
|
|
- */
|
|
|
- countHostComponents: function(hostComponent, hostsMap, host){
|
|
|
- var isMasterRunning = (hostComponent.get('isMaster') && hostComponent.get('workStatus') === App.HostComponentStatus.started);
|
|
|
- var isSlaveRunning = (hostComponent.get('isSlave') && hostComponent.get('workStatus') === App.HostComponentStatus.started);
|
|
|
- if (host) {
|
|
|
- host.mastersRunning = host.mastersRunning + ~~isMasterRunning;
|
|
|
- host.slavesRunning = host.slavesRunning + ~~isSlaveRunning;
|
|
|
- host.totalMasters = host.totalMasters + ~~hostComponent.get('isMaster');
|
|
|
- host.totalSlaves = host.totalSlaves + ~~hostComponent.get('isSlave');
|
|
|
- } else {
|
|
|
- hostsMap[hostComponent.get('host.id')] = {
|
|
|
- mastersRunning: ~~isMasterRunning,
|
|
|
- slavesRunning: ~~isSlaveRunning,
|
|
|
- totalMasters: ~~hostComponent.get('isMaster'),
|
|
|
- totalSlaves: ~~hostComponent.get('isSlave')
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
+ previousComponentStatuses = currentComponentStatuses;
|
|
|
+ previousHostStatuses = currentHostStatuses;
|
|
|
|
|
|
- /**
|
|
|
- * compute host status by hostsMap of hostComponents
|
|
|
- * @param hosts
|
|
|
- * @param hostsMap
|
|
|
- */
|
|
|
- updateHostsStatus: function(hosts, hostsMap){
|
|
|
- hosts.forEach(function(_host){
|
|
|
- var healthStatus = _host.get('healthStatus');
|
|
|
- var host = hostsMap[_host.get('id')];
|
|
|
- if(host) {
|
|
|
- //hostComponents of host are loaded to model
|
|
|
- var status;
|
|
|
- var masterComponentsRunning = (host.mastersRunning === host.totalMasters);
|
|
|
- var slaveComponentsRunning = (host.slavesRunning === host.totalSlaves);
|
|
|
- if (_host.get('isNotHeartBeating') || healthStatus == 'UNKNOWN') {
|
|
|
- status = 'DEAD-YELLOW';
|
|
|
- } else if (masterComponentsRunning && slaveComponentsRunning) {
|
|
|
- status = 'LIVE';
|
|
|
- } else if (host.totalMasters > 0 && !masterComponentsRunning) {
|
|
|
- status = 'DEAD-RED';
|
|
|
- } else {
|
|
|
- status = 'DEAD-ORANGE';
|
|
|
- }
|
|
|
+ hosts.forEach(function (host) {
|
|
|
+ var status = hostStatuses[host.get('id')];
|
|
|
if (status) {
|
|
|
- healthStatus = status;
|
|
|
+ host.set('healthStatus', status);
|
|
|
}
|
|
|
- }
|
|
|
- _host.set('healthClass', 'health-status-' + healthStatus);
|
|
|
- }, this);
|
|
|
- },
|
|
|
-
|
|
|
- parse_host_components: function(json) {
|
|
|
- var result = {};
|
|
|
- json.items.forEach(function (item) {
|
|
|
- item.components.forEach(function (component) {
|
|
|
- component.host_components.forEach(function (host_component) {
|
|
|
- host_component.id = host_component.HostRoles.component_name + "_" + host_component.HostRoles.host_name;
|
|
|
- result[host_component.id] = {
|
|
|
- work_status: host_component.HostRoles.state
|
|
|
- };
|
|
|
- if (host_component.metrics &&
|
|
|
- host_component.metrics.hbase &&
|
|
|
- host_component.metrics.hbase.master &&
|
|
|
- host_component.metrics.hbase.master.IsActiveMaster) {
|
|
|
- result[host_component.id]['ha_status'] = host_component.metrics.hbase.master.IsActiveMaster;
|
|
|
- }
|
|
|
- }, this)
|
|
|
- }, this)
|
|
|
- }, this);
|
|
|
- return result;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.timeEnd('App.statusMapper execution time');
|
|
|
}
|
|
|
-
|
|
|
});
|