HBASE-5967 OpenDataException because HBaseProtos.ServerLoad cannot be converted to an open data type (Gregory)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1354098 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2012-06-26 16:31:36 +00:00
parent 36a903366a
commit 0475dd5dae
3 changed files with 8 additions and 6 deletions

View File

@ -294,7 +294,7 @@ public class ClusterStatus extends VersionedWritable {
for (Map.Entry<ServerName, ServerLoad> entry : liveServers.entrySet()) {
LiveServerInfo.Builder lsi =
LiveServerInfo.newBuilder().setServer(ProtobufUtil.toServerName(entry.getKey()));
lsi.setServerLoad(entry.getValue().getServerLoadPB());
lsi.setServerLoad(entry.getValue().obtainServerLoadPB());
builder.addLiveServers(lsi.build());
}
for (ServerName deadServer : getDeadServerNames()) {

View File

@ -75,8 +75,10 @@ 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 HBaseProtos.ServerLoad getServerLoadPB() {
public HBaseProtos.ServerLoad obtainServerLoadPB() {
return serverLoad;
}
@ -208,7 +210,7 @@ public class ServerLoad {
* @return string array of loaded RegionServer-level coprocessors
*/
public String[] getRegionServerCoprocessors() {
List<Coprocessor> list = getServerLoadPB().getCoprocessorsList();
List<Coprocessor> list = obtainServerLoadPB().getCoprocessorsList();
String [] ret = new String[list.size()];
int i = 0;
for (Coprocessor elem : list) {
@ -227,11 +229,11 @@ public class ServerLoad {
// Need a set to remove duplicates, but since generated Coprocessor class
// is not Comparable, make it a Set<String> instead of Set<Coprocessor>
TreeSet<String> coprocessSet = new TreeSet<String>();
for (Coprocessor coprocessor : getServerLoadPB().getCoprocessorsList()) {
for (Coprocessor coprocessor : obtainServerLoadPB().getCoprocessorsList()) {
coprocessSet.add(coprocessor.getName());
}
for (HBaseProtos.RegionLoad rl : getServerLoadPB().getRegionLoadsList()) {
for (HBaseProtos.RegionLoad rl : obtainServerLoadPB().getRegionLoadsList()) {
for (Coprocessor coprocessor : rl.getCoprocessorsList()) {
coprocessSet.add(coprocessor.getName());
}

View File

@ -219,7 +219,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.getServerLoadPB());
request.setLoad(ServerLoad.EMPTY_SERVERLOAD.obtainServerLoadPB());
master.regionServerReport(null, request.build());
}
// Master should now come up.