From: <tob...@us...> - 2014-06-28 01:45:10
|
Revision: 8507 http://sourceforge.net/p/bigdata/code/8507 Author: tobycraig Date: 2014-06-28 01:45:04 +0000 (Sat, 28 Jun 2014) Log Message: ----------- Added per service status to health tab Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/HAStatusServletUtil.java branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java 2014-06-27 21:26:52 UTC (rev 8506) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/Banner.java 2014-06-28 01:45:04 UTC (rev 8507) @@ -350,6 +350,19 @@ } /** + * Attempts to return build version. + * + * @return Build version if available + */ + public final static String getVersion() { + if (getBuildInfo().isEmpty()) { + return "unknown"; + } + + return getBuildInfo().get("buildVersion"); + } + + /** * Outputs the banner and exits. * * @param args Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/HAStatusServletUtil.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/HAStatusServletUtil.java 2014-06-27 21:26:52 UTC (rev 8506) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-sails/src/java/com/bigdata/rdf/sail/webapp/HAStatusServletUtil.java 2014-06-28 01:45:04 UTC (rev 8507) @@ -43,6 +43,7 @@ import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.ZooKeeper; +import com.bigdata.Banner; import com.bigdata.BigdataStatics; import com.bigdata.ha.HAGlue; import com.bigdata.ha.HAStatusEnum; @@ -916,28 +917,39 @@ json.writeStartObject(); - json.writeFieldName("version"); - json.writeString("1.0"); // FIXME - json.writeFieldName("timestamp"); - json.writeNumber(new Date().getTime()); // FIXME + json.writeStringField("version", Banner.getVersion()); + json.writeNumberField("timestamp", new Date().getTime()); if(quorum.isQuorumFullyMet(quorum.token())) { - json.writeFieldName("status"); - json.writeString("Good"); - json.writeFieldName("details"); - json.writeString("All servers joined"); + json.writeStringField("status", "Good"); + json.writeStringField("details", "All servers joined"); } else { // at least one server is not available, so status is either Warning or Bad - json.writeFieldName("status"); if(quorum.isQuorumMet()) { - json.writeString("Warning"); + json.writeStringField("status", "Warning"); } else { - json.writeString("Bad"); + json.writeStringField("status", "Bad"); } - json.writeFieldName("details"); - json.writeString("Only " + quorum.getJoined().length + " of target " + + json.writeStringField("details", "Only " + quorum.getJoined().length + " of target " + quorum.replicationFactor() + " servers joined"); } + json.writeFieldName("services"); + json.writeStartArray(); + + final UUID[] joined = quorum.getJoined(); + final UUID[] pipeline = quorum.getPipeline(); + + for (UUID serviceId : pipeline) { + final boolean isLeader = serviceId.equals(quorum.getLeaderId()); + final boolean isFollower = indexOf(serviceId, joined) > 0; + + json.writeStartObject(); + json.writeStringField("id", serviceId.toString()); + json.writeStringField("status", isLeader ? "leader" : (isFollower ? "follower" : "unready")); + json.writeEndObject(); + } + + json.writeEndArray(); json.writeEndObject(); json.close(); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-27 21:26:52 UTC (rev 8506) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/index.html 2014-06-28 01:45:04 UTC (rev 8507) @@ -202,11 +202,17 @@ <div class="tab" id="health-tab"> + <div class="box" id="health-overview"> + <h1>Overview</h1> + <p class="health-status">Status: <span></span></p> + <p class="health-details">Details: <span></span></p> + <p class="health-version">Version: <span></span></p> + <p class="health-timestamp">Timestamp: <span></span></p> + </div> + + <div id="health-services"></div> + <div class="box"> - <p id="health-status">Status: <span></span></p> - <p id="health-details">Details: <span></span></p> - <p id="health-version">Version: <span></span></p> - <p id="health-timestamp">Timestamp: <span></span></p> <p><a href="#" id="health-refresh">Refresh</a></p> </div> Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-27 21:26:52 UTC (rev 8506) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-war/src/html/js/workbench.js 2014-06-28 01:45:04 UTC (rev 8507) @@ -1406,15 +1406,31 @@ function getHealth(e) { e.preventDefault(); $.get('/status?health', function(data) { - for(var key in data) { - if(key == 'timestamp') { - var date = new Date(data[key]); - data[key] = date.toString(); + $('#health-overview .health-status span').html(data.status); + $('#health-overview').removeClass('health-good health-warning health-bad').addClass('health-' + data.status.toLowerCase()); + $('#health-overview .health-details span').html(data.details); + $('#health-overview .health-version span').html(data.version); + $('#health-overview .health-timestamp span').html(new Date(data.timestamp).toString()); + + $('#health-services div').remove(); + for(var i=0; i<data.services.length; i++) { + var div = $('<div>'); + div.append('<p>ID: ' + data.services[i].id + '</p>'); + div.append('<p>Status: ' + data.services[i].status + '</p>'); + var health; + switch(data.services[i].status) { + case 'leader': + case 'follower': + health = 'good'; + break; + case 'unready': + health = 'warning'; + break; + default: + health = 'bad'; } - if(key == 'status') { - $('#health-overview').removeClass('health-good health-warning health-bad').addClass('health-' + data[key].toLowerCase()); - } - $('#health-' + key + ' span').html(data[key]); + div.addClass('box health-' + health); + div.appendTo($('#health-services')); } }) } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |