static byte[] toByteArray(final ServerName sn, int infoPort) {
    ZooKeeperProtos.Master.Builder mbuilder = ZooKeeperProtos.Master.newBuilder();
    HBaseProtos.ServerName.Builder snbuilder = HBaseProtos.ServerName.newBuilder();
    snbuilder.setHostName(sn.getHostname());
    snbuilder.setPort(sn.getPort());
    snbuilder.setStartCode(sn.getStartcode());
    mbuilder.setMaster(snbuilder.build());
    mbuilder.setRpcVersion(HConstants.RPC_CURRENT_VERSION);
    mbuilder.setInfoPort(infoPort);
    return ProtobufUtil.prependPBMagic(mbuilder.build().toByteArray());
  }
@param sn must not be null
@return Content of the master znode as a serialized pb with the pb magic as prefix.
hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MasterAddressTracker.java