ndimiduk commented on a change in pull request #830: HBASE-23281: Track meta
region locations in masters
URL: https://github.com/apache/hbase/pull/830#discussion_r347650440
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
##########
@@ -3051,6 +3053,44 @@ public static ProcedureDescription
buildProcedureDescription(String signature, S
return builder.build();
}
+ /**
+ * Get the Meta region state from the passed data bytes. Can handle both old
and new style
+ * server names.
+ * @param data protobuf serialized data with meta server name.
+ * @param replicaId replica ID for this region
+ * @return RegionState instance corresponding to the serialized data.
+ * @throws DeserializationException if the data is invalid.
+ */
+ public static RegionState parseMetaRegionStateFrom(final byte[] data, int
replicaId)
+ throws DeserializationException {
+ RegionState.State state = RegionState.State.OPEN;
+ ServerName serverName;
+ if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data))
{
+ try {
+ int prefixLen = ProtobufUtil.lengthOfPBMagic();
+ ZooKeeperProtos.MetaRegionServer rl =
+ ZooKeeperProtos.MetaRegionServer.parser().parseFrom(data,
prefixLen,
+ data.length - prefixLen);
+ if (rl.hasState()) {
+ state = RegionState.State.convert(rl.getState());
+ }
+ HBaseProtos.ServerName sn = rl.getServer();
+ serverName = ServerName.valueOf(
+ sn.getHostName(), sn.getPort(), sn.getStartCode());
+ } catch (InvalidProtocolBufferException e) {
+ throw new DeserializationException("Unable to parse meta region
location");
+ }
+ } else {
+ // old style of meta region location?
+ serverName = parseServerNameFrom(data);
+ }
+ if (serverName == null) {
+ state = RegionState.State.OFFLINE;
Review comment:
nit: the default state value be `OFFLINE`, then this null-check and
assignment is not necessary.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services