diff --git a/hbase-server/src/main/resources/hbase-webapps/master/rits.jsp b/hbase-server/src/main/resources/hbase-webapps/master/rits.jsp index 17d0090cb6e..3fc960ee0c6 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/rits.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/rits.jsp @@ -21,11 +21,17 @@ import="static org.apache.commons.lang3.StringEscapeUtils.escapeXml" import="java.util.Collections" import="java.util.Comparator" + import="java.util.ArrayList" import="java.util.List" + import="java.util.HashMap" + import="java.util.Map" import="java.util.stream.Collectors" import="org.apache.hadoop.hbase.master.HMaster" + import="org.apache.hadoop.hbase.master.RegionState" import="org.apache.hadoop.hbase.master.assignment.RegionStateNode" import="org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure" + import="org.apache.hadoop.hbase.util.GsonUtil" + import="org.apache.hbase.thirdparty.com.google.gson.Gson" %> <% HMaster master = (HMaster) getServletContext().getAttribute(HMaster.MASTER); @@ -69,6 +75,7 @@ @@ -79,14 +86,18 @@ Region Table RegionState + Server Procedure ProcedureState + Start Time + Duration (ms) <% for (RegionStateNode regionStateNode : rit) { %> <%= regionStateNode.getRegionInfo().getEncodedName() %> <%= regionStateNode.getRegionInfo().getTable() %> <%= regionStateNode.getState() %> + <%= regionStateNode.getRegionLocation().getServerName() %> <% TransitRegionStateProcedure procedure = regionStateNode.getProcedure(); @@ -98,6 +109,10 @@ <%= procedure.getProcId() %> <%= escapeXml(procedure.getState().toString() + (procedure.isBypass() ? "(Bypassed)" : "")) %> <% } %> + + <% RegionState rs = regionStateNode.toRegionState(); %> + <%= rs.getStamp() %> + <%= System.currentTimeMillis() - rs.getStamp() %> <% } %>

<%= rit.size() %> region(s) in transition.

@@ -107,7 +122,30 @@ <% } %> - +<% } else if (format.equals("json")) { %> +<% + Gson GSON = GsonUtil.createGson().create(); + Map>> map = new HashMap<>(); + List> rits = new ArrayList<>(); + map.put("rits", rits); + for (RegionStateNode regionStateNode : rit) { + Map r = new HashMap<>(); + r.put("region", regionStateNode.getRegionInfo().getEncodedName()); + r.put("table", regionStateNode.getRegionInfo().getTable().getNameAsString()); + r.put("state", regionStateNode.getState()); + r.put("server", regionStateNode.getRegionLocation().getServerName()); + TransitRegionStateProcedure procedure = regionStateNode.getProcedure(); + if (procedure != null) { + r.put("procedureId", procedure.getProcId()); + r.put("procedureState", procedure.getState().toString()); + } + RegionState rs = regionStateNode.toRegionState(); + r.put("startTime", rs.getStamp()); + r.put("duration", System.currentTimeMillis() - rs.getStamp()); + rits.add(r); + } + %> + <%= GSON.toJson(map) %> <% } else { %>
@@ -127,4 +165,4 @@

-<% } %> \ No newline at end of file +<% } %>