Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
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 @@ -23,6 +23,7 @@
import java.util.concurrent.TimeUnit;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.ScheduledChore;
import org.apache.hadoop.hbase.TableName;
import org.apache.yetus.audience.InterfaceAudience;
Expand Down Expand Up @@ -74,6 +75,11 @@ public SpaceQuotaRefresherChore(RegionServerSpaceQuotaManager manager, Connectio
@Override
protected void chore() {
try {
// check whether Quota table is present or not.
if (!checkQuotaTableExists()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will result in a META read. This can be done only once in the life time of an RS right if we found Quota table exists? A Boolean state can help here.
Why do you think we should do a WARN log? It can be just INFO at max IMO.

Copy link
Contributor Author

@shardul-cr7 shardul-cr7 Sep 6, 2019

Choose a reason for hiding this comment

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

Hi @anoopsjohn , Thanks for the review. Added a boolean state to avoid the Meta read again and added info level log.

LOG.warn("Quota table not found, skipping quota manager cache refresh.");
return;
}
if (LOG.isTraceEnabled()) {
LOG.trace("Reading current quota snapshots from hbase:quota.");
}
Expand Down Expand Up @@ -144,6 +150,16 @@ protected void chore() {
}
}

/**
* Checks if hbase:quota exists in hbase:meta
*
* @return true if hbase:quota table is in meta, else returns false.
* @throws IOException throws IOException
*/
boolean checkQuotaTableExists() throws IOException {
return MetaTableAccessor.tableExists(getConnection(), QuotaUtil.QUOTA_TABLE_NAME);
}

/**
* Checks if the given <code>snapshot</code> is in violation, allowing the snapshot to be null.
* If the snapshot is null, this is interpreted as no snapshot which implies not in violation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void setup() throws IOException {
chore = mock(SpaceQuotaRefresherChore.class);
when(chore.getConnection()).thenReturn(conn);
when(chore.getManager()).thenReturn(manager);
when(chore.checkQuotaTableExists()).thenReturn(true);
doCallRealMethod().when(chore).chore();
when(chore.isInViolation(any())).thenCallRealMethod();
doCallRealMethod().when(chore).extractQuotaSnapshot(any(), any());
Expand Down