diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/master/RegionState.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/master/RegionState.java index 2d03473b9f6b..a2f92e397c9c 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/master/RegionState.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/master/RegionState.java @@ -354,6 +354,11 @@ public boolean isReadyToOffline() { || isSplittingNew() || isMergingNew(); } + public boolean isSplitOrMerge() { + return isMerged() || isMergingNew() || isMerging() + || isSplit() || isSplittingNew() || isSplitting(); + } + /** * Check if a region state can transition to online */ diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon index 388357d6eb0f..84787c5cee34 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon @@ -44,9 +44,8 @@ org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; <%java return; %> <%java> - ServerInfo serverInfo = ProtobufUtil.getServerInfo(null, regionServer.getRSRpcServices()); - ServerName serverName = ProtobufUtil.toServerName(serverInfo.getServerName()); - List onlineRegions = ProtobufUtil.getOnlineRegions(regionServer.getRSRpcServices()); + ServerName serverName = regionServer.getServerName(); + List onlineRegions = regionServer.getOnlineRegionInfos(); MasterAddressTracker masterAddressTracker = regionServer.getMasterAddressTracker(); ServerName masterServerName = masterAddressTracker == null ? null : masterAddressTracker.getMasterAddress(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStates.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStates.java index 147a112152bb..54f82343f5d2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStates.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStates.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import java.util.SortedSet; +import java.util.TreeMap; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListMap; @@ -543,10 +544,11 @@ public Map> getRegionByStateOfTable(TableNam tableRegions.put(states[i], new ArrayList()); } - for (RegionStateNode node: regionsMap.values()) { - if (node.getTable().equals(tableName)) { - tableRegions.get(node.getState()).add(node.getRegionInfo()); + for (RegionStateNode node: regionsMap.tailMap(tableName.getName()).values()) { + if (!node.getTable().equals(tableName)) { + break; } + tableRegions.get(node.getState()).add(node.getRegionInfo()); } return tableRegions; } @@ -804,4 +806,21 @@ public static String regionNamesToString(final Collection regions) { sb.append("]"); return sb.toString(); } + + /** + * WEB UI + */ + public synchronized Map getRegionLocations(TableName tableName) { + Map tableRegions = new TreeMap<>(); + for (RegionStateNode regionStateNode : regionsMap.tailMap(tableName.getName()).values()) { + if (!regionStateNode.getTable().equals(tableName)) { + break; + } + if (regionStateNode.toRegionState().isSplitOrMerge()) { + continue; + } + tableRegions.put(regionStateNode.getRegionInfo(), regionStateNode.getRegionLocation()); + } + return tableRegions; + } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index bcb143652203..5d70a982d951 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -2949,6 +2949,18 @@ protected Map getOnlineRegions() { return this.onlineRegions; } + /** + * WEB UI + */ + public List getOnlineRegionInfos() { + List allRegionInfos; + synchronized (this.onlineRegions) { + allRegionInfos = onlineRegions.values().stream().map(HRegion::getRegionInfo) + .collect(Collectors.toList()); + } + return allRegionInfos; + } + public int getNumberOfOnlineRegions() { return this.onlineRegions.size(); } diff --git a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp index 6a28de16bb7a..a155aa4e2be5 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp @@ -434,10 +434,7 @@ <% if (rsGroupTables != null && rsGroupTables.size() > 0) { - List tables; - try (Admin admin = master.getConnection().getAdmin()) { - tables = master.isInitialized() ? admin.listTableDescriptors(true) : null; - } + List tables = master.isInitialized() ? master.listTableDescriptors(null, null, null, true) : new ArrayList<>(); Map tableDescriptors = tables.stream().collect( Collectors.toMap(TableDescriptor::getTableName, Function.identity())); %> diff --git a/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp b/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp index 9b1328a3a32b..61f1e8480953 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp @@ -21,9 +21,9 @@ import="java.util.Date" import="org.apache.hadoop.conf.Configuration" import="org.apache.hadoop.hbase.client.Admin" - import="org.apache.hadoop.hbase.client.SnapshotDescription" import="org.apache.hadoop.hbase.http.InfoServer" import="org.apache.hadoop.hbase.master.HMaster" + import="org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription" import="org.apache.hadoop.hbase.snapshot.SnapshotInfo" import="org.apache.hadoop.util.StringUtils" import="org.apache.hadoop.hbase.TableName" @@ -40,11 +40,11 @@ long snapshotTtl = 0; if(snapshotName != null && master.isInitialized()) { try (Admin admin = master.getConnection().getAdmin()) { - for (SnapshotDescription snapshotDesc: admin.listSnapshots()) { + for (SnapshotDescription snapshotDesc: master.getSnapshotManager().getCompletedSnapshots()) { if (snapshotName.equals(snapshotDesc.getName())) { snapshot = snapshotDesc; - stats = SnapshotInfo.getSnapshotStats(conf, snapshot); - snapshotTable = snapshot.getTableName(); + stats = SnapshotInfo.getSnapshotStats(conf, snapshot, null); + snapshotTable = TableName.valueOf(snapshot.getTable()); snapshotTtl = snapshot.getTtl(); tableExists = admin.tableExists(snapshotTable); break; diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp index b800e72f37b7..3b816ab23c5a 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp @@ -635,7 +635,6 @@ stateMap.put(regionInfo.getEncodedName(), regionState); } } - RegionLocator r = master.getConnection().getRegionLocator(table.getName()); try { %> @@ -820,12 +819,11 @@ String totalLocalityForSsd = ""; Map regDistribution = new TreeMap<>(); Map primaryRegDistribution = new TreeMap<>(); - List regions = r.getAllRegionLocations(); Map regionsToLoad = new LinkedHashMap<>(); - Map regionsToServer = new LinkedHashMap<>(); - for (HRegionLocation hriEntry : regions) { - RegionInfo regionInfo = hriEntry.getRegion(); - ServerName addr = hriEntry.getServerName(); + Map regionsToServer = master.getAssignmentManager().getRegionStates().getRegionLocations(table.getName()); + for (Map.Entry hriEntry : regionsToServer.entrySet()) { + RegionInfo regionInfo = hriEntry.getKey(); + ServerName addr = hriEntry.getValue(); regionsToServer.put(regionInfo, addr); if (addr != null) { @@ -874,7 +872,7 @@ totalLocalityForSsd = String.format("%.1f", ((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight)); } - if(regions != null && regions.size() > 0) { %> + if(regionsToServer != null && regionsToServer.size() > 0) { %>

Table Regions