synchronized void checkAndUpdateNamespaceTableCount(TableName table, int numRegions)
    throws IOException {
    if (table.isSystemTable()) {
      return;
    }
    String namespace = table.getNamespaceAsString();
    NamespaceDescriptor nspdesc = getNamespaceDescriptor(namespace);
    if (nspdesc != null) {
      NamespaceTableAndRegionInfo currentStatus;
      currentStatus = getState(nspdesc.getName());
      if ((currentStatus.getTables().size()) >= TableNamespaceManager.getMaxTables(nspdesc)) {
        throw new QuotaExceededException("The table " + table.getNameAsString()
          + " cannot be created as it would exceed maximum number of tables allowed "
          + " in the namespace.  The total number of tables permitted is "
          + TableNamespaceManager.getMaxTables(nspdesc));
      }
      if (
        (currentStatus.getRegionCount() + numRegions) > TableNamespaceManager.getMaxRegions(nspdesc)
      ) {
        throw new QuotaExceededException(
          "The table " + table.getNameAsString() + " is not allowed to have " + numRegions
            + " regions. The total number of regions permitted is only "
            + TableNamespaceManager.getMaxRegions(nspdesc) + ", while current region count is "
            + currentStatus.getRegionCount()
            + ". This may be transient, please retry later if there are any"
            + " ongoing split operations in the namespace.");
      }
    } else {
      throw new IOException(
        "Namespace Descriptor found null for " + namespace + " This is unexpected.");
    }
    addTable(table, numRegions);
  }
Check and update region count for an existing table. To handle scenarios like restore snapshot
@param name name of the table for region count needs to be checked and updated
@param incr count of regions
@throws QuotaExceededException if quota exceeds for the number of regions allowed in a
                               namespace
@throws IOException            Signals that an I/O exception has occurred.
hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceStateManager.java