CHUKWA-788. Save ring chart threshold setting in HBase. (Eric Yang)
Project: http://git-wip-us.apache.org/repos/asf/chukwa/repo Commit: http://git-wip-us.apache.org/repos/asf/chukwa/commit/aa76d992 Tree: http://git-wip-us.apache.org/repos/asf/chukwa/tree/aa76d992 Diff: http://git-wip-us.apache.org/repos/asf/chukwa/diff/aa76d992 Branch: refs/heads/master Commit: aa76d992103168e93b7d1b2c1c92d67fad843567 Parents: 49384fb Author: Eric Yang <[email protected]> Authored: Sat Nov 28 10:38:30 2015 -0800 Committer: Eric Yang <[email protected]> Committed: Sat Nov 28 10:38:30 2015 -0800 ---------------------------------------------------------------------- CHANGES.txt | 2 ++ .../chukwa/datastore/ChukwaHBaseStore.java | 15 +++++++------- .../apache/hadoop/chukwa/hicc/bean/Chart.java | 9 +++++++++ .../apache/hadoop/chukwa/util/HBaseUtil.java | 14 ++++++------- src/main/web/hicc/WEB-INF/vm/circles.vm | 21 ++++++++++++++------ src/main/web/hicc/home/css/jquery.gridster.css | 6 +++--- src/main/web/hicc/home/graph-explorer.html | 10 ++++++---- 7 files changed, 50 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/chukwa/blob/aa76d992/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 684b3f5..6d37755 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -66,6 +66,8 @@ Trunk (unreleased changes) BUGS + CHUKWA-788. Save ring chart threshold setting in HBase. (Eric Yang) + CHUKWA-784. Improve CharFileTailingAdaptorUTF8NewLineEscaped and LocalWriter logic to send proper data chunk. (Eric Yang) http://git-wip-us.apache.org/repos/asf/chukwa/blob/aa76d992/src/main/java/org/apache/hadoop/chukwa/datastore/ChukwaHBaseStore.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/hadoop/chukwa/datastore/ChukwaHBaseStore.java b/src/main/java/org/apache/hadoop/chukwa/datastore/ChukwaHBaseStore.java index 120b731..bdd765d 100644 --- a/src/main/java/org/apache/hadoop/chukwa/datastore/ChukwaHBaseStore.java +++ b/src/main/java/org/apache/hadoop/chukwa/datastore/ChukwaHBaseStore.java @@ -449,10 +449,11 @@ public class ChukwaHBaseStore { * @throws URISyntaxException */ public static synchronized String createCircle(String id, - String title, String[] metrics, String source, String suffixLabel) throws URISyntaxException { + String title, String[] metrics, String source, String suffixLabel, String direction) throws URISyntaxException { Chart chart = new Chart(id); chart.setSuffixText(suffixLabel); chart.setTitle(title); + chart.setThreshold(direction); ArrayList<SeriesMetaData> series = new ArrayList<SeriesMetaData>(); for(String metric : metrics) { SeriesMetaData s = new SeriesMetaData(); @@ -924,18 +925,18 @@ public class ChukwaHBaseStore { namenode.append(hostname); namenode.append(":NameNode"); String[] namenodeHeap = { "HadoopMetrics.jvm.JvmMetrics.MemHeapUsedM", "HadoopMetrics.jvm.JvmMetrics.MemHeapMaxM" }; - createCircle("7", "Namenode Memory", namenodeHeap, namenode.toString(), "%"); + createCircle("7", "Namenode Memory", namenodeHeap, namenode.toString(), "%", "up"); // HDFS Usage - String[] hdfsUsage = { "HadoopMetrics.dfs.FSNamesystem.CapacityUsed", "HadoopMetrics.dfs.FSNamesystem.CapacityTotal" }; - createCircle("8", "HDFS Usage", hdfsUsage, hostname, "%"); + String[] hdfsUsage = { "HadoopMetrics.dfs.FSNamesystem.CapacityRemainingGB", "HadoopMetrics.dfs.FSNamesystem.CapacityTotalGB" }; + createCircle("8", "HDFS Remaining", hdfsUsage, hostname, "%", "down"); // Resource Manager Memory StringBuilder rmnode = new StringBuilder(); rmnode.append(hostname); rmnode.append(":ResourceManager"); String[] rmHeap = { "HadoopMetrics.jvm.JvmMetrics.MemHeapUsedM", "HadoopMetrics.jvm.JvmMetrics.MemHeapMaxM" }; - createCircle("9", "Resource Manager Memory", rmHeap, rmnode.toString(), "%"); + createCircle("9", "Resource Manager Memory", rmHeap, rmnode.toString(), "%", "up"); // Node Managers Health String[] nmh = { "HadoopMetrics.yarn.ClusterMetrics.NumActiveNMs", "HadoopMetrics.yarn.ClusterMetrics.NumLostNMs" }; @@ -962,7 +963,7 @@ public class ChukwaHBaseStore { hbaseMaster.append(hostname); hbaseMaster.append(":Master"); String[] hbm = { "HBaseMetrics.jvm.JvmMetrics.MemHeapUsedM", "HBaseMetrics.jvm.JvmMetrics.MemHeapMaxM" }; - createCircle("15", "HBase Master Memory", hbm, hbaseMaster.toString(), "%"); + createCircle("15", "HBase Master Memory", hbm, hbaseMaster.toString(), "%", "up"); // Demo metrics // String[] trialAbandonRate = { "HadoopMetrics.jvm.JvmMetrics.MemHeapUsedM", "HadoopMetrics.jvm.JvmMetrics.MemHeapMaxM" }; @@ -1200,7 +1201,7 @@ public class ChukwaHBaseStore { dashboard.add(widget); widget = new Widget(); - widget.setTitle("HDFS Usage"); + widget.setTitle("HDFS Remaining"); widget.setSrc(new URI("/hicc/v1/circles/draw/8")); widget.setCol(1); widget.setRow(2); http://git-wip-us.apache.org/repos/asf/chukwa/blob/aa76d992/src/main/java/org/apache/hadoop/chukwa/hicc/bean/Chart.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/hadoop/chukwa/hicc/bean/Chart.java b/src/main/java/org/apache/hadoop/chukwa/hicc/bean/Chart.java index 06b2bd5..a944373 100644 --- a/src/main/java/org/apache/hadoop/chukwa/hicc/bean/Chart.java +++ b/src/main/java/org/apache/hadoop/chukwa/hicc/bean/Chart.java @@ -46,6 +46,7 @@ public class Chart { private String icon = ""; private String bannerText = ""; private String suffixText = ""; + private String threshold = ""; public Chart(String id) { this.id = id; @@ -233,4 +234,12 @@ public class Chart { public String getSuffixText() { return this.suffixText; } + + public void setThreshold(String direction) { + this.threshold = direction; + } + + public String getThreshold() { + return this.threshold; + } } http://git-wip-us.apache.org/repos/asf/chukwa/blob/aa76d992/src/main/java/org/apache/hadoop/chukwa/util/HBaseUtil.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/hadoop/chukwa/util/HBaseUtil.java b/src/main/java/org/apache/hadoop/chukwa/util/HBaseUtil.java index 70a80c0..9462b5d 100644 --- a/src/main/java/org/apache/hadoop/chukwa/util/HBaseUtil.java +++ b/src/main/java/org/apache/hadoop/chukwa/util/HBaseUtil.java @@ -54,9 +54,9 @@ public class HBaseUtil { c.setTimeInMillis(time); byte[] day = Integer.toString(c.get(Calendar.DAY_OF_YEAR)).getBytes(Charset.forName("UTF-8")); byte[] pk = getHash(primaryKey); - byte[] key = new byte[12]; + byte[] key = new byte[14]; System.arraycopy(day, 0, key, 0, day.length); - System.arraycopy(pk, 0, key, 2, 5); + System.arraycopy(pk, 0, key, 2, 6); return key; } @@ -66,16 +66,16 @@ public class HBaseUtil { byte[] day = Integer.toString(c.get(Calendar.DAY_OF_YEAR)).getBytes(Charset.forName("UTF-8")); byte[] pk = getHash(primaryKey); byte[] src = getHash(source); - byte[] key = new byte[12]; + byte[] key = new byte[14]; System.arraycopy(day, 0, key, 0, day.length); - System.arraycopy(pk, 0, key, 2, 5); - System.arraycopy(src, 0, key, 7, 5); + System.arraycopy(pk, 0, key, 2, 6); + System.arraycopy(src, 0, key, 8, 6); return key; } private static byte[] getHash(String key) { - byte[] hash = new byte[5]; - System.arraycopy(md5.digest(key.getBytes(Charset.forName("UTF-8"))), 0, hash, 0, 5); + byte[] hash = new byte[6]; + System.arraycopy(md5.digest(key.getBytes(Charset.forName("UTF-8"))), 0, hash, 0, 6); return hash; } } http://git-wip-us.apache.org/repos/asf/chukwa/blob/aa76d992/src/main/web/hicc/WEB-INF/vm/circles.vm ---------------------------------------------------------------------- diff --git a/src/main/web/hicc/WEB-INF/vm/circles.vm b/src/main/web/hicc/WEB-INF/vm/circles.vm index 76d9b41..65e38ff 100644 --- a/src/main/web/hicc/WEB-INF/vm/circles.vm +++ b/src/main/web/hicc/WEB-INF/vm/circles.vm @@ -88,12 +88,21 @@ function render(result) { var fontsize = 38; var percent = result.series.data[0][1]; var text = percent+"$chart.getSuffixText()"; - var color = "#70cac8"; - if(percent > 75) { - color = "#fc6e64"; - } else if (percent > 50) { - color = "#f7d254"; - } + #if ($chart.getThreshold()=="up") + var color = "#70cac8"; + if(percent > 75) { + color = "#fc6e64"; + } else if (percent > 50) { + color = "#f7d254"; + } + #else + var color = "#70cac8"; + if(percent < 25) { + color = "#fc6e64"; + } else if (percent < 50) { + color = "#f7d254"; + } + #end if(radius < 200) { width=10; fontsize = 12; http://git-wip-us.apache.org/repos/asf/chukwa/blob/aa76d992/src/main/web/hicc/home/css/jquery.gridster.css ---------------------------------------------------------------------- diff --git a/src/main/web/hicc/home/css/jquery.gridster.css b/src/main/web/hicc/home/css/jquery.gridster.css index 9251929..14fee6b 100755 --- a/src/main/web/hicc/home/css/jquery.gridster.css +++ b/src/main/web/hicc/home/css/jquery.gridster.css @@ -177,18 +177,18 @@ body { } .gs-w:hover .gs-header { - opacity: .9; + opacity: .3; //filter: blur(5px); } .gs-header { - color: white; + color: #555555; position: absolute; top: 0; left: 0; width: 100%; height: 30px; - background-color: #496274; + background-color: #eeeeee; opacity: 0; z-index: 20; } http://git-wip-us.apache.org/repos/asf/chukwa/blob/aa76d992/src/main/web/hicc/home/graph-explorer.html ---------------------------------------------------------------------- diff --git a/src/main/web/hicc/home/graph-explorer.html b/src/main/web/hicc/home/graph-explorer.html index 03ede7c..a7c1084 100644 --- a/src/main/web/hicc/home/graph-explorer.html +++ b/src/main/web/hicc/home/graph-explorer.html @@ -82,8 +82,8 @@ <div role="tabpanel" class="tab-pane" id="ring"> <label>Threshold</label> <select id="threshold" class="form-control"> - <option>Upper bound</option> - <option>Lower bound</option> + <option value="up">Upper bound</option> + <option value="down">Lower bound</option> </select> <label>Suffix Label</label><input type="text" id="ringSuffix" class="form-control" /> </div> @@ -227,6 +227,7 @@ $(function() { var ymin = $('#ymin').val() ; var ymax = $('#ymax').val(); var yunit = $('#yunit').val(); + var threshold = $('#threshold').val(); var banner = $('#banner').val(); var suffix = $('#suffix').val(); var view = $("ul#view li.active"); @@ -239,10 +240,11 @@ $(function() { 'icon' : icon, 'bannerText' : banner, 'suffixText' : suffix, - 'yUnitType' : yunit, + 'yUnitType' : yunit, + 'threshold' : threshold, 'width' : 300, 'height' : 200, - 'series' : url + 'series' : url }; if(ymin!='') { data['min']=ymin;
