Skip to content

Commit 7fcfcf3

Browse files
committed
HBASE-22146 SpaceQuotaViolationPolicy Disable is not working in Namespace -update
1 parent b719081 commit 7fcfcf3

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/namespace/NamespaceAuditor.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,6 @@ public void addNamespace(NamespaceDescriptor ns) throws IOException {
142142

143143
public void deleteNamespace(String namespace) throws IOException {
144144
stateManager.deleteNamespace(namespace);
145-
Set<TableName> tableNameSet = getState(namespace).getTables();
146-
for (TableName tableName: tableNameSet) {
147-
removeFromNamespaceUsage(tableName);
148-
}
149145
}
150146

151147
public void removeFromNamespaceUsage(TableName tableName)

hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaUtil.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.hadoop.hbase.TableNotDisabledException;
3333
import org.apache.hadoop.hbase.TableNotEnabledException;
3434
import org.apache.hadoop.hbase.TableNotFoundException;
35+
import org.apache.hadoop.hbase.NamespaceDescriptor;
3536
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
3637
import org.apache.hadoop.hbase.client.Connection;
3738
import org.apache.hadoop.hbase.client.Delete;
@@ -264,17 +265,33 @@ private static void deleteQuotas(final Connection connection, final byte[] rowKe
264265
final byte[] qualifier) throws IOException {
265266
Delete delete = new Delete(rowKey);
266267
if (qualifier != null) {
267-
delete.addColumns(QUOTA_FAMILY_INFO, qualifier);
268+
if (Arrays.equals(qualifier,QUOTA_QUALIFIER_POLICY)) {
269+
delete.addColumns(QUOTA_FAMILY_USAGE, qualifier);
270+
} else
271+
delete.addColumns(QUOTA_FAMILY_INFO, qualifier);
268272
}
269-
doDelete(connection, delete);
270273
if (isNamespaceRowKey(rowKey)) {
271-
TableName[] tableArray = connection.getAdmin().listTableNamesByNamespace(getNamespaceFromRowKey(rowKey));
272-
for (TableName tableName: tableArray) {
273-
if (QuotaUtil.getTableQuota(connection, tableName) == null) {
274-
deleteTableQuota(connection,tableName);
274+
//Check namespace is not deleted before you get info about quota and list of tables in namespace
275+
NamespaceDescriptor[] descs = connection.getAdmin().listNamespaceDescriptors();
276+
String ns = getNamespaceFromRowKey(rowKey);
277+
int index = 0;
278+
while (index < descs.length) {
279+
if (ns.equals(descs[index].getName())) {
280+
Quotas namespaceQuota = getNamespaceQuota(connection,ns);
281+
if (namespaceQuota != null && namespaceQuota.hasSpace()) {
282+
TableName[] tableArray = connection.getAdmin().listTableNamesByNamespace(ns);
283+
for (TableName tableName : tableArray) {
284+
deleteQuotas(connection, getTableRowKey(tableName), QUOTA_QUALIFIER_POLICY);
285+
}
286+
}
287+
//Exit the while loop by moving to last index
288+
index = descs.length;
289+
} else {
290+
index++;
275291
}
276292
}
277293
}
294+
doDelete(connection, delete);
278295
}
279296

280297
public static Map<String, UserQuotaState> fetchUserQuotas(final Connection connection,

0 commit comments

Comments
 (0)