diff --git a/CHANGES.txt b/CHANGES.txt index ea1a3b35333..4042d9c93b2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -84,6 +84,8 @@ Release 0.91.0 - Unreleased HBASE-3657 reduce copying of HRegionInfo's (Ted Yu via Stack) HBASE-3422 Balancer will try to rebalance thousands of regions in one go; needs an upper bound added (Ted Yu via Stack) + HBASE-3676 Update region server load for AssignmentManager through + regionServerReport() (Ted Yu via Stack) TASK HBASE-3559 Move report of split to master OFF the heartbeat channel diff --git a/src/main/java/org/apache/hadoop/hbase/HServerLoad.java b/src/main/java/org/apache/hadoop/hbase/HServerLoad.java index 05ff4b93c88..561a000df0e 100644 --- a/src/main/java/org/apache/hadoop/hbase/HServerLoad.java +++ b/src/main/java/org/apache/hadoop/hbase/HServerLoad.java @@ -22,9 +22,9 @@ package org.apache.hadoop.hbase; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Strings; @@ -47,7 +47,7 @@ public class HServerLoad implements WritableComparable { /** the maximum allowable size of the heap, in MB */ private int maxHeapMB; /** per-region load metrics */ - private ArrayList regionLoad = new ArrayList(); + private Map regionLoad = new TreeMap(Bytes.BYTES_COMPARATOR); /** * Encapsulates per-region loading metrics. @@ -86,8 +86,7 @@ public class HServerLoad implements WritableComparable { */ public RegionLoad(final byte[] name, final int stores, final int storefiles, final int storefileSizeMB, - final int memstoreSizeMB, final int storefileIndexSizeMB, - final long requestsCount) { + final int memstoreSizeMB, final int storefileIndexSizeMB,final long requestsCount) { this.name = name; this.stores = stores; this.storefiles = storefiles; @@ -282,7 +281,9 @@ public class HServerLoad implements WritableComparable { */ public HServerLoad(final HServerLoad hsl) { this(hsl.numberOfRequests, hsl.usedHeapMB, hsl.maxHeapMB); - this.regionLoad.addAll(hsl.regionLoad); + for (Map.Entry e : hsl.regionLoad.entrySet()) { + this.regionLoad.put(e.getKey(), e.getValue()); + } } /** @@ -387,8 +388,8 @@ public class HServerLoad implements WritableComparable { /** * @return region load metrics */ - public Collection getRegionsLoad() { - return Collections.unmodifiableCollection(regionLoad); + public Map getRegionsLoad() { + return Collections.unmodifiableMap(regionLoad); } /** @@ -396,7 +397,7 @@ public class HServerLoad implements WritableComparable { */ public int getStorefiles() { int count = 0; - for (RegionLoad info: regionLoad) + for (RegionLoad info: regionLoad.values()) count += info.getStorefiles(); return count; } @@ -406,7 +407,7 @@ public class HServerLoad implements WritableComparable { */ public int getStorefileSizeInMB() { int count = 0; - for (RegionLoad info: regionLoad) + for (RegionLoad info: regionLoad.values()) count += info.getStorefileSizeMB(); return count; } @@ -416,7 +417,7 @@ public class HServerLoad implements WritableComparable { */ public int getMemStoreSizeInMB() { int count = 0; - for (RegionLoad info: regionLoad) + for (RegionLoad info: regionLoad.values()) count += info.getMemStoreSizeMB(); return count; } @@ -426,7 +427,7 @@ public class HServerLoad implements WritableComparable { */ public int getStorefileIndexSizeInMB() { int count = 0; - for (RegionLoad info: regionLoad) + for (RegionLoad info: regionLoad.values()) count += info.getStorefileIndexSizeMB(); return count; } @@ -466,7 +467,7 @@ public class HServerLoad implements WritableComparable { */ public void addRegionInfo(final HServerLoad.RegionLoad load) { this.numberOfRegions++; - this.regionLoad.add(load); + this.regionLoad.put(load.getName(), load); } /** @@ -483,7 +484,7 @@ public class HServerLoad implements WritableComparable { final int storefiles, final int storefileSizeMB, final int memstoreSizeMB, final int storefileIndexSizeMB, final long requestsCount) { - this.regionLoad.add(new HServerLoad.RegionLoad(name, stores, storefiles, + this.regionLoad.put(name, new HServerLoad.RegionLoad(name, stores, storefiles, storefileSizeMB, memstoreSizeMB, storefileIndexSizeMB, requestsCount)); } @@ -497,7 +498,7 @@ public class HServerLoad implements WritableComparable { for (int i = 0; i < numberOfRegions; i++) { RegionLoad rl = new RegionLoad(); rl.readFields(in); - regionLoad.add(rl); + regionLoad.put(rl.getName(), rl); } } @@ -506,8 +507,8 @@ public class HServerLoad implements WritableComparable { out.writeInt(usedHeapMB); out.writeInt(maxHeapMB); out.writeInt(numberOfRegions); - for (int i = 0; i < numberOfRegions; i++) - regionLoad.get(i).write(out); + for (RegionLoad rl: regionLoad.values()) + rl.write(out); } // Comparable diff --git a/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java b/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java index 14e8fa107f0..d7a1e67c307 100644 --- a/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java +++ b/src/main/java/org/apache/hadoop/hbase/avro/AvroUtil.java @@ -93,7 +93,7 @@ public class AvroUtil { asl.numberOfRegions = hsl.getNumberOfRegions(); asl.numberOfRequests = hsl.getNumberOfRequests(); - Collection regionLoads = hsl.getRegionsLoad(); + Collection regionLoads = hsl.getRegionsLoad().values(); Schema s = Schema.createArray(ARegionLoad.SCHEMA$); GenericData.Array aregionLoads = null; if (regionLoads != null) { diff --git a/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java b/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java index 4dd082bbc4f..4b8a59abcd6 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java +++ b/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java @@ -326,6 +326,18 @@ public class ServerManager { // No more piggyback messages on heartbeats for other stuff return msgs; } + + /** + * Make server load accessible to AssignmentManager + * @param serverName + * @return + * @throws HServerLoad if serverName is known + */ + HServerLoad getLoad(String serverName) { + HServerInfo hsi = this.onlineServers.get(serverName); + if (hsi == null) return null; + return hsi.getLoad(); + } /** * @param serverName diff --git a/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java b/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java index 69ed646a35a..578ee145292 100644 --- a/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java +++ b/src/main/java/org/apache/hadoop/hbase/rest/StorageClusterStatusResource.java @@ -82,7 +82,7 @@ public class StorageClusterStatusResource extends ResourceBase { info.getStartCode(), load.getUsedHeapMB(), load.getMaxHeapMB()); node.setRequests(load.getNumberOfRequests()); - for (HServerLoad.RegionLoad region: load.getRegionsLoad()) { + for (HServerLoad.RegionLoad region: load.getRegionsLoad().values()) { node.addRegion(region.getName(), region.getStores(), region.getStorefiles(), region.getStorefileSizeMB(), region.getMemStoreSizeMB(), region.getStorefileIndexSizeMB());