eagle-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zombieJ <...@git.apache.org>
Subject [GitHub] eagle pull request #753: EAGLE-845 JMX Dashboard
Date Fri, 30 Dec 2016 08:05:03 GMT
Github user zombieJ commented on a diff in the pull request:

    https://github.com/apache/eagle/pull/753#discussion_r94208082
  
    --- Diff: eagle-hadoop-metric/src/main/webapp/app/apps/hadoop_metric/ctrls/overview.js
---
    @@ -21,52 +21,173 @@
     	 * `register` without params will load the module which using require
     	 */
     	register(function (hadoopMetricApp) {
    -		hadoopMetricApp.controller("overviewCtrl", function ($scope, PageConfig) {
    -			PageConfig.title = 'Overview';
    +		hadoopMetricApp.controller("overviewCtrl", function ($q, $wrapState, $scope, PageConfig,
METRIC, Time) {
    +			var cache = {};
    +			$scope.site = $wrapState.param.siteId;
    +			var activeMasterInfo = METRIC.hbaseActiveMaster($scope.site);
     
    -			$scope.commonOption = {};
    +			var MASTER_METRIC_ARRAY = [
    +				"hadoop.memory.nonheapmemoryusage.used",
    +				"hadoop.memory.heapmemoryusage.used",
    +				"hadoop.hbase.master.server.averageload",
    +				"hadoop.hbase.master.assignmentmanger.ritcount",
    +				"hadoop.hbase.master.assignmentmanger.ritcountoverthreshold",
    +				"hadoop.hbase.master.assignmentmanger.assign_num_ops",
    +				"hadoop.hbase.master.assignmentmanger.assign_min",
    +				"hadoop.hbase.master.assignmentmanger.assign_max",
    +				"hadoop.hbase.master.assignmentmanger.assign_75th_percentile",
    +				"hadoop.hbase.master.assignmentmanger.assign_95th_percentile",
    +				"hadoop.hbase.master.assignmentmanger.assign_99th_percentile",
    +				"hadoop.hbase.master.assignmentmanger.bulkassign_num_ops",
    +				"hadoop.hbase.master.assignmentmanger.bulkassign_min",
    +				"hadoop.hbase.master.assignmentmanger.bulkassign_max",
    +				"hadoop.hbase.master.assignmentmanger.bulkassign_75th_percentile",
    +				"hadoop.hbase.master.assignmentmanger.bulkassign_95th_percentile",
    +				"hadoop.hbase.master.assignmentmanger.bulkassign_99th_percentile",
    +				"hadoop.hbase.master.balancer.balancercluster_num_ops",
    +				"hadoop.hbase.master.balancer.balancercluster_min",
    +				"hadoop.hbase.master.balancer.balancercluster_max",
    +				"hadoop.hbase.master.balancer.balancercluster_75th_percentile",
    +				"hadoop.hbase.master.balancer.balancercluster_95th_percentile",
    +				"hadoop.hbase.master.balancer.balancercluster_99th_percentile",
    +				"hadoop.hbase.master.filesystem.hlogsplittime_min",
    +				"hadoop.hbase.master.filesystem.hlogsplittime_max",
    +				"hadoop.hbase.master.filesystem.hlogsplittime_75th_percentile",
    +				"hadoop.hbase.master.filesystem.hlogsplittime_95th_percentile",
    +				"hadoop.hbase.master.filesystem.hlogsplittime_99th_percentile",
    +				"hadoop.hbase.master.filesystem.hlogsplitsize_min",
    +				"hadoop.hbase.master.filesystem.hlogsplitsize_max",
    +				"hadoop.hbase.master.filesystem.metahlogsplittime_min",
    +				"hadoop.hbase.master.filesystem.metahlogsplittime_max",
    +				"hadoop.hbase.master.filesystem.metahlogsplittime_75th_percentile",
    +				"hadoop.hbase.master.filesystem.metahlogsplittime_95th_percentile",
    +				"hadoop.hbase.master.filesystem.metahlogsplittime_99th_percentile",
    +				"hadoop.hbase.master.filesystem.metahlogsplitsize_min",
    +				"hadoop.hbase.master.filesystem.metahlogsplitsize_max"
    +			];
     
    -			// Mock series data
    -			function mockMetric(name, option, count) {
    -				count = count || 1;
    -				var now = +new Date();
    +			PageConfig.title = 'Overview';
    +			var storageOption = {
    +				animation: false,
    +				tooltip: {
    +					formatter: function (points) {
    +						return points[0].name + "<br/>" +
    +							$.map(points, function (point) {
    +								return '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:'
+ point.color + '"></span> ' +
    +									point.seriesName + ": " +
    +									common.number.abbr(point.value, true, 0);
    +							}).reverse().join("<br/>");
    +					}
    +				},
    +				yAxis: [{
    +					axisLabel: {
    +						formatter: function (value) {
    +							return common.number.sizeFormat(value, 0);
    +						}
    +					}
    +				}]
    +			};
    +			$scope.metricList = {};
     
    -				var series = [];
    -				for (var i = 0 ; i < count ; i += 1) {
    -					var data = [];
    +			function generateHbaseMetric(name) {
    +				var startTime = Time.startTime();
    +				var endTime = Time.endTime();
    +				var interval = Time.diffInterval(startTime, endTime);
    +				var intervalMin = interval / 1000 / 60;
    +				var trendStartTime = Time.align(startTime, interval);
    +				var trendEndTime = Time.align(endTime, interval);
     
    -					for(var j = 0 ; j < 30 ; j += 1) {
    -						data.push({x: now + j * 1000 * 60, y: Math.random() * 100});
    -					}
    +				$scope.site = $wrapState.param.siteId;
     
    -					series.push($.extend({
    -						name: name + '_' + i,
    -						type: 'line',
    -						data: data,
    -						showSymbol: false,
    -					}, option));
    -				}
    +				var metrics = cache[name] = cache[name] || $q.all([activeMasterInfo._promise]).then(function
(res) {
    +					var hostname = cache[hostname] = cache[hostname] || res[0][0].tags.hostname;
    +					$scope.defaultHostname = $wrapState.param.hostname || hostname;
     
    +					var jobCond = {
    +						site: $scope.site,
    +						component: "hbasemaster",
    +						host: $scope.defaultHostname
    +					};
    +					return METRIC.aggMetricsToEntities(METRIC.hbaseMetricsAggregation(jobCond, name,
["site"], "avg(value)", intervalMin, trendStartTime, trendEndTime))._promise;
    +				});
    +				return metrics;
    +			}
    +
    +			function mergeMetricToOneSeries(metricTitle, metrics, legendName, dataOption, option)
{
    +				var series = [];
    +				$.each(metrics, function (i, metricMap) {
    +					$.map(metricMap, function (metric) {
    +						series.push(METRIC.metricsToSeries(legendName[i], metric, option));
    +					});
    +				});
     				return {
    -					title: name,
    -					series: series
    +					title: metricTitle,
    +					series: series,
    +					option: dataOption || {}
     				};
     			}
    +			// TODO: Optimize the chart count
    +			// TODO: ECharts dynamic refresh series bug: https://github.com/ecomfe/echarts/issues/4033
    +			$scope.refresh = function () {
    +				var hbaseservers = METRIC.hbasehostStatus({site: $scope.site});
    +				var promies = [];
    +				$.each(MASTER_METRIC_ARRAY, function (i, metric_name) {
    +					promies.push(generateHbaseMetric(metric_name));
    +				});
    +				promies.push(hbaseservers);
    +				$q.all(promies).then(function (res) {
    +					$scope.metricList = [
    +						mergeMetricToOneSeries("MemoryUsage", [res[0], res[1]], ["nonheap", "heap"], storageOption),
    --- End diff --
    
    Not use magic number. Ref: line 29. Use well design api instead.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message