synchronized boolean checkAndUpdateNamespaceRegionCount(TableName name, byte[] regionName,
    int incr) throws IOException {
    if (name.isSystemTable()) {
      return true;
    }
    String namespace = name.getNamespaceAsString();
    NamespaceDescriptor nspdesc = getNamespaceDescriptor(namespace);
    if (nspdesc != null) {
      NamespaceTableAndRegionInfo currentStatus;
      currentStatus = getState(namespace);
      int regionCount = currentStatus.getRegionCount();
      long maxRegionCount = TableNamespaceManager.getMaxRegions(nspdesc);
      if (incr > 0 && regionCount >= maxRegionCount) {
        LOG.warn(
          "The region {} cannot be created. The region count  will exceed quota on the namespace. "
            + "This may be transient, please retry later if there are any ongoing split"
            + " operations in the namespace.",
          Bytes.toStringBinary(regionName));
        return false;
      }
      NamespaceTableAndRegionInfo nsInfo = nsStateCache.get(namespace);
      if (nsInfo != null) {
        nsInfo.incRegionCountForTable(name, incr);
      } else {
        LOG.warn("Namespace state found null for namespace : {}", namespace);
      }
    }
    return true;
  }
Check if adding a region violates namespace quota, if not update namespace cache.
@return true, if region can be added to table.
@throws IOException Signals that an I/O exception has occurred.
hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceStateManager.java