Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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 @@ -60,6 +61,7 @@ public class SpaceQuotaRefresherChore extends ScheduledChore {

private final RegionServerSpaceQuotaManager manager;
private final Connection conn;
private boolean quotaTablePresent = false;

public SpaceQuotaRefresherChore(RegionServerSpaceQuotaManager manager, Connection conn) {
super(SpaceQuotaRefresherChore.class.getSimpleName(),
Expand All @@ -74,6 +76,12 @@ public SpaceQuotaRefresherChore(RegionServerSpaceQuotaManager manager, Connectio
@Override
protected void chore() {
try {
// check whether Quota table is present or not.
if (!quotaTablePresent && !checkQuotaTableExists()) {
LOG.info("Quota table not found, skipping quota manager cache refresh.");
quotaTablePresent = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this right? Setting it to true? Should it be false? The table was 'not found'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ohh yes..I should set it after the if condition...my bad :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review. Made the changes. :)

return;
}
if (LOG.isTraceEnabled()) {
LOG.trace("Reading current quota snapshots from hbase:quota.");
}
Expand Down Expand Up @@ -144,6 +152,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