|
32 | 32 | import org.apache.hadoop.hbase.TableNotDisabledException; |
33 | 33 | import org.apache.hadoop.hbase.TableNotEnabledException; |
34 | 34 | import org.apache.hadoop.hbase.TableNotFoundException; |
| 35 | +import org.apache.hadoop.hbase.NamespaceDescriptor; |
35 | 36 | import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; |
36 | 37 | import org.apache.hadoop.hbase.client.Connection; |
37 | 38 | import org.apache.hadoop.hbase.client.Delete; |
@@ -264,17 +265,33 @@ private static void deleteQuotas(final Connection connection, final byte[] rowKe |
264 | 265 | final byte[] qualifier) throws IOException { |
265 | 266 | Delete delete = new Delete(rowKey); |
266 | 267 | 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); |
268 | 272 | } |
269 | | - doDelete(connection, delete); |
270 | 273 | 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++; |
275 | 291 | } |
276 | 292 | } |
277 | 293 | } |
| 294 | + doDelete(connection, delete); |
278 | 295 | } |
279 | 296 |
|
280 | 297 | public static Map<String, UserQuotaState> fetchUserQuotas(final Connection connection, |
|
0 commit comments