123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683 |
- /**
- * 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.servicesMapper = App.QuickDataMapper.create({
- servicesSortOrder: [
- 'HDFS',
- 'YARN',
- 'MAPREDUCE',
- 'MAPREDUCE2',
- 'TEZ',
- 'HBASE',
- 'HIVE',
- 'HCATALOG',
- 'WEBHCAT',
- 'FLUME',
- 'OOZIE',
- 'GANGLIA',
- 'NAGIOS',
- 'ZOOKEEPER',
- 'PIG',
- 'SQOOP',
- 'HUE'
- ],
- sortByOrder: function (sortOrder, array) {
- var sorted = [];
- for (var i = 0; i < sortOrder.length; i++)
- for (var j = 0; j < array.length; j++) {
- if (sortOrder[i] == array[j].id) {
- sorted.push(array[j]);
- }
- }
- return sorted;
- },
- model: App.Service,
- config: {
- id: 'ServiceInfo.service_name',
- service_name: 'ServiceInfo.service_name',
- work_status: 'ServiceInfo.state',
- $rand: Math.random(),
- $alerts: [ 1, 2, 3 ],
- host_components: 'host_components'
- },
- hdfsConfig: {
- version: 'nameNodeComponent.host_components[0].metrics.dfs.namenode.Version',
- name_node_id: 'nameNodeComponent.host_components[0].HostRoles.host_name',
- sname_node_id: 'snameNodeComponent.host_components[0].HostRoles.host_name',
- active_name_node_id: 'active_name_node_id',
- standby_name_node_id: 'standby_name_node_id',
- standby_name_node2_id: 'standby_name_node2_id',
- data_nodes: 'data_nodes',
- journal_nodes: 'journal_nodes',
- name_node_start_time: 'nameNodeComponent.host_components[0].metrics.runtime.StartTime',
- jvm_memory_heap_used: 'nameNodeComponent.host_components[0].metrics.jvm.memHeapUsedM',
- jvm_memory_heap_committed: 'nameNodeComponent.host_components[0].metrics.jvm.memHeapCommittedM',
- live_data_nodes: 'live_data_nodes',
- dead_data_nodes: 'dead_data_nodes',
- decommission_data_nodes: 'decommission_data_nodes',
- capacity_used: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CapacityUsed',
- capacity_total: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CapacityTotal',
- capacity_remaining: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CapacityRemaining',
- dfs_total_blocks: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.BlocksTotal',
- dfs_corrupt_blocks: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.CorruptBlocks',
- dfs_missing_blocks: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.MissingBlocks',
- dfs_under_replicated_blocks: 'nameNodeComponent.host_components[0].metrics.dfs.FSNamesystem.UnderReplicatedBlocks',
- dfs_total_files: 'nameNodeComponent.host_components[0].metrics.dfs.namenode.TotalFiles',
- upgrade_status: 'nameNodeComponent.host_components[0].metrics.dfs.namenode.UpgradeFinalized',
- safe_mode_status: 'nameNodeComponent.host_components[0].metrics.dfs.namenode.Safemode',
- name_node_cpu: 'nameNodeComponent.host_components[0].metrics.cpu.cpu_wio',
- name_node_rpc: 'nameNodeComponent.host_components[0].metrics.rpc.RpcQueueTime_avg_time'
- },
- yarnConfig: {
- version: 'resourceManagerComponent.ServiceComponentInfo.Version',
- resource_manager_node_id: 'resourceManagerComponent.host_components[0].HostRoles.host_name',
- node_manager_nodes: 'node_manager_nodes',
- node_manager_live_nodes: 'node_manager_live_nodes',
- yarn_client_nodes: 'yarn_client_nodes',
- resource_manager_start_time: 'resourceManagerComponent.ServiceComponentInfo.StartTime',
- jvm_memory_heap_used: 'resourceManagerComponent.host_components[0].metrics.jvm.memHeapUsedM',
- jvm_memory_heap_committed: 'resourceManagerComponent.host_components[0].metrics.jvm.memHeapCommittedM',
- containers_allocated: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AllocatedContainers',
- containers_pending: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.PendingContainers',
- containers_reserved: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.ReservedContainers',
- apps_submitted: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AppsSubmitted',
- apps_running: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AppsRunning',
- apps_pending: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AppsPending',
- apps_completed: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AppsCompleted',
- apps_killed: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AppsKilled',
- apps_failed: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AppsFailed',
- node_managers_count_active: 'resourceManagerComponent.ServiceComponentInfo.rm_metrics.cluster.activeNMcount',
- //node_managers_count_lost: 'resourceManagerComponent.ServiceComponentInfo.rm_metrics.cluster.lostNMcount',
- node_managers_count_unhealthy: 'resourceManagerComponent.ServiceComponentInfo.rm_metrics.cluster.unhealthyNMcount',
- node_managers_count_rebooted: 'resourceManagerComponent.ServiceComponentInfo.rm_metrics.cluster.rebootedNMcount',
- node_managers_count_decommissioned: 'resourceManagerComponent.ServiceComponentInfo.rm_metrics.cluster.decommissionedNMcount',
- allocated_memory: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AllocatedMB',
- available_memory: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.AvailableMB',
- reserved_memory: 'resourceManagerComponent.host_components[0].metrics.yarn.Queue.root.ReservedMB',
- queue: 'resourceManagerComponent.queue'
- },
- mapReduce2Config: {
- version: 'jobHistoryServerComponent.ServiceComponentInfo.Version',
- job_history_server_id: 'jobHistoryServerComponent.host_components[0].HostRoles.host_name',
- map_reduce2_clients: 'map_reduce2_clients'
- },
- mapReduceConfig: {
- version: 'jobTrackerComponent.ServiceComponentInfo.Version',
- job_tracker_id: 'jobTrackerComponent.host_components[0].HostRoles.host_name',
- task_trackers: 'task_trackers',
- job_tracker_start_time: 'jobTrackerComponent.ServiceComponentInfo.StartTime',
- job_tracker_heap_used: 'jobTrackerComponent.ServiceComponentInfo.HeapMemoryUsed',
- job_tracker_heap_max: 'jobTrackerComponent.ServiceComponentInfo.HeapMemoryMax',
- alive_trackers: 'alive_trackers',
- black_list_trackers: 'black_list_trackers',
- gray_list_trackers: 'gray_list_trackers',
- map_slots: 'map_slots',
- reduce_slots: 'reduce_slots',
- jobs_submitted: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.jobs_submitted',
- jobs_completed: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.jobs_completed',
- jobs_running: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.jobs_running',
- map_slots_occupied: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.occupied_map_slots',
- map_slots_reserved: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.reserved_map_slots',
- reduce_slots_occupied: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.occupied_reduce_slots',
- reduce_slots_reserved: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.reserved_reduce_slots',
- maps_running: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.running_maps',
- maps_waiting: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.waiting_maps',
- reduces_running: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.running_reduces',
- reduces_waiting: 'jobTrackerComponent.ServiceComponentInfo.jobtracker.waiting_reduces',
- trackers_decommissioned: 'jobTrackerComponent.host_components[0].metrics.mapred.jobtracker.trackers_decommissioned',
- job_tracker_cpu: 'jobTrackerComponent.host_components[0].metrics.cpu.cpu_wio',
- job_tracker_rpc: 'jobTrackerComponent.host_components[0].metrics.rpc.RpcQueueTime_avg_time'
- },
- hbaseConfig: {
- version: 'masterComponent.ServiceComponentInfo.Version',
- master_id: 'masterComponent.host_components[0].HostRoles.host_name',
- region_servers: 'region_servers',
- master_start_time: 'masterComponent.ServiceComponentInfo.MasterStartTime',
- master_active_time: 'masterComponent.ServiceComponentInfo.MasterActiveTime',
- average_load: 'masterComponent.ServiceComponentInfo.AverageLoad',
- regions_in_transition: 'regions_in_transition',
- revision: 'masterComponent.ServiceComponentInfo.Revision',
- heap_memory_used: 'masterComponent.ServiceComponentInfo.HeapMemoryUsed',
- heap_memory_max: 'masterComponent.ServiceComponentInfo.HeapMemoryMax'
- },
- model3: App.HostComponent,
- config3: {
- id: 'id',
- work_status: 'HostRoles.state',
- desired_status: 'HostRoles.desired_state',
- component_name: 'HostRoles.component_name',
- host_id: 'HostRoles.host_name',
- stale_configs: 'HostRoles.stale_configs',
- $service_id: 'none' /* will be set outside of parse function */
- },
- map: function (json) {
- if (!this.get('model')) {
- return;
- }
- var start = new Date().getTime();
- console.log('in service mapper');
- if (json.items) {
- var result = [];
- json.items.forEach(function (item) {
- var finalConfig = jQuery.extend({}, this.config);
- var finalJson = [];
- item.host_components = [];
- 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;
- item.host_components.push(host_component.id);
- }, this);
- }, this);
- item.host_components.sort();
- if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HDFS") {
- finalJson = this.hdfsMapper(item);
- finalJson.rand = Math.random();
- result.push(finalJson);
- App.store.load(App.HDFSService, finalJson);
- }else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "MAPREDUCE") {
- finalJson = this.mapreduceMapper(item);
- finalJson.rand = Math.random();
- result.push(finalJson);
- App.store.load(App.MapReduceService, finalJson);
- }else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "HBASE") {
- finalJson = this.hbaseMapper(item);
- finalJson.rand = Math.random();
- result.push(finalJson);
- App.store.load(App.HBaseService, finalJson);
- }else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "FLUME") {
- finalJson = this.flumeMapper(item);
- finalJson.rand = Math.random();
- result.push(finalJson);
- if(finalJson.nodeObjs){
- finalJson.nodeObjs.forEach(function(no){
- App.store.load(App.FlumeNode, no);
- });
- }
- App.store.load(App.FlumeService, finalJson);
- }else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "YARN") {
- finalJson = this.yarnMapper(item);
- finalJson.rand = Math.random();
- result.push(finalJson);
- App.store.load(App.YARNService, finalJson);
- }else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "MAPREDUCE2") {
- finalJson = this.mapreduce2Mapper(item);
- finalJson.rand = Math.random();
- result.push(finalJson);
- App.store.load(App.MapReduce2Service, finalJson);
- }else {
- finalJson = this.parseIt(item, this.config);
- finalJson.rand = Math.random();
- this.mapQuickLinks(finalJson, item);
- result.push(finalJson);
- }
- }, this);
- result = this.sortByOrder(this.get('servicesSortOrder'), result);
- App.store.loadMany(this.get('model'), result);
- // Host components
- result = [];
- var hostComponentsMap = {};
- json.items.forEach(function(item){
- item.components.forEach(function(component){
- var service = component.ServiceComponentInfo.service_name;
- component.host_components.forEach(function(host_component){
- if(host_component.HostRoles.component_name == "HBASE_MASTER"){
- this.config3.ha_status = 'metrics.hbase.master.IsActiveMaster';
- }
- var comp = this.parseIt(host_component, this.config3);
- comp.service_id = service;
- this.calculateState(comp);
- result.push(comp);
- hostComponentsMap[comp.id] = comp;
- }, this)
- }, this)
- }, this);
- var oldHostComponents = App.HostComponent.find();
- var item;
- var currentHCWithComponentNames = {};
- var currentComponentNameHostNames = {};
- var doHostComponentsLoad = false;
- oldHostComponents.forEach(function (item) {
- if (item) {
- if (!hostComponentsMap[item.get('id')]) {
- item.deleteRecord();
- item.get('stateManager').transitionTo('loading');
- } else {
- var componentName = item.get('componentName');
- if (componentName) {
- currentHCWithComponentNames[item.get('id')] = item.get('id');
- }
- if (!currentComponentNameHostNames[componentName]) {
- currentComponentNameHostNames[componentName] = [];
- }
- currentComponentNameHostNames[componentName].pushObject(item.get('host.hostName'));
- }
- }
- }, this);
- for(var i in hostComponentsMap) {
- if(!currentHCWithComponentNames[i]) {
- doHostComponentsLoad = true;
- break;
- }
- }
- result.forEach(function (item) {
- if (currentHCWithComponentNames[item.id] != null &&
- !currentComponentNameHostNames[item.component_name].contains(item.host_id)) {
- item.id = (new Date).getTime();
- }
- });
- if (!App.router.get('clusterController.isLoaded') || doHostComponentsLoad) {
- App.store.loadMany(this.get('model3'), result);
- }
- }
- console.log('out service mapper. Took ' + (new Date().getTime() - start) + 'ms');
- },
- /**
- * Map quick links to services:OOZIE,GANGLIA,NAGIOS,HUE
- * @param finalJson
- * @param item
- */
- mapQuickLinks: function (finalJson, item){
- if(item && item.ServiceInfo && item.ServiceInfo.service_name == "OOZIE"){
- finalJson.quick_links = [19];
- }else if(item && item.ServiceInfo && item.ServiceInfo.service_name == "GANGLIA"){
- finalJson.quick_links = [20];
- }else if(item && item.ServiceInfo && item.ServiceInfo.service_name == "NAGIOS"){
- finalJson.quick_links = [21];
- }else if(item && item.ServiceInfo && item.ServiceInfo.service_name == "HUE"){
- finalJson.quick_links = [22];
- }
- },
- hdfsMapper: function (item) {
- var finalConfig = jQuery.extend({}, this.config);
- // Change the JSON so that it is easy to map
- var hdfsConfig = this.hdfsConfig;
- item.components.forEach(function (component) {
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "NAMENODE") {
- //enabled HA
- if ( component.host_components.length == 2) {
- var haState1;
- var haState2;
- if (component.host_components[1].metrics && component.host_components[1].metrics.dfs) {
- haState2 = component.host_components[1].metrics.dfs.FSNamesystem.HAState;
- }
- if (component.host_components[0].metrics && component.host_components[0].metrics.dfs) {
- haState1 = component.host_components[0].metrics.dfs.FSNamesystem.HAState;
- }
- var active_name_node = [];
- var standby_name_nodes = [];
- switch (haState1) {
- case "active":
- active_name_node.push(component.host_components[0].HostRoles.host_name);
- break;
- case "standby":
- standby_name_nodes.push(component.host_components[0].HostRoles.host_name);
- break;
- }
- switch (haState2) {
- case "active":
- active_name_node.push(component.host_components[1].HostRoles.host_name);
- break;
- case "standby":
- standby_name_nodes.push(component.host_components[1].HostRoles.host_name);
- break;
- }
- item.active_name_node_id = null;
- item.standby_name_node_id = null;
- item.standby_name_node2_id = null;
- switch (active_name_node.length) {
- case 1:
- item.active_name_node_id = active_name_node[0];
- break;
- }
- switch (standby_name_nodes.length) {
- case 1:
- item.standby_name_node_id = standby_name_nodes[0];
- break;
- case 2:
- item.standby_name_node_id = standby_name_nodes[0];
- item.standby_name_node2_id = standby_name_nodes[1];
- break;
- }
- // important: active nameNode always at host_components[0]; if no active, then any nameNode could work.
- if (haState2 == "active") { // change places for all model bind with host_component[0]
- var tmp = component.host_components[1];
- component.host_components[1] = component.host_components[0];
- component.host_components[0] = tmp;
- }
- }
- item.nameNodeComponent = component;
- finalConfig = jQuery.extend(finalConfig, hdfsConfig);
- // Get the live, dead & decommission nodes from string json
- if (component.host_components[0].metrics && component.host_components[0].metrics.dfs && component.host_components[0].metrics.dfs.namenode) {
- var liveNodesJson = App.parseJSON(component.host_components[0].metrics.dfs.namenode.LiveNodes);
- var deadNodesJson = App.parseJSON(component.host_components[0].metrics.dfs.namenode.DeadNodes);
- var decommissionNodesJson = App.parseJSON(component.host_components[0].metrics.dfs.namenode.DecomNodes);
- }
- item.live_data_nodes = [];
- item.dead_data_nodes = [];
- item.decommission_data_nodes = [];
- for (var ln in liveNodesJson) {
- item.live_data_nodes.push(ln);
- }
- for (var dn in deadNodesJson) {
- item.dead_data_nodes.push(dn);
- }
- for (var dcn in decommissionNodesJson) {
- item.decommission_data_nodes.push(dcn);
- }
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "SECONDARY_NAMENODE") {
- item.snameNodeComponent = component;
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "JOURNALNODE") {
- if (!item.journal_nodes) {
- item.journal_nodes = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- item.journal_nodes.push(hc.HostRoles.host_name);
- });
- }
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "DATANODE") {
- if (!item.data_nodes) {
- item.data_nodes = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- item.data_nodes.push(hc.HostRoles.host_name);
- });
- }
- }
- });
- // Map
- var finalJson = this.parseIt(item, finalConfig);
- finalJson.quick_links = [1, 2, 3, 4];
- return finalJson;
- },
- yarnMapper: function (item) {
- var result = [];
- var self = this;
- var finalConfig = jQuery.extend({}, this.config);
- // Change the JSON so that it is easy to map
- var yarnConfig = this.yarnConfig;
- item.components.forEach(function (component) {
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "RESOURCEMANAGER") {
- item.resourceManagerComponent = component;
- // live nodes calculation
- var nmList = [];
- if (component.ServiceComponentInfo.rm_metrics && component.ServiceComponentInfo.rm_metrics.cluster && component.ServiceComponentInfo.rm_metrics.cluster.nodeManagers) {
- nmList = App.parseJSON(component.ServiceComponentInfo.rm_metrics.cluster.nodeManagers);
- }
- nmList.forEach(function (nm) {
- if (nm.State === "RUNNING") {
- if (!item.node_manager_live_nodes) {
- item.node_manager_live_nodes = [];
- }
- item.node_manager_live_nodes.push(nm.HostName);
- }
- });
- if (component.host_components[0].metrics && component.host_components[0].metrics.yarn) {
- var root = component.host_components[0].metrics.yarn.Queue.root;
- var queue = JSON.stringify({
- 'root': self.parseObject(root)
- });
- component.queue = queue;
- }
- // extend config
- finalConfig = jQuery.extend(finalConfig, yarnConfig);
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "NODEMANAGER") {
- if (!item.node_manager_nodes) {
- item.node_manager_nodes = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- item.node_manager_nodes.push(hc.HostRoles.host_name);
- });
- }
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "YARN_CLIENT") {
- if (!item.yarn_client_nodes) {
- item.yarn_client_nodes = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- item.yarn_client_nodes.push(hc.HostRoles.host_name);
- });
- }
- }
- });
- // Map
- var finalJson = this.parseIt(item, finalConfig);
- finalJson.quick_links = [ 23, 24, 25, 26 ];
- return finalJson;
- },
- parseObject: function(obj) {
- var res = {};
- for (var p in obj) {
- if (obj.hasOwnProperty(p)) {
- if (obj[p] instanceof Object) {
- res[p] = this.parseObject(obj[p]);
- }
- }
- }
- return res;
- },
- mapreduce2Mapper: function (item) {
- var result = [];
- var finalConfig = jQuery.extend({}, this.config);
- // Change the JSON so that it is easy to map
- var mapReduce2Config = this.mapReduce2Config;
- item.components.forEach(function (component) {
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "HISTORYSERVER") {
- item.jobHistoryServerComponent = component;
- finalConfig = jQuery.extend(finalConfig, mapReduce2Config);
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "MAPREDUCE2_CLIENT") {
- if (!item.map_reduce2_clients) {
- item.map_reduce2_clients = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- item.map_reduce2_clients.push(hc.HostRoles.host_name);
- });
- }
- }
- });
- // Map
- var finalJson = this.parseIt(item, finalConfig);
- finalJson.quick_links = [27, 28, 29, 30];
- return finalJson;
- },
- mapreduceMapper: function (item) {
- // Change the JSON so that it is easy to map
- var result = [];
- var finalConfig = jQuery.extend({}, this.config);
- var mapReduceConfig = this.mapReduceConfig;
- item.components.forEach(function (component) {
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "JOBTRACKER") {
- item.jobTrackerComponent = component;
- finalConfig = jQuery.extend(finalConfig, mapReduceConfig);
- // Get the live, gray & black nodes from string json
- item.map_slots = 0;
- item.reduce_slots = 0;
- var liveNodesJson = App.parseJSON(component.ServiceComponentInfo.AliveNodes);
- var grayNodesJson = App.parseJSON(component.ServiceComponentInfo.GrayListedNodes);
- var blackNodesJson = App.parseJSON(component.ServiceComponentInfo.BlackListedNodes);
- item.alive_trackers = [];
- item.gray_list_trackers = [];
- item.black_list_trackers = [];
- if (liveNodesJson != null) {
- liveNodesJson.forEach(function (nj) {
- item.alive_trackers.push(nj.hostname);
- if (nj.slots && nj.slots.map_slots)
- item.map_slots += nj.slots.map_slots;
- if (nj.slots && nj.slots.map_slots_used)
- item.map_slots_used += nj.slots.map_slots_used;
- if (nj.slots && nj.slots.reduce_slots)
- item.reduce_slots += nj.slots.reduce_slots;
- if (nj.slots && nj.slots.reduce_slots_used)
- item.reduce_slots_used += nj.slots.reduce_slots_used;
- });
- }
- if (grayNodesJson != null) {
- grayNodesJson.forEach(function (nj) {
- item.gray_list_trackers.push(nj.hostname);
- });
- }
- if (blackNodesJson != null) {
- blackNodesJson.forEach(function (nj) {
- item.black_list_trackers.push(nj.hostname);
- });
- }
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "TASKTRACKER") {
- if (!item.task_trackers) {
- item.task_trackers = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- item.task_trackers.push(hc.HostRoles.host_name);
- });
- }
- }
- });
- // Map
- finalJson = this.parseIt(item, finalConfig);
- finalJson.quick_links = [5, 6, 7, 8, 9, 10, 11, 12];
- return finalJson;
- },
- hbaseMapper: function (item) {
- // Change the JSON so that it is easy to map
- var finalConfig = jQuery.extend({}, this.config);
- var hbaseConfig = this.hbaseConfig;
- item.components.forEach(function (component) {
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "HBASE_MASTER") {
- item.masterComponent = component;
- finalConfig = jQuery.extend(finalConfig, hbaseConfig);
- var regionsArray = App.parseJSON(component.ServiceComponentInfo.RegionsInTransition);
- //regions_in_transition can have various type of value: null, array or int
- if (Array.isArray(regionsArray)) {
- item.regions_in_transition = regionsArray.length;
- } else {
- item.regions_in_transition = regionsArray == null ? 0 : regionsArray;
- }
- }
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "HBASE_REGIONSERVER") {
- if (!item.region_servers) {
- item.region_servers = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- item.region_servers.push(hc.HostRoles.host_name);
- });
- }
- }
- });
- // Map
- finalJson = this.parseIt(item, finalConfig);
- finalJson.average_load = parseFloat(finalJson.average_load).toFixed(2);
- finalJson.quick_links = [13, 14, 15, 16, 17, 18];
- return finalJson;
- },
-
- /**
- * Flume is different from other services, in that the important
- * data is in customizeable channels. Hence we directly transfer
- * data into the JSON object.
- */
- flumeMapper: function (item) {
- var finalConfig = jQuery.extend({}, this.config);
- var finalJson = this.parseIt(item, finalConfig);
- item.components.forEach(function (component) {
- if (component.ServiceComponentInfo && component.ServiceComponentInfo.component_name == "FLUME_SERVER") {
- if (!finalJson.nodes) {
- finalJson.nodes = [];
- }
- if (!finalJson.nodeObjs) {
- finalJson.nodeObjs = [];
- }
- if (component.host_components) {
- component.host_components.forEach(function (hc) {
- var fnode = {};
- fnode.id = hc.HostRoles.host_name;
- fnode.host_id = hc.HostRoles.host_name;
- fnode.channels = "";
- fnode.sources = "";
- fnode.sinks = "";
- if (hc.metrics != null && hc.metrics.flume && hc.metrics.flume.flume && hc.metrics.flume.flume) {
- if (hc.metrics.flume.flume.CHANNEL) {
- for ( var c in hc.metrics.flume.flume.CHANNEL) {
- if (fnode.channels.length < 1) {
- fnode.channels += c;
- } else {
- fnode.channels += ("," + c);
- }
- }
- }
- if (hc.metrics.flume.flume.SINK) {
- for ( var c in hc.metrics.flume.flume.SINK) {
- if (fnode.sinks.length < 1) {
- fnode.sinks += c;
- } else {
- fnode.sinks += ("," + c);
- }
- }
- }
- if (hc.metrics.flume.flume.SOURCE) {
- for ( var c in hc.metrics.flume.flume.SOURCE) {
- if (fnode.sources.length < 1) {
- fnode.sources += c;
- } else {
- fnode.sources += ("," + c);
- }
- }
- }
- }
- finalJson.nodeObjs.push(fnode);
- finalJson.nodes.push(hc.HostRoles.host_name);
- });
- }
- }
- });
- return finalJson;
- }
- });
|