currentStatus = getState(namespace); int regionCount = currentStatus.getRegionCount(); long maxRegionCount = TableNamespaceManager.getMaxRegions(nspdesc); if (incr > 0 && regionCount >= maxRegionCount) { LOG.warn("The region " + Bytes.toStringBinary(regionName)
public void validateTableAndRegionCount(NamespaceDescriptor desc) throws IOException { if (getMaxRegions(desc) <= 0) { throw new ConstraintException( "The max region quota for " + desc.getName() + " is less than or equal to zero."); } if (getMaxTables(desc) <= 0) { throw new ConstraintException( "The max tables quota for " + desc.getName() + " is less than or equal to zero."); } }
/** * 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. */ synchronized void checkAndUpdateNamespaceRegionCount(TableName name, int incr) throws IOException { String namespace = name.getNamespaceAsString(); NamespaceDescriptor nspdesc = getNamespaceDescriptor(namespace); if (nspdesc != null) { NamespaceTableAndRegionInfo currentStatus = getState(namespace); int regionCountOfTable = currentStatus.getRegionCountOfTable(name); if ((currentStatus.getRegionCount() - regionCountOfTable + incr) > TableNamespaceManager .getMaxRegions(nspdesc)) { throw new QuotaExceededException("The table " + name.getNameAsString() + " region count cannot be updated as it would exceed maximum number " + "of regions allowed in the namespace. The total number of regions permitted is " + TableNamespaceManager.getMaxRegions(nspdesc)); } currentStatus.removeTable(name); currentStatus.addTable(name, incr); } }
synchronized void checkAndUpdateNamespaceTableCount(TableName table, int numRegions) throws IOException { 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); }
void validateTableAndRegionCount(NamespaceDescriptor desc) throws IOException { if (getMaxRegions(desc) <= 0) { throw new ConstraintException("The max region quota for " + desc.getName() + " is less than or equal to zero."); } if (getMaxTables(desc) <= 0) { throw new ConstraintException("The max tables quota for " + desc.getName() + " is less than or equal to zero."); } }
/** * Check and update region count for an existing table. To handle scenarios like restore snapshot * @param TableName 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. */ synchronized void checkAndUpdateNamespaceRegionCount(TableName name, int incr) throws IOException { String namespace = name.getNamespaceAsString(); NamespaceDescriptor nspdesc = getNamespaceDescriptor(namespace); if (nspdesc != null) { NamespaceTableAndRegionInfo currentStatus = getState(namespace); int regionCountOfTable = currentStatus.getRegionCountOfTable(name); if ((currentStatus.getRegionCount() - regionCountOfTable + incr) > TableNamespaceManager .getMaxRegions(nspdesc)) { throw new QuotaExceededException("The table " + name.getNameAsString() + " region count cannot be updated as it would exceed maximum number " + "of regions allowed in the namespace. The total number of regions permitted is " + TableNamespaceManager.getMaxRegions(nspdesc)); } currentStatus.removeTable(name); currentStatus.addTable(name, incr); } }
synchronized void checkAndUpdateNamespaceTableCount(TableName table, int numRegions) throws IOException { 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); }
currentStatus = getState(namespace); if (incr > 0 && currentStatus.getRegionCount() >= TableNamespaceManager.getMaxRegions(nspdesc)) { LOG.warn("The region " + Bytes.toStringBinary(regionName) + " cannot be created. The region count will exceed quota on the namespace. "