Skip to content

Commit b329bf0

Browse files
committed
Revert "HBASE-22013 SpaceQuotas - getNumRegions() returning wrong number of regions due to region replicas"
This reverts commit 7af5b30.
1 parent 84ee378 commit b329bf0

File tree

3 files changed

+6
-64
lines changed

3 files changed

+6
-64
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/quotas/QuotaObserverChore.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.apache.hadoop.hbase.TableName;
3333
import org.apache.hadoop.hbase.client.Connection;
3434
import org.apache.hadoop.hbase.client.RegionInfo;
35-
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
3635
import org.apache.hadoop.hbase.client.Scan;
3736
import org.apache.hadoop.hbase.master.HMaster;
3837
import org.apache.hadoop.hbase.master.MetricsMaster;
@@ -765,9 +764,6 @@ int getNumRegions(TableName table) throws IOException {
765764
List<RegionInfo> regions = this.conn.getAdmin().getRegions(table);
766765
if (regions == null) {
767766
return 0;
768-
} else {
769-
// Filter the region replicas if any and return the original number of regions for a table.
770-
RegionReplicaUtil.removeNonDefaultRegions(regions);
771767
}
772768
return regions.size();
773769
}

hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/SpaceQuotaHelperForTests.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,15 @@ TableName createTableWithRegions(int numRegions) throws Exception {
306306
}
307307

308308
TableName createTableWithRegions(Admin admin, int numRegions) throws Exception {
309-
return createTableWithRegions(admin, NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, numRegions,
310-
0);
309+
return createTableWithRegions(
310+
testUtil.getAdmin(), NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, numRegions);
311311
}
312312

313313
TableName createTableWithRegions(String namespace, int numRegions) throws Exception {
314-
return createTableWithRegions(testUtil.getAdmin(), namespace, numRegions, 0);
314+
return createTableWithRegions(testUtil.getAdmin(), namespace, numRegions);
315315
}
316316

317-
TableName createTableWithRegions(Admin admin, String namespace, int numRegions,
318-
int numberOfReplicas) throws Exception {
317+
TableName createTableWithRegions(Admin admin, String namespace, int numRegions) throws Exception {
319318
final TableName tn = getNextTableName(namespace);
320319

321320
// Delete the old table
@@ -325,14 +324,8 @@ TableName createTableWithRegions(Admin admin, String namespace, int numRegions,
325324
}
326325

327326
// Create the table
328-
TableDescriptor tableDesc;
329-
if (numberOfReplicas > 0) {
330-
tableDesc = TableDescriptorBuilder.newBuilder(tn).setRegionReplication(numberOfReplicas)
331-
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(F1)).build();
332-
} else {
333-
tableDesc = TableDescriptorBuilder.newBuilder(tn)
334-
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(F1)).build();
335-
}
327+
TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(tn)
328+
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(F1)).build();
336329
if (numRegions == 1) {
337330
admin.createTable(tableDesc);
338331
} else {

hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestSpaceQuotas.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.apache.hadoop.hbase.DoNotRetryIOException;
3939
import org.apache.hadoop.hbase.HBaseClassTestRule;
4040
import org.apache.hadoop.hbase.HBaseTestingUtility;
41-
import org.apache.hadoop.hbase.NamespaceDescriptor;
4241
import org.apache.hadoop.hbase.TableName;
4342
import org.apache.hadoop.hbase.TableNotEnabledException;
4443
import org.apache.hadoop.hbase.client.Admin;
@@ -486,52 +485,6 @@ public void testSetQuotaOnNonExistingTableWithDisable() throws Exception {
486485
setQuotaLimit(NON_EXISTENT_TABLE, SpaceViolationPolicy.DISABLE, 2L);
487486
}
488487

489-
@Test
490-
public void testSetQuotaWithRegionReplicaSingleRegion() throws Exception {
491-
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.NO_INSERTS);
492-
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.NO_WRITES);
493-
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
494-
setQuotaAndVerfiyForRegionReplication(1, 2, SpaceViolationPolicy.DISABLE);
495-
}
496-
497-
@Test
498-
public void testSetQuotaWithRegionReplicaMultipleRegion() throws Exception {
499-
setQuotaAndVerfiyForRegionReplication(5, 3, SpaceViolationPolicy.NO_INSERTS);
500-
setQuotaAndVerfiyForRegionReplication(6, 3, SpaceViolationPolicy.NO_WRITES);
501-
setQuotaAndVerfiyForRegionReplication(6, 3, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
502-
setQuotaAndVerfiyForRegionReplication(6, 3, SpaceViolationPolicy.DISABLE);
503-
}
504-
505-
@Test
506-
public void testSetQuotaWithSingleRegionZeroRegionReplica() throws Exception {
507-
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.NO_INSERTS);
508-
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.NO_WRITES);
509-
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
510-
setQuotaAndVerfiyForRegionReplication(1, 0, SpaceViolationPolicy.DISABLE);
511-
}
512-
513-
@Test
514-
public void testSetQuotaWithMultipleRegionZeroRegionReplicas() throws Exception {
515-
setQuotaAndVerfiyForRegionReplication(5, 0, SpaceViolationPolicy.NO_INSERTS);
516-
setQuotaAndVerfiyForRegionReplication(6, 0, SpaceViolationPolicy.NO_WRITES);
517-
setQuotaAndVerfiyForRegionReplication(6, 0, SpaceViolationPolicy.NO_WRITES_COMPACTIONS);
518-
setQuotaAndVerfiyForRegionReplication(6, 0, SpaceViolationPolicy.DISABLE);
519-
}
520-
521-
private void setQuotaAndVerfiyForRegionReplication(int region, int replicatedRegion,
522-
SpaceViolationPolicy policy) throws Exception {
523-
TableName tn = helper.createTableWithRegions(TEST_UTIL.getAdmin(),
524-
NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, region, replicatedRegion);
525-
setQuotaLimit(tn, policy, 5L);
526-
helper.writeData(tn, 5L * SpaceQuotaHelperForTests.ONE_MEGABYTE);
527-
Put p = new Put(Bytes.toBytes("to_reject"));
528-
p.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"),
529-
Bytes.toBytes("reject"));
530-
// Adding a sleep for 5 sec, so all the chores run and to void flakiness of the test.
531-
Thread.sleep(5000);
532-
verifyViolation(policy, tn, p);
533-
}
534-
535488
public void setQuotaAndViolateNextSwitchPoliciesAndValidate(SpaceViolationPolicy policy1,
536489
SpaceViolationPolicy policy2) throws Exception {
537490
Put put = new Put(Bytes.toBytes("to_reject"));

0 commit comments

Comments
 (0)