Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3159,7 +3159,7 @@ public QuotaRetriever getQuotaRetriever(final QuotaFilter filter) throws IOExcep
@Override
public List<QuotaSettings> getQuota(QuotaFilter filter) throws IOException {
List<QuotaSettings> quotas = new ArrayList<>();
try (QuotaRetriever retriever = QuotaRetriever.open(conf, filter)) {
try (QuotaRetriever retriever = QuotaRetriever.open(connection, filter)) {
Iterator<QuotaSettings> iterator = retriever.iterator();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good to me.

However similar optimization can be done in master branch as well, below API is used multiple places
org.apache.hadoop.hbase.quotas.QuotaRetriever#open(org.apache.hadoop.conf.Configuration, org.apache.hadoop.hbase.quotas.QuotaFilter)

We can reuse the existing connection instead of creating new one always.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'm happy to expand the scope of this ticket.

while (iterator.hasNext()) {
quotas.add(iterator.next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,19 @@ public static QuotaRetriever open(final Configuration conf, final QuotaFilter fi
scanner.init(conf, scan);
return scanner;
}

/**
* Open a QuotaRetriever with the specified filter using an existing Connection
* @param conn Connection object to use.
* @param filter the QuotaFilter
* @return the QuotaRetriever
* @throws IOException if a remote or network exception occurs
*/
public static QuotaRetriever open(final Connection conn, final QuotaFilter filter)
throws IOException {
Scan scan = QuotaTableUtil.makeScan(filter);
QuotaRetriever scanner = new QuotaRetriever();
scanner.init(conn, scan);
return scanner;
}
}