MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / handleMetaZnode

Method handleMetaZnode

src/HBaseClient.java:4489–4531  ·  view source on GitHub ↗

Returns a new client for the RS found in the meta-region-server. This is used in HBase 0.95 and up.

(final byte[] data)

Source from the content-addressed store, hash-verified

4487 * This is used in HBase 0.95 and up.
4488 */
4489 protected RegionClient handleMetaZnode(final byte[] data) {
4490 if (data[0] != MAGIC) {
4491 LOG.error("Malformed META region meta-data in " + Bytes.pretty(data)
4492 + ", invalid leading magic number: " + data[0]);
4493 return null;
4494 }
4495
4496 final int metadata_length = Bytes.getInt(data, 1);
4497 if (metadata_length < 1 || metadata_length > 65000) {
4498 LOG.error("Malformed META region meta-data in " + Bytes.pretty(data)
4499 + ", invalid metadata length=" + metadata_length);
4500 return null; // TODO(tsuna): Add a watch to wait until the file changes.
4501 }
4502 short offset = (short) (1 + 4 + metadata_length);
4503
4504 final int pbuf_magic = Bytes.getInt(data, offset);
4505 if (pbuf_magic != PBUF_MAGIC) {
4506 LOG.error("Malformed META region meta-data in " + Bytes.pretty(data)
4507 + ", invalid magic number=" + pbuf_magic);
4508 return null; // TODO(tsuna): Add a watch to wait until the file changes.
4509 }
4510 offset += 4;
4511
4512 final String ip;
4513 final int port;
4514 try {
4515 final ZooKeeperPB.MetaRegionServer meta =
4516 ZooKeeperPB.MetaRegionServer.newBuilder()
4517 .mergeFrom(data, offset, data.length - offset).build();
4518 ip = getIP(meta.getServer().getHostName());
4519 port = meta.getServer().getPort();
4520 } catch (InvalidProtocolBufferException e) {
4521 LOG.error("Failed to parse the protobuf in " + Bytes.pretty(data), e);
4522 return null; // TODO(tsuna): Add a watch to wait until the file changes.
4523 }
4524
4525 LOG.info("Connecting to " + (split_meta ?
4526 new String(HBASE96_META) : new String(META))
4527 + " region @ " + ip + ':' + port);
4528 has_root = split_meta ? true : false;
4529 final RegionClient client = rootregion = newClient(ip, port);
4530 return client;
4531 }
4532
4533 }
4534

Calls 5

prettyMethod · 0.95
getIntMethod · 0.95
getIPMethod · 0.80
getPortMethod · 0.80
newClientMethod · 0.80