Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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,13 @@ public SpaceQuotaRefresherChore(RegionServerSpaceQuotaManager manager, Connectio
@Override
protected void chore() {
try {
// check whether quotaTable is present or not.
if (!quotaTablePresent && !checkQuotaTableExists()) {
LOG.info("Quota table not found, skipping quota manager cache refresh.");
return;
}
// since quotaTable is present so setting the flag as true.
quotaTablePresent = true;
Copy link
Contributor

@pankaj72981 pankaj72981 Sep 21, 2019

Choose a reason for hiding this comment

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

Better we move flag setting inside checkQuotaTableExists().
Sorry for the late review.

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