private static int getDefaultMasterPort(Configuration conf) {
    final int port = conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT);
    if (port == 0) {
      // Master port may be set to 0. We should substitute the default port in that case.
      return HConstants.DEFAULT_MASTER_PORT;
    }
    return port;
  }
Supplies the default master port we should use given the provided configuration.
@param conf Configuration to parse from.
hbase-client/src/main/java/org/apache/hadoop/hbase/client/MasterRegistry.java