Skip to content

Commit 53bffef

Browse files
committed
HBASE-22297 Fix TestRegionMergeTransitionOnCluster and TestSplitTransactionOnCluster
Signed-off-by: Michael Stack <stack@apache.org>
1 parent 14e0b71 commit 53bffef

2 files changed

Lines changed: 16 additions & 19 deletions

File tree

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.ArrayList;
2727
import java.util.List;
2828
import java.util.Objects;
29-
import java.util.concurrent.TimeUnit;
3029
import java.util.concurrent.atomic.AtomicBoolean;
3130
import org.apache.commons.lang3.RandomUtils;
3231
import org.apache.hadoop.conf.Configuration;
@@ -63,6 +62,7 @@
6362
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
6463
import org.apache.hadoop.hbase.util.Bytes;
6564
import org.apache.hadoop.hbase.util.FSUtils;
65+
import org.apache.hadoop.hbase.util.FutureUtils;
6666
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
6767
import org.apache.hadoop.hbase.util.Pair;
6868
import org.apache.hadoop.hbase.util.PairOfSameType;
@@ -312,7 +312,6 @@ public void testMerge() throws Exception {
312312
LOG.info("Starting " + name.getMethodName());
313313
final TableName tableName = TableName.valueOf(name.getMethodName());
314314
final Admin admin = TEST_UTIL.getAdmin();
315-
final int syncWaitTimeout = 10 * 60000; // 10min
316315

317316
try {
318317
// Create table and load data.
@@ -326,8 +325,8 @@ public void testMerge() throws Exception {
326325
am.offlineRegion(b);
327326
try {
328327
// Merge offline region. Region a is offline here
329-
admin.mergeRegionsAsync(a.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), false)
330-
.get(syncWaitTimeout, TimeUnit.MILLISECONDS);
328+
FutureUtils.get(
329+
admin.mergeRegionsAsync(a.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), false));
331330
fail("Offline regions should not be able to merge");
332331
} catch (DoNotRetryRegionException ie) {
333332
System.out.println(ie);
@@ -336,21 +335,21 @@ public void testMerge() throws Exception {
336335

337336
try {
338337
// Merge the same region: b and b.
339-
admin.mergeRegionsAsync(b.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), true);
338+
FutureUtils
339+
.get(admin.mergeRegionsAsync(b.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), true));
340340
fail("A region should not be able to merge with itself, even forcifully");
341341
} catch (IOException ie) {
342342
assertTrue("Exception should mention regions not online",
343-
StringUtils.stringifyException(ie).contains("region to itself")
344-
&& ie instanceof MergeRegionException);
343+
StringUtils.stringifyException(ie).contains("region to itself") &&
344+
ie instanceof MergeRegionException);
345345
}
346346

347347
try {
348348
// Merge unknown regions
349-
admin.mergeRegionsAsync(Bytes.toBytes("-f1"), Bytes.toBytes("-f2"), true);
349+
FutureUtils.get(admin.mergeRegionsAsync(Bytes.toBytes("-f1"), Bytes.toBytes("-f2"), true));
350350
fail("Unknown region could not be merged");
351351
} catch (IOException ie) {
352-
assertTrue("UnknownRegionException should be thrown",
353-
ie instanceof UnknownRegionException);
352+
assertTrue("UnknownRegionException should be thrown", ie instanceof UnknownRegionException);
354353
}
355354
table.close();
356355
} finally {

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Map;
3232
import java.util.Optional;
3333
import java.util.concurrent.CountDownLatch;
34+
import java.util.concurrent.ExecutionException;
3435
import java.util.concurrent.TimeUnit;
3536
import java.util.concurrent.atomic.AtomicBoolean;
3637
import org.apache.hadoop.conf.Configuration;
@@ -89,6 +90,7 @@
8990
import org.apache.hadoop.hbase.util.Bytes;
9091
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
9192
import org.apache.hadoop.hbase.util.FSUtils;
93+
import org.apache.hadoop.hbase.util.FutureUtils;
9294
import org.apache.hadoop.hbase.util.HBaseFsck;
9395
import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
9496
import org.apache.hadoop.hbase.util.RetryCounter;
@@ -328,7 +330,7 @@ public void testSplitRollbackOnRegionClosing() throws IOException, InterruptedEx
328330
// We don't roll back here anymore. Instead we fail-fast on construction of the
329331
// split transaction. Catch the exception instead.
330332
try {
331-
this.admin.splitRegionAsync(hri.getRegionName());
333+
FutureUtils.get(this.admin.splitRegionAsync(hri.getRegionName()));
332334
fail();
333335
} catch (DoNotRetryRegionException e) {
334336
// Expected
@@ -510,17 +512,13 @@ public void testSplitShouldNotThrowNPEEvenARegionHasEmptySplitFiles() throws Exc
510512
}
511513

512514
/**
513-
* Verifies HBASE-5806. Here the case is that splitting is completed but before the
514-
* CJ could remove the parent region the master is killed and restarted.
515-
* @throws IOException
516-
* @throws InterruptedException
517-
* @throws NodeExistsException
518-
* @throws KeeperException
515+
* Verifies HBASE-5806. Here the case is that splitting is completed but before the CJ could
516+
* remove the parent region the master is killed and restarted.
519517
*/
520518
@Test
521519
public void testMasterRestartAtRegionSplitPendingCatalogJanitor()
522520
throws IOException, InterruptedException, NodeExistsException,
523-
KeeperException, ServiceException {
521+
KeeperException, ServiceException, ExecutionException {
524522
final TableName tableName = TableName.valueOf(name.getMethodName());
525523

526524
// Create table then get the single region for our new table.
@@ -541,7 +539,7 @@ public void testMasterRestartAtRegionSplitPendingCatalogJanitor()
541539
HRegionServer server = cluster.getRegionServer(tableRegionIndex);
542540
printOutRegions(server, "Initial regions: ");
543541
// Call split.
544-
this.admin.splitRegionAsync(hri.getRegionName());
542+
this.admin.splitRegionAsync(hri.getRegionName()).get();
545543
List<HRegion> daughters = checkAndGetDaughters(tableName);
546544

547545
// Before cleanup, get a new master.

0 commit comments

Comments
 (0)