.../java/org/apache/hadoop/hbase/RegionLoad.java | 4 +- .../hadoop/hbase/RegionLoadProtosWrapper.java | 38 ++++++ .../java/org/apache/hadoop/hbase/ServerLoad.java | 46 ++++---- .../hadoop/hbase/ServerLoadProtosWrapper.java | 38 ++++++ .../hadoop/hbase/client/RegionLoadStats.java | 4 +- .../apache/hadoop/hbase/protobuf/ProtobufUtil.java | 16 ++- .../hbase/TestInterfaceAudienceAnnotations.java | 131 +++++++++++++++++++++ .../java/org/apache/hadoop/hbase/util/Triple.java | 4 + .../hadoop/hbase/master/MasterRpcServices.java | 3 +- .../main/resources/hbase-webapps/master/table.jsp | 7 +- .../org/apache/hadoop/hbase/TestServerLoad.java | 7 +- .../hadoop/hbase/master/TestMasterNoCluster.java | 2 +- 12 files changed, 264 insertions(+), 36 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java index 5bf2ec7..c361973 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoad.java @@ -38,8 +38,8 @@ public class RegionLoad { protected ClusterStatusProtos.RegionLoad regionLoadPB; - public RegionLoad(ClusterStatusProtos.RegionLoad regionLoadPB) { - this.regionLoadPB = regionLoadPB; + public RegionLoad(RegionLoadProtosWrapper regionLoadPB) { + this.regionLoadPB = regionLoadPB.getRegionLoad(); } /** diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoadProtosWrapper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoadProtosWrapper.java new file mode 100644 index 0000000..75d0543 --- /dev/null +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/RegionLoadProtosWrapper.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase; + +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos; +import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad; + +/** + * A wrapper on the {@link RegionLoad} + */ +@InterfaceAudience.Private +public class RegionLoadProtosWrapper { + private ClusterStatusProtos.RegionLoad regionLoadPB; + + public RegionLoadProtosWrapper(ClusterStatusProtos.RegionLoad regionLoadPB) { + this.regionLoadPB = regionLoadPB; + } + + public ClusterStatusProtos.RegionLoad getRegionLoad() { + return this.regionLoadPB; + } +} diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java index 1ddcc20..55505bb 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java @@ -57,9 +57,9 @@ public class ServerLoad { private long totalCompactingKVs = 0; private long currentCompactedKVs = 0; - public ServerLoad(ClusterStatusProtos.ServerLoad serverLoad) { + public ServerLoad(ServerLoadProtosWrapper serverLoad) { this.serverLoad = serverLoad; - for (ClusterStatusProtos.RegionLoad rl: serverLoad.getRegionLoadsList()) { + for (ClusterStatusProtos.RegionLoad rl: serverLoad.getServerLoad().getRegionLoadsList()) { stores += rl.getStores(); storefiles += rl.getStorefiles(); storeUncompressedSizeMB += rl.getStoreUncompressedSizeMB(); @@ -81,42 +81,42 @@ public class ServerLoad { // NOTE: Function name cannot start with "get" because then an OpenDataException is thrown because // HBaseProtos.ServerLoad cannot be converted to an open data type(see HBASE-5967). /* @return the underlying ServerLoad protobuf object */ - public ClusterStatusProtos.ServerLoad obtainServerLoadPB() { + public ServerLoadProtosWrapper obtainServerLoadPB() { return serverLoad; } - protected ClusterStatusProtos.ServerLoad serverLoad; + protected ServerLoadProtosWrapper serverLoad; /* @return number of requests since last report. */ public long getNumberOfRequests() { - return serverLoad.getNumberOfRequests(); + return serverLoad.getServerLoad().getNumberOfRequests(); } public boolean hasNumberOfRequests() { - return serverLoad.hasNumberOfRequests(); + return serverLoad.getServerLoad().hasNumberOfRequests(); } /* @return total Number of requests from the start of the region server. */ public long getTotalNumberOfRequests() { - return serverLoad.getTotalNumberOfRequests(); + return serverLoad.getServerLoad().getTotalNumberOfRequests(); } public boolean hasTotalNumberOfRequests() { - return serverLoad.hasTotalNumberOfRequests(); + return serverLoad.getServerLoad().hasTotalNumberOfRequests(); } /* @return the amount of used heap, in MB. */ public int getUsedHeapMB() { - return serverLoad.getUsedHeapMB(); + return serverLoad.getServerLoad().getUsedHeapMB(); } public boolean hasUsedHeapMB() { - return serverLoad.hasUsedHeapMB(); + return serverLoad.getServerLoad().hasUsedHeapMB(); } /* @return the maximum allowable size of the heap, in MB. */ public int getMaxHeapMB() { - return serverLoad.getMaxHeapMB(); + return serverLoad.getServerLoad().getMaxHeapMB(); } public boolean hasMaxHeapMB() { - return serverLoad.hasMaxHeapMB(); + return serverLoad.getServerLoad().hasMaxHeapMB(); } public int getStores() { @@ -179,11 +179,11 @@ public class ServerLoad { * @return the number of regions */ public int getNumberOfRegions() { - return serverLoad.getRegionLoadsCount(); + return serverLoad.getServerLoad().getRegionLoadsCount(); } public int getInfoServerPort() { - return serverLoad.getInfoServerPort(); + return serverLoad.getServerLoad().getInfoServerPort(); } /** @@ -191,7 +191,8 @@ public class ServerLoad { * @return the list of ReplicationLoadSource */ public List getReplicationLoadSourceList() { - return ProtobufUtil.toReplicationLoadSourceList(serverLoad.getReplLoadSourceList()); + return ProtobufUtil + .toReplicationLoadSourceList(serverLoad.getServerLoad().getReplLoadSourceList()); } /** @@ -199,8 +200,8 @@ public class ServerLoad { * @return ReplicationLoadSink */ public ReplicationLoadSink getReplicationLoadSink() { - if (serverLoad.hasReplLoadSink()) { - return ProtobufUtil.toReplicationLoadSink(serverLoad.getReplLoadSink()); + if (serverLoad.getServerLoad().hasReplLoadSink()) { + return ProtobufUtil.toReplicationLoadSink(serverLoad.getServerLoad().getReplLoadSink()); } else { return null; } @@ -229,8 +230,8 @@ public class ServerLoad { public Map getRegionsLoad() { Map regionLoads = new TreeMap(Bytes.BYTES_COMPARATOR); - for (ClusterStatusProtos.RegionLoad rl : serverLoad.getRegionLoadsList()) { - RegionLoad regionLoad = new RegionLoad(rl); + for (ClusterStatusProtos.RegionLoad rl : serverLoad.getServerLoad().getRegionLoadsList()) { + RegionLoad regionLoad = new RegionLoad(ProtobufUtil.createRegionLoadWrapper(rl)); regionLoads.put(regionLoad.getName(), regionLoad); } return regionLoads; @@ -241,7 +242,7 @@ public class ServerLoad { * @return string array of loaded RegionServer-level coprocessors */ public String[] getRegionServerCoprocessors() { - List list = obtainServerLoadPB().getCoprocessorsList(); + List list = serverLoad.getServerLoad().getCoprocessorsList(); String [] ret = new String[list.size()]; int i = 0; for (Coprocessor elem : list) { @@ -260,7 +261,7 @@ public class ServerLoad { // Need a set to remove duplicates, but since generated Coprocessor class // is not Comparable, make it a Set instead of Set TreeSet coprocessSet = new TreeSet(); - for (Coprocessor coprocessor : obtainServerLoadPB().getCoprocessorsList()) { + for (Coprocessor coprocessor : serverLoad.getServerLoad().getCoprocessorsList()) { coprocessSet.add(coprocessor.getName()); } return coprocessSet.toArray(new String[coprocessSet.size()]); @@ -330,5 +331,6 @@ public class ServerLoad { } public static final ServerLoad EMPTY_SERVERLOAD = - new ServerLoad(ClusterStatusProtos.ServerLoad.newBuilder().build()); + new ServerLoad( + ProtobufUtil.createServerLoadWrapper(ClusterStatusProtos.ServerLoad.newBuilder().build())); } diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoadProtosWrapper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoadProtosWrapper.java new file mode 100644 index 0000000..94a38b4 --- /dev/null +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoadProtosWrapper.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase; + +import org.apache.hadoop.hbase.classification.InterfaceAudience; +import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos; +import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.ServerLoad; + +/** + * A wrapper on the {@link ServerLoad} + */ +@InterfaceAudience.Private +public class ServerLoadProtosWrapper { + private ClusterStatusProtos.ServerLoad serverLoad; + + public ServerLoadProtosWrapper(ClusterStatusProtos.ServerLoad serverLoad) { + this.serverLoad = serverLoad; + } + + public ClusterStatusProtos.ServerLoad getServerLoad() { + return this.serverLoad; + } +} diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionLoadStats.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionLoadStats.java index 443026f..bfdb216 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionLoadStats.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionLoadStats.java @@ -20,11 +20,11 @@ package org.apache.hadoop.hbase.client; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; -@InterfaceAudience.Public -@InterfaceStability.Evolving /** * POJO representing region server load */ +@InterfaceAudience.Public +@InterfaceStability.Evolving public class RegionLoadStats { int memstoreLoad; int heapOccupancy; diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java index 0c34a17..f379880 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java @@ -57,7 +57,9 @@ import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.NamespaceDescriptor; +import org.apache.hadoop.hbase.RegionLoadProtosWrapper; import org.apache.hadoop.hbase.ServerLoad; +import org.apache.hadoop.hbase.ServerLoadProtosWrapper; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.Tag; @@ -3516,7 +3518,7 @@ public final class ProtobufUtil { servers = new HashMap(proto.getLiveServersList().size()); for (LiveServerInfo lsi : proto.getLiveServersList()) { servers.put(ProtobufUtil.toServerName( - lsi.getServer()), new ServerLoad(lsi.getServerLoad())); + lsi.getServer()), new ServerLoad(ProtobufUtil.createServerLoadWrapper(lsi.getServerLoad()))); } Collection deadServers = null; @@ -3567,7 +3569,7 @@ public final class ProtobufUtil { LiveServerInfo.Builder lsi = LiveServerInfo.newBuilder().setServer(ProtobufUtil.toServerName(serverName)); status.getLoad(serverName); - lsi.setServerLoad(status.getLoad(serverName).obtainServerLoadPB()); + lsi.setServerLoad(status.getLoad(serverName).obtainServerLoadPB().getServerLoad()); builder.addLiveServers(lsi.build()); } } @@ -3622,4 +3624,14 @@ public final class ProtobufUtil { return new RegionLoadStats(stats.getMemstoreLoad(), stats.getHeapOccupancy(), stats.getCompactionPressure()); } + + public static RegionLoadProtosWrapper + createRegionLoadWrapper(ClusterStatusProtos.RegionLoad regionLoadPB) { + return new RegionLoadProtosWrapper(regionLoadPB); + } + + public static ServerLoadProtosWrapper + createServerLoadWrapper(ClusterStatusProtos.ServerLoad serverLoad) { + return new ServerLoadProtosWrapper(serverLoad); + } } diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java index 0e0fbb0..1326c73 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java @@ -20,7 +20,12 @@ package org.apache.hadoop.hbase; import java.io.IOException; import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.lang.reflect.Parameter; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import org.apache.commons.logging.Log; @@ -28,6 +33,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.testclassification.SmallTests; +import org.apache.hadoop.hbase.util.Pair; +import org.apache.hadoop.hbase.util.Triple; import org.apache.hadoop.hbase.ClassFinder.And; import org.apache.hadoop.hbase.ClassFinder.FileNameFilter; import org.apache.hadoop.hbase.ClassFinder.Not; @@ -59,6 +66,7 @@ import org.junit.experimental.categories.Category; @Category(SmallTests.class) public class TestInterfaceAudienceAnnotations { + private static final String HBASE_PROTOBUF = "org.apache.hadoop.hbase.protobuf.generated"; private static final Log LOG = LogFactory.getLog(TestInterfaceAudienceAnnotations.class); /** Selects classes with generated in their package name */ @@ -299,4 +307,127 @@ public class TestInterfaceAudienceAnnotations { + "have @InterfaceStability annotation as well", 0, classes.size()); } + + @Test + public void testProtosInReturnTypes() throws ClassNotFoundException, IOException, LinkageError { + ClassFinder classFinder = + new ClassFinder(new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), + new Not((FileNameFilter) new TestFileNameFilter()), + new And(new PublicClassFilter(), new Not(new TestClassFilter()), + new Not(new GeneratedClassFilter()), + new InterfaceAudiencePublicAnnotatedClassFilter())); + Set> classes = classFinder.findClasses(false); + List, Method>> protosReturnType = new ArrayList, Method>>(); + for (Class clazz : classes) { + findProtoInReturnType(clazz, protosReturnType); + } + if (protosReturnType.size() != 0) { + LOG.info("These are the methods that have Protos as the return type"); + for (Pair, Method> pair : protosReturnType) { + LOG.info(pair.getFirst().getName() + " " + pair.getSecond().getName() + " " + + pair.getSecond().getReturnType().getName()); + } + } + + Assert.assertEquals("Public exposed methods should not have protos in return type", 0, + protosReturnType.size()); + } + + @Test + public void testProtosInParamTypes() throws ClassNotFoundException, IOException, LinkageError { + ClassFinder classFinder = + new ClassFinder(new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), + new Not((FileNameFilter) new TestFileNameFilter()), + new And(new PublicClassFilter(), new Not(new TestClassFilter()), + new Not(new GeneratedClassFilter()), + new InterfaceAudiencePublicAnnotatedClassFilter())); + Set> classes = classFinder.findClasses(false); + List, Method, Parameter>> protosParamType = + new ArrayList, Method, Parameter>>(); + for (Class clazz : classes) { + findProtoInParamType(clazz, protosParamType); + } + + if (protosParamType.size() != 0) { + LOG.info("These are the methods that have Protos as the param type"); + for (Triple, Method, Parameter> pair : protosParamType) { + LOG.info(pair.getFirst().getName() + " " + pair.getSecond().getName() + " " + + pair.getThird().getType().getName()); + } + } + + Assert.assertEquals("Public exposed methods should not have protos in param type", 0, + protosParamType.size()); + } + + @Test + public void testProtosInConstructors() throws ClassNotFoundException, IOException, LinkageError { + ClassFinder classFinder = + new ClassFinder(new And(new MainCodeResourcePathFilter(), new TestFileNameFilter()), + new Not((FileNameFilter) new TestFileNameFilter()), + new And(new PublicClassFilter(), new Not(new TestClassFilter()), + new Not(new GeneratedClassFilter()), + new InterfaceAudiencePublicAnnotatedClassFilter())); + Set> classes = classFinder.findClasses(false); + List> classList = new ArrayList>(); + for (Class clazz : classes) { + Constructor[] constructors = clazz.getConstructors(); + for (Constructor cons : constructors) { + Parameter[] parameters = cons.getParameters(); + for (Parameter param : parameters) { + if (param.getType().getName().contains(HBASE_PROTOBUF)) { + classList.add(clazz); + break; + } + } + } + } + + if (classList.size() != 0) { + LOG.info("These are the classes that have Protos in the constructor"); + for (Class clazz : classList) { + LOG.info(clazz.getName()); + } + } + + Assert.assertEquals("Public exposed classes should not have protos in constructors", 0, + classList.size()); + } + + private void findProtoInReturnType(Class clazz, + List, Method>> protosReturnType) { + Pair, Method> returnTypePair = new Pair, Method>(); + Method[] methods = clazz.getMethods(); + returnTypePair.setFirst(clazz); + for (Method method : methods) { + if (clazz.isInterface() || method.getModifiers() == Modifier.PUBLIC) { + Class returnType = method.getReturnType(); + if (returnType.getName().contains(HBASE_PROTOBUF)) { + returnTypePair.setSecond(method); + protosReturnType.add(returnTypePair); + continue; + } + } + } + } + + private void findProtoInParamType(Class clazz, + List, Method, Parameter>> protosParamType) { + Triple, Method, Parameter> paramType = new Triple, Method, Parameter>(); + Method[] methods = clazz.getMethods(); + paramType.setFirst(clazz); + for (Method method : methods) { + if (clazz.isInterface() || method.getModifiers() == Modifier.PUBLIC) { + Parameter[] parameters = method.getParameters(); + for (Parameter param : parameters) { + if (param.getType().getName().contains(HBASE_PROTOBUF)) { + paramType.setSecond(method); + paramType.setThird(param); + protosParamType.add(paramType); + break; + } + } + } + } + } } diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java index 1438ab7..1de6bee 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Triple.java @@ -28,6 +28,10 @@ public class Triple { private A first; private B second; private C third; + // default constructor + public Triple() { + + } public Triple(A first, B second, C third) { this.first = first; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java index 2f65e97..5c4e20f 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java @@ -246,7 +246,8 @@ public class MasterRpcServices extends RSRpcServices ClusterStatusProtos.ServerLoad sl = request.getLoad(); ServerName serverName = ProtobufUtil.toServerName(request.getServer()); ServerLoad oldLoad = master.getServerManager().getLoad(serverName); - master.getServerManager().regionServerReport(serverName, new ServerLoad(sl)); + master.getServerManager().regionServerReport(serverName, + new ServerLoad(ProtobufUtil.createServerLoadWrapper(sl))); if (sl != null && master.metricsMaster != null) { // Up our metrics. master.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests() 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 cc13972..f9a2f75 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp @@ -42,6 +42,7 @@ import="org.apache.hadoop.hbase.zookeeper.MetaTableLocator" import="org.apache.hadoop.hbase.util.Bytes" import="org.apache.hadoop.hbase.util.FSUtils" + import="org.apache.hadoop.hbase.protobuf.ProtobufUtil" import="org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos" import="org.apache.hadoop.hbase.protobuf.generated.HBaseProtos" import="org.apache.hadoop.hbase.TableName" @@ -344,15 +345,15 @@ if ( fqtn != null ) { totalStoreFileCount += regionload.getStorefiles(); totalMemSize += regionload.getMemStoreSizeMB(); } else { - RegionLoad load0 = new RegionLoad(ClusterStatusProtos.RegionLoad.newBuilder().setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build()); + RegionLoad load0 = new RegionLoad(ProtobufUtil.createRegionLoadWrapper(ClusterStatusProtos.RegionLoad.newBuilder().setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build())); regionsToLoad.put(regionInfo, load0); } }else{ - RegionLoad load0 = new RegionLoad(ClusterStatusProtos.RegionLoad.newBuilder().setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build()); + RegionLoad load0 = new RegionLoad(ProtobufUtil.createRegionLoadWrapper(ClusterStatusProtos.RegionLoad.newBuilder().setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build())); regionsToLoad.put(regionInfo, load0); } }else{ - RegionLoad load0 = new RegionLoad(ClusterStatusProtos.RegionLoad.newBuilder().setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build()); + RegionLoad load0 = new RegionLoad(ProtobufUtil.createRegionLoadWrapper(ClusterStatusProtos.RegionLoad.newBuilder().setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build())); regionsToLoad.put(regionInfo, load0); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerLoad.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerLoad.java index e6c17a5..d1b28bf 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerLoad.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestServerLoad.java @@ -22,6 +22,7 @@ package org.apache.hadoop.hbase; import static org.junit.Assert.*; +import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos; import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos; import org.apache.hadoop.hbase.testclassification.MiscTests; @@ -36,7 +37,7 @@ public class TestServerLoad { @Test public void testRegionLoadAggregation() { - ServerLoad sl = new ServerLoad(createServerLoadProto()); + ServerLoad sl = new ServerLoad(ProtobufUtil.createServerLoadWrapper(createServerLoadProto())); assertEquals(13, sl.getStores()); assertEquals(114, sl.getStorefiles()); assertEquals(129, sl.getStoreUncompressedSizeMB()); @@ -50,7 +51,7 @@ public class TestServerLoad { @Test public void testToString() { - ServerLoad sl = new ServerLoad(createServerLoadProto()); + ServerLoad sl = new ServerLoad(ProtobufUtil.createServerLoadWrapper(createServerLoadProto())); String slToString = sl.toString(); assertTrue(slToString.contains("numberOfStores=13")); assertTrue(slToString.contains("numberOfStorefiles=114")); @@ -63,7 +64,7 @@ public class TestServerLoad { @Test public void testRegionLoadWrapAroundAggregation() { - ServerLoad sl = new ServerLoad(createServerLoadProto()); + ServerLoad sl = new ServerLoad(ProtobufUtil.createServerLoadWrapper(createServerLoadProto())); long totalCount = ((long)Integer.MAX_VALUE)*2; assertEquals(totalCount, sl.getReadRequestsCount()); assertEquals(totalCount, sl.getWriteRequestsCount()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java index da0b9a6..ffcf72f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java @@ -239,7 +239,7 @@ public class TestMasterNoCluster { RegionServerReportRequest.Builder request = RegionServerReportRequest.newBuilder();; ServerName sn = ServerName.parseVersionedServerName(sns[i].getVersionedBytes()); request.setServer(ProtobufUtil.toServerName(sn)); - request.setLoad(ServerLoad.EMPTY_SERVERLOAD.obtainServerLoadPB()); + request.setLoad(ServerLoad.EMPTY_SERVERLOAD.obtainServerLoadPB().getServerLoad()); master.getMasterRpcServices().regionServerReport(null, request.build()); } // Master should now come up.