Revert "HBASE-22013 SpaceQuotas - getNumRegions() returning wrong number of regions due to region replicas"
This reverts commit 7af5b30eca
.
This commit is contained in:
parent
84ee378df1
commit
b329bf0a57
|
@ -32,7 +32,6 @@ import org.apache.hadoop.hbase.Stoppable;
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.client.Connection;
|
import org.apache.hadoop.hbase.client.Connection;
|
||||||
import org.apache.hadoop.hbase.client.RegionInfo;
|
import org.apache.hadoop.hbase.client.RegionInfo;
|
||||||
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
|
|
||||||
import org.apache.hadoop.hbase.client.Scan;
|
import org.apache.hadoop.hbase.client.Scan;
|
||||||
import org.apache.hadoop.hbase.master.HMaster;
|
import org.apache.hadoop.hbase.master.HMaster;
|
||||||
import org.apache.hadoop.hbase.master.MetricsMaster;
|
import org.apache.hadoop.hbase.master.MetricsMaster;
|
||||||
|
@ -765,9 +764,6 @@ public class QuotaObserverChore extends ScheduledChore {
|
||||||
List<RegionInfo> regions = this.conn.getAdmin().getRegions(table);
|
List<RegionInfo> regions = this.conn.getAdmin().getRegions(table);
|
||||||
if (regions == null) {
|
if (regions == null) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
|
||||||
// Filter the region replicas if any and return the original number of regions for a table.
|
|
||||||
RegionReplicaUtil.removeNonDefaultRegions(regions);
|
|
||||||
}
|
}
|
||||||
return regions.size();
|
return regions.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,16 +306,15 @@ public class SpaceQuotaHelperForTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
TableName createTableWithRegions(Admin admin, int numRegions) throws Exception {
|
TableName createTableWithRegions(Admin admin, int numRegions) throws Exception {
|
||||||
return createTableWithRegions(admin, NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, numRegions,
|
return createTableWithRegions(
|
||||||
0);
|
testUtil.getAdmin(), NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, numRegions);
|
||||||
}
|
}
|
||||||
|
|
||||||
TableName createTableWithRegions(String namespace, int numRegions) throws Exception {
|
TableName createTableWithRegions(String namespace, int numRegions) throws Exception {
|
||||||
return createTableWithRegions(testUtil.getAdmin(), namespace, numRegions, 0);
|
return createTableWithRegions(testUtil.getAdmin(), namespace, numRegions);
|
||||||
}
|
}
|
||||||
|
|
||||||
TableName createTableWithRegions(Admin admin, String namespace, int numRegions,
|
TableName createTableWithRegions(Admin admin, String namespace, int numRegions) throws Exception {
|
||||||
int numberOfReplicas) throws Exception {
|
|
||||||
final TableName tn = getNextTableName(namespace);
|
final TableName tn = getNextTableName(namespace);
|
||||||
|
|
||||||
// Delete the old table
|
// Delete the old table
|
||||||
|
@ -325,14 +324,8 @@ public class SpaceQuotaHelperForTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the table
|
// Create the table
|
||||||
TableDescriptor tableDesc;
|
TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(tn)
|
||||||
if (numberOfReplicas > 0) {
|
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(F1)).build();
|
||||||
tableDesc = TableDescriptorBuilder.newBuilder(tn).setRegionReplication(numberOfReplicas)
|
|
||||||
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(F1)).build();
|
|
||||||
} else {
|
|
||||||
tableDesc = TableDescriptorBuilder.newBuilder(tn)
|
|
||||||
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(F1)).build();
|
|
||||||
}
|
|
||||||
if (numRegions == 1) {
|
if (numRegions == 1) {
|
||||||
admin.createTable(tableDesc);
|
admin.createTable(tableDesc);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
||||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
|
||||||
import org.apache.hadoop.hbase.TableName;
|
import org.apache.hadoop.hbase.TableName;
|
||||||
import org.apache.hadoop.hbase.TableNotEnabledException;
|
import org.apache.hadoop.hbase.TableNotEnabledException;
|
||||||
import org.apache.hadoop.hbase.client.Admin;
|
import org.apache.hadoop.hbase.client.Admin;
|
||||||
|
@ -486,52 +485,6 @@ public class TestSpaceQuotas {
|
||||||
setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.DISABLE, 2L);
|
setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.DISABLE, 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetQuotaWithRegionReplicaSingleRegion() throws Exception {
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.NO_INSERTS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.NO_WRITES);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.DISABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetQuotaWithRegionReplicaMultipleRegion() throws Exception {
|
|
||||||
setQuotaAndVerfiyForRegionReplication(5, 3, SpaceViolationPolicy.NO_INSERTS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(6, 3, SpaceViolationPolicy.NO_WRITES);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(6, 3, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(6, 3, SpaceViolationPolicy.DISABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetQuotaWithSingleRegionZeroRegionReplica() throws Exception {
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.NO_INSERTS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.NO_WRITES);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.DISABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetQuotaWithMultipleRegionZeroRegionReplicas() throws Exception {
|
|
||||||
setQuotaAndVerfiyForRegionReplication(5, 0, SpaceViolationPolicy.NO_INSERTS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(6, 0, SpaceViolationPolicy.NO_WRITES);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(6, 0, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
|
|
||||||
setQuotaAndVerfiyForRegionReplication(6, 0, SpaceViolationPolicy.DISABLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setQuotaAndVerfiyForRegionReplication(int region, int replicatedRegion,
|
|
||||||
SpaceViolationPolicy policy) throws Exception {
|
|
||||||
TableName tn = helper.createTableWithRegions(TEST_UTIL.getAdmin(),
|
|
||||||
NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, region, replicatedRegion);
|
|
||||||
setQuotaLimit(tn, policy, 5L);
|
|
||||||
helper.writeData(tn, 5L * SpaceQuotaHelperForTests.ONE_MEGABYTE);
|
|
||||||
Put p = new Put(Bytes.toBytes("to_reject"));
|
|
||||||
p.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"),
|
|
||||||
Bytes.toBytes("reject"));
|
|
||||||
// Adding a sleep for 5 sec, so all the chores run and to void flakiness of the test.
|
|
||||||
Thread.sleep(5000);
|
|
||||||
verifyViolation(policy, tn, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQuotaAndViolateNextSwitchPoliciesAndValidate(SpaceViolationPolicy policy1,
|
public void setQuotaAndViolateNextSwitchPoliciesAndValidate(SpaceViolationPolicy policy1,
|
||||||
SpaceViolationPolicy policy2) throws Exception {
|
SpaceViolationPolicy policy2) throws Exception {
|
||||||
Put put = new Put(Bytes.toBytes("to_reject"));
|
Put put = new Put(Bytes.toBytes("to_reject"));
|
||||||
|
|
Loading…
Reference in New Issue