|
21 | 21 | import java.io.ByteArrayInputStream; |
22 | 22 | import java.io.ByteArrayOutputStream; |
23 | 23 | import java.io.IOException; |
24 | | -import java.util.ArrayList; |
25 | 24 | import java.util.Collection; |
26 | 25 | import java.util.HashMap; |
27 | | -import java.util.HashSet; |
28 | 26 | import java.util.List; |
29 | 27 | import java.util.Map; |
30 | 28 | import java.util.Objects; |
31 | | -import java.util.Set; |
32 | 29 | import java.util.regex.Pattern; |
33 | | - |
34 | 30 | import org.apache.commons.lang3.StringUtils; |
35 | 31 | import org.apache.hadoop.hbase.Cell; |
36 | 32 | import org.apache.hadoop.hbase.CellScanner; |
37 | 33 | import org.apache.hadoop.hbase.CompareOperator; |
38 | 34 | import org.apache.hadoop.hbase.NamespaceDescriptor; |
39 | 35 | import org.apache.hadoop.hbase.TableName; |
40 | 36 | import org.apache.hadoop.hbase.client.Connection; |
41 | | -import org.apache.hadoop.hbase.client.Delete; |
42 | 37 | import org.apache.hadoop.hbase.client.Get; |
43 | 38 | import org.apache.hadoop.hbase.client.Put; |
44 | 39 | import org.apache.hadoop.hbase.client.Result; |
|
58 | 53 | import org.slf4j.Logger; |
59 | 54 | import org.slf4j.LoggerFactory; |
60 | 55 |
|
61 | | -import org.apache.hbase.thirdparty.com.google.common.collect.HashMultimap; |
62 | | -import org.apache.hbase.thirdparty.com.google.common.collect.Multimap; |
63 | 56 | import org.apache.hbase.thirdparty.com.google.protobuf.ByteString; |
64 | 57 | import org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException; |
65 | 58 | import org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations; |
@@ -547,87 +540,6 @@ static Put createPutForNamespaceSnapshotSize(String namespace, long size) { |
547 | 540 | return p; |
548 | 541 | } |
549 | 542 |
|
550 | | - /** |
551 | | - * Returns a list of {@code Delete} to remove given table snapshot |
552 | | - * entries to remove from quota table |
553 | | - * @param snapshotEntriesToRemove the entries to remove |
554 | | - */ |
555 | | - static List<Delete> createDeletesForExistingTableSnapshotSizes( |
556 | | - Multimap<TableName, String> snapshotEntriesToRemove) { |
557 | | - List<Delete> deletes = new ArrayList<>(); |
558 | | - for (Map.Entry<TableName, Collection<String>> entry : snapshotEntriesToRemove.asMap() |
559 | | - .entrySet()) { |
560 | | - for (String snapshot : entry.getValue()) { |
561 | | - Delete d = new Delete(getTableRowKey(entry.getKey())); |
562 | | - d.addColumns(QUOTA_FAMILY_USAGE, |
563 | | - Bytes.add(QUOTA_SNAPSHOT_SIZE_QUALIFIER, Bytes.toBytes(snapshot))); |
564 | | - deletes.add(d); |
565 | | - } |
566 | | - } |
567 | | - return deletes; |
568 | | - } |
569 | | - |
570 | | - /** |
571 | | - * Returns a list of {@code Delete} to remove all table snapshot entries from quota table. |
572 | | - * @param connection connection to re-use |
573 | | - */ |
574 | | - static List<Delete> createDeletesForExistingTableSnapshotSizes(Connection connection) |
575 | | - throws IOException { |
576 | | - return createDeletesForExistingSnapshotsFromScan(connection, createScanForSpaceSnapshotSizes()); |
577 | | - } |
578 | | - |
579 | | - /** |
580 | | - * Returns a list of {@code Delete} to remove given namespace snapshot |
581 | | - * entries to removefrom quota table |
582 | | - * @param snapshotEntriesToRemove the entries to remove |
583 | | - */ |
584 | | - static List<Delete> createDeletesForExistingNamespaceSnapshotSizes( |
585 | | - Set<String> snapshotEntriesToRemove) { |
586 | | - List<Delete> deletes = new ArrayList<>(); |
587 | | - for (String snapshot : snapshotEntriesToRemove) { |
588 | | - Delete d = new Delete(getNamespaceRowKey(snapshot)); |
589 | | - d.addColumns(QUOTA_FAMILY_USAGE, QUOTA_SNAPSHOT_SIZE_QUALIFIER); |
590 | | - deletes.add(d); |
591 | | - } |
592 | | - return deletes; |
593 | | - } |
594 | | - |
595 | | - /** |
596 | | - * Returns a list of {@code Delete} to remove all namespace snapshot entries from quota table. |
597 | | - * @param connection connection to re-use |
598 | | - */ |
599 | | - static List<Delete> createDeletesForExistingNamespaceSnapshotSizes(Connection connection) |
600 | | - throws IOException { |
601 | | - return createDeletesForExistingSnapshotsFromScan(connection, |
602 | | - createScanForNamespaceSnapshotSizes()); |
603 | | - } |
604 | | - |
605 | | - /** |
606 | | - * Returns a list of {@code Delete} to remove all entries returned by the passed scanner. |
607 | | - * @param connection connection to re-use |
608 | | - * @param scan the scanner to use to generate the list of deletes |
609 | | - */ |
610 | | - static List<Delete> createDeletesForExistingSnapshotsFromScan(Connection connection, Scan scan) |
611 | | - throws IOException { |
612 | | - List<Delete> deletes = new ArrayList<>(); |
613 | | - try (Table quotaTable = connection.getTable(QUOTA_TABLE_NAME); |
614 | | - ResultScanner rs = quotaTable.getScanner(scan)) { |
615 | | - for (Result r : rs) { |
616 | | - CellScanner cs = r.cellScanner(); |
617 | | - while (cs.advance()) { |
618 | | - Cell c = cs.current(); |
619 | | - byte[] family = Bytes.copy(c.getFamilyArray(), c.getFamilyOffset(), c.getFamilyLength()); |
620 | | - byte[] qual = |
621 | | - Bytes.copy(c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()); |
622 | | - Delete d = new Delete(r.getRow()); |
623 | | - d.addColumns(family, qual); |
624 | | - deletes.add(d); |
625 | | - } |
626 | | - } |
627 | | - return deletes; |
628 | | - } |
629 | | - } |
630 | | - |
631 | 543 | /** |
632 | 544 | * Fetches the computed size of all snapshots against tables in a namespace for space quotas. |
633 | 545 | */ |
@@ -663,34 +575,6 @@ static long parseSnapshotSize(Cell c) throws InvalidProtocolBufferException { |
663 | 575 | return QuotaProtos.SpaceQuotaSnapshot.parseFrom(bs).getQuotaUsage(); |
664 | 576 | } |
665 | 577 |
|
666 | | - /** |
667 | | - * Returns a scanner for all existing namespace snapshot entries. |
668 | | - */ |
669 | | - static Scan createScanForNamespaceSnapshotSizes() { |
670 | | - return createScanForNamespaceSnapshotSizes(null); |
671 | | - } |
672 | | - |
673 | | - /** |
674 | | - * Returns a scanner for all namespace snapshot entries of the given namespace |
675 | | - * @param namespace name of the namespace whose snapshot entries are to be scanned |
676 | | - */ |
677 | | - static Scan createScanForNamespaceSnapshotSizes(String namespace) { |
678 | | - Scan s = new Scan(); |
679 | | - if (namespace == null || namespace.isEmpty()) { |
680 | | - // Read all namespaces, just look at the row prefix |
681 | | - s.setRowPrefixFilter(QUOTA_NAMESPACE_ROW_KEY_PREFIX); |
682 | | - } else { |
683 | | - // Fetch the exact row for the table |
684 | | - byte[] rowkey = getNamespaceRowKey(namespace); |
685 | | - // Fetch just this one row |
686 | | - s.withStartRow(rowkey).withStopRow(rowkey, true); |
687 | | - } |
688 | | - |
689 | | - // Just the usage family and only the snapshot size qualifiers |
690 | | - return s.addFamily(QUOTA_FAMILY_USAGE) |
691 | | - .setFilter(new ColumnPrefixFilter(QUOTA_SNAPSHOT_SIZE_QUALIFIER)); |
692 | | - } |
693 | | - |
694 | 578 | static Scan createScanForSpaceSnapshotSizes() { |
695 | 579 | return createScanForSpaceSnapshotSizes(null); |
696 | 580 | } |
@@ -737,46 +621,6 @@ public static Map<String,Long> getObservedSnapshotSizes(Connection conn) throws |
737 | 621 | } |
738 | 622 | } |
739 | 623 |
|
740 | | - /** |
741 | | - * Returns a multimap for all existing table snapshot entries. |
742 | | - * @param conn connection to re-use |
743 | | - */ |
744 | | - public static Multimap<TableName, String> getTableSnapshots(Connection conn) throws IOException { |
745 | | - try (Table quotaTable = conn.getTable(QUOTA_TABLE_NAME); |
746 | | - ResultScanner rs = quotaTable.getScanner(createScanForSpaceSnapshotSizes())) { |
747 | | - Multimap<TableName, String> snapshots = HashMultimap.create(); |
748 | | - for (Result r : rs) { |
749 | | - CellScanner cs = r.cellScanner(); |
750 | | - while (cs.advance()) { |
751 | | - Cell c = cs.current(); |
752 | | - |
753 | | - final String snapshot = extractSnapshotNameFromSizeCell(c); |
754 | | - snapshots.put(getTableFromRowKey(r.getRow()), snapshot); |
755 | | - } |
756 | | - } |
757 | | - return snapshots; |
758 | | - } |
759 | | - } |
760 | | - |
761 | | - /** |
762 | | - * Returns a set of the names of all namespaces containing snapshot entries. |
763 | | - * @param conn connection to re-use |
764 | | - */ |
765 | | - public static Set<String> getNamespaceSnapshots(Connection conn) throws IOException { |
766 | | - try (Table quotaTable = conn.getTable(QUOTA_TABLE_NAME); |
767 | | - ResultScanner rs = quotaTable.getScanner(createScanForNamespaceSnapshotSizes())) { |
768 | | - Set<String> snapshots = new HashSet<>(); |
769 | | - for (Result r : rs) { |
770 | | - CellScanner cs = r.cellScanner(); |
771 | | - while (cs.advance()) { |
772 | | - Cell c = cs.current(); |
773 | | - snapshots.add(getNamespaceFromRowKey(r.getRow())); |
774 | | - } |
775 | | - } |
776 | | - return snapshots; |
777 | | - } |
778 | | - } |
779 | | - |
780 | 624 | /** |
781 | 625 | * Returns the current space quota snapshot of the given {@code tableName} from |
782 | 626 | * {@code QuotaTableUtil.QUOTA_TABLE_NAME} or null if the no quota information is available for |
|
0 commit comments