HBASE-17063 Cleanup TestHRegion : remove duplicate variables for method name and two unused params in initRegion

- Replaces local tablename and method names in individual tests with those initialized in setup() function
- Remove unused params from initHRegion().

Change-Id: Id0fe25890c833f7cc9b91277d5015480a007d788
This commit is contained in:
Apekshit Sharma 2016-11-09 20:03:19 -08:00
parent 12eec5bc5d
commit 62e3b1ece6
2 changed files with 62 additions and 148 deletions

View File

@ -197,7 +197,8 @@ public class TestHRegion {
// Do not spin up clusters in here. If you need to spin up a cluster, do it // Do not spin up clusters in here. If you need to spin up a cluster, do it
// over in TestHRegionOnCluster. // over in TestHRegionOnCluster.
private static final Log LOG = LogFactory.getLog(TestHRegion.class); private static final Log LOG = LogFactory.getLog(TestHRegion.class);
@Rule public TestName name = new TestName(); @Rule
public TestName name = new TestName();
@ClassRule @ClassRule
public static final TestRule timeout = public static final TestRule timeout =
CategoryBasedTimeout.forClass(TestHRegion.class); CategoryBasedTimeout.forClass(TestHRegion.class);
@ -234,7 +235,7 @@ public class TestHRegion {
CONF = TEST_UTIL.getConfiguration(); CONF = TEST_UTIL.getConfiguration();
dir = TEST_UTIL.getDataTestDir("TestHRegion").toString(); dir = TEST_UTIL.getDataTestDir("TestHRegion").toString();
method = name.getMethodName(); method = name.getMethodName();
tableName = TableName.valueOf(name.getMethodName()); tableName = TableName.valueOf(method);
} }
@After @After
@ -244,17 +245,13 @@ public class TestHRegion {
TEST_UTIL.cleanupTestDir(); TEST_UTIL.cleanupTestDir();
} }
String getName() {
return name.getMethodName();
}
/** /**
* Test that I can use the max flushed sequence id after the close. * Test that I can use the max flushed sequence id after the close.
* @throws IOException * @throws IOException
*/ */
@Test @Test
public void testSequenceId() throws IOException { public void testSequenceId() throws IOException {
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, COLUMN_FAMILY_BYTES); HRegion region = initHRegion(tableName, method, CONF, COLUMN_FAMILY_BYTES);
assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId()); assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId());
// Weird. This returns 0 if no store files or no edits. Afraid to change it. // Weird. This returns 0 if no store files or no edits. Afraid to change it.
assertEquals(0, (long)region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); assertEquals(0, (long)region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES));
@ -262,8 +259,8 @@ public class TestHRegion {
assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId()); assertEquals(HConstants.NO_SEQNUM, region.getMaxFlushedSeqId());
assertEquals(0, (long)region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES)); assertEquals(0, (long)region.getMaxStoreSeqId().get(COLUMN_FAMILY_BYTES));
// Open region again. // Open region again.
region = initHRegion(tableName, name.getMethodName(), CONF, COLUMN_FAMILY_BYTES); region = initHRegion(tableName, method, CONF, COLUMN_FAMILY_BYTES);
byte [] value = Bytes.toBytes(name.getMethodName()); byte [] value = Bytes.toBytes(method);
// Make a random put against our cf. // Make a random put against our cf.
Put put = new Put(value); Put put = new Put(value);
put.addColumn(COLUMN_FAMILY_BYTES, null, value); put.addColumn(COLUMN_FAMILY_BYTES, null, value);
@ -289,10 +286,10 @@ public class TestHRegion {
*/ */
@Test @Test
public void testCloseCarryingSnapshot() throws IOException { public void testCloseCarryingSnapshot() throws IOException {
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, COLUMN_FAMILY_BYTES); HRegion region = initHRegion(tableName, method, CONF, COLUMN_FAMILY_BYTES);
Store store = region.getStore(COLUMN_FAMILY_BYTES); Store store = region.getStore(COLUMN_FAMILY_BYTES);
// Get some random bytes. // Get some random bytes.
byte [] value = Bytes.toBytes(name.getMethodName()); byte [] value = Bytes.toBytes(method);
// Make a random put against our cf. // Make a random put against our cf.
Put put = new Put(value); Put put = new Put(value);
put.addColumn(COLUMN_FAMILY_BYTES, null, value); put.addColumn(COLUMN_FAMILY_BYTES, null, value);
@ -336,12 +333,12 @@ public class TestHRegion {
FileSystem fs = FileSystem.get(CONF); FileSystem fs = FileSystem.get(CONF);
Path rootDir = new Path(dir + "testMemstoreSnapshotSize"); Path rootDir = new Path(dir + "testMemstoreSnapshotSize");
MyFaultyFSLog faultyLog = new MyFaultyFSLog(fs, rootDir, "testMemstoreSnapshotSize", CONF); MyFaultyFSLog faultyLog = new MyFaultyFSLog(fs, rootDir, "testMemstoreSnapshotSize", CONF);
HRegion region = initHRegion(tableName, null, null, name.getMethodName(), HRegion region = initHRegion(tableName, null, null, false, Durability.SYNC_WAL, faultyLog,
CONF, false, Durability.SYNC_WAL, faultyLog, COLUMN_FAMILY_BYTES); COLUMN_FAMILY_BYTES);
Store store = region.getStore(COLUMN_FAMILY_BYTES); Store store = region.getStore(COLUMN_FAMILY_BYTES);
// Get some random bytes. // Get some random bytes.
byte [] value = Bytes.toBytes(name.getMethodName()); byte [] value = Bytes.toBytes(method);
faultyLog.setStoreFlushCtx(store.createFlushContext(12345)); faultyLog.setStoreFlushCtx(store.createFlushContext(12345));
Put put = new Put(value); Put put = new Put(value);
@ -386,13 +383,13 @@ public class TestHRegion {
FileSystem fs = FileSystem.get(CONF); FileSystem fs = FileSystem.get(CONF);
Path rootDir = new Path(dir + "testMemstoreSizeWithFlushCanceling"); Path rootDir = new Path(dir + "testMemstoreSizeWithFlushCanceling");
FSHLog hLog = new FSHLog(fs, rootDir, "testMemstoreSizeWithFlushCanceling", CONF); FSHLog hLog = new FSHLog(fs, rootDir, "testMemstoreSizeWithFlushCanceling", CONF);
HRegion region = initHRegion(tableName, null, null, name.getMethodName(), HRegion region = initHRegion(tableName, null, null, false, Durability.SYNC_WAL, hLog,
CONF, false, Durability.SYNC_WAL, hLog, COLUMN_FAMILY_BYTES); COLUMN_FAMILY_BYTES);
Store store = region.getStore(COLUMN_FAMILY_BYTES); Store store = region.getStore(COLUMN_FAMILY_BYTES);
assertEquals(0, region.getMemstoreSize()); assertEquals(0, region.getMemstoreSize());
// Put some value and make sure flush could be completed normally // Put some value and make sure flush could be completed normally
byte [] value = Bytes.toBytes(name.getMethodName()); byte [] value = Bytes.toBytes(method);
Put put = new Put(value); Put put = new Put(value);
put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("abc"), value); put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("abc"), value);
region.put(put); region.put(put);
@ -428,13 +425,13 @@ public class TestHRegion {
FileSystem fs = FileSystem.get(CONF); FileSystem fs = FileSystem.get(CONF);
Path rootDir = new Path(dir + testName); Path rootDir = new Path(dir + testName);
FSHLog hLog = new FSHLog(fs, rootDir, testName, CONF); FSHLog hLog = new FSHLog(fs, rootDir, testName, CONF);
HRegion region = initHRegion(tableName, null, null, name.getMethodName(), HRegion region = initHRegion(tableName, null, null, false, Durability.SYNC_WAL, hLog,
CONF, false, Durability.SYNC_WAL, hLog, COLUMN_FAMILY_BYTES); COLUMN_FAMILY_BYTES);
Store store = region.getStore(COLUMN_FAMILY_BYTES); Store store = region.getStore(COLUMN_FAMILY_BYTES);
assertEquals(0, region.getMemstoreSize()); assertEquals(0, region.getMemstoreSize());
// Put one value // Put one value
byte [] value = Bytes.toBytes(name.getMethodName()); byte [] value = Bytes.toBytes(method);
Put put = new Put(value); Put put = new Put(value);
put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("abc"), value); put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("abc"), value);
region.put(put); region.put(put);
@ -480,12 +477,11 @@ public class TestHRegion {
@Test @Test
public void testFlushSizeAccounting() throws Exception { public void testFlushSizeAccounting() throws Exception {
final Configuration conf = HBaseConfiguration.create(CONF); final Configuration conf = HBaseConfiguration.create(CONF);
final String callingMethod = name.getMethodName(); final WAL wal = createWALCompatibleWithFaultyFileSystem(method, conf, tableName);
final WAL wal = createWALCompatibleWithFaultyFileSystem(callingMethod, conf, tableName);
// Only retry once. // Only retry once.
conf.setInt("hbase.hstore.flush.retries.number", 1); conf.setInt("hbase.hstore.flush.retries.number", 1);
final User user = final User user =
User.createUserForTesting(conf, this.name.getMethodName(), new String[]{"foo"}); User.createUserForTesting(conf, method, new String[]{"foo"});
// Inject our faulty LocalFileSystem // Inject our faulty LocalFileSystem
conf.setClass("fs.file.impl", FaultyFileSystem.class, FileSystem.class); conf.setClass("fs.file.impl", FaultyFileSystem.class, FileSystem.class);
user.runAs(new PrivilegedExceptionAction<Object>() { user.runAs(new PrivilegedExceptionAction<Object>() {
@ -498,8 +494,8 @@ public class TestHRegion {
HRegion region = null; HRegion region = null;
try { try {
// Initialize region // Initialize region
region = initHRegion(tableName, null, null, callingMethod, conf, false, region = initHRegion(tableName, null, null, false, Durability.SYNC_WAL, wal,
Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES); COLUMN_FAMILY_BYTES);
long size = region.getMemstoreSize(); long size = region.getMemstoreSize();
Assert.assertEquals(0, size); Assert.assertEquals(0, size);
// Put one item into memstore. Measure the size of one item in memstore. // Put one item into memstore. Measure the size of one item in memstore.
@ -546,12 +542,11 @@ public class TestHRegion {
@Test @Test
public void testCloseWithFailingFlush() throws Exception { public void testCloseWithFailingFlush() throws Exception {
final Configuration conf = HBaseConfiguration.create(CONF); final Configuration conf = HBaseConfiguration.create(CONF);
final String callingMethod = name.getMethodName(); final WAL wal = createWALCompatibleWithFaultyFileSystem(method, conf, tableName);
final WAL wal = createWALCompatibleWithFaultyFileSystem(callingMethod, conf, tableName);
// Only retry once. // Only retry once.
conf.setInt("hbase.hstore.flush.retries.number", 1); conf.setInt("hbase.hstore.flush.retries.number", 1);
final User user = final User user =
User.createUserForTesting(conf, this.name.getMethodName(), new String[]{"foo"}); User.createUserForTesting(conf, this.method, new String[]{"foo"});
// Inject our faulty LocalFileSystem // Inject our faulty LocalFileSystem
conf.setClass("fs.file.impl", FaultyFileSystem.class, FileSystem.class); conf.setClass("fs.file.impl", FaultyFileSystem.class, FileSystem.class);
user.runAs(new PrivilegedExceptionAction<Object>() { user.runAs(new PrivilegedExceptionAction<Object>() {
@ -564,7 +559,7 @@ public class TestHRegion {
HRegion region = null; HRegion region = null;
try { try {
// Initialize region // Initialize region
region = initHRegion(tableName, null, null, callingMethod, conf, false, region = initHRegion(tableName, null, null, false,
Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES); Durability.SYNC_WAL, wal, COLUMN_FAMILY_BYTES);
long size = region.getMemstoreSize(); long size = region.getMemstoreSize();
Assert.assertEquals(0, size); Assert.assertEquals(0, size);
@ -678,8 +673,6 @@ public class TestHRegion {
@Test @Test
public void testSkipRecoveredEditsReplay() throws Exception { public void testSkipRecoveredEditsReplay() throws Exception {
String method = "testSkipRecoveredEditsReplay";
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, CONF, family); this.region = initHRegion(tableName, method, CONF, family);
final WALFactory wals = new WALFactory(CONF, null, method); final WALFactory wals = new WALFactory(CONF, null, method);
@ -731,8 +724,6 @@ public class TestHRegion {
@Test @Test
public void testSkipRecoveredEditsReplaySomeIgnored() throws Exception { public void testSkipRecoveredEditsReplaySomeIgnored() throws Exception {
String method = "testSkipRecoveredEditsReplaySomeIgnored";
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, CONF, family); this.region = initHRegion(tableName, method, CONF, family);
final WALFactory wals = new WALFactory(CONF, null, method); final WALFactory wals = new WALFactory(CONF, null, method);
@ -821,8 +812,6 @@ public class TestHRegion {
@Test @Test
public void testSkipRecoveredEditsReplayTheLastFileIgnored() throws Exception { public void testSkipRecoveredEditsReplayTheLastFileIgnored() throws Exception {
String method = "testSkipRecoveredEditsReplayTheLastFileIgnored";
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, CONF, family); this.region = initHRegion(tableName, method, CONF, family);
final WALFactory wals = new WALFactory(CONF, null, method); final WALFactory wals = new WALFactory(CONF, null, method);
@ -889,9 +878,8 @@ public class TestHRegion {
testRecoveredEditsReplayCompaction(false); testRecoveredEditsReplayCompaction(false);
testRecoveredEditsReplayCompaction(true); testRecoveredEditsReplayCompaction(true);
} }
public void testRecoveredEditsReplayCompaction(boolean mismatchedRegionName) throws Exception { public void testRecoveredEditsReplayCompaction(boolean mismatchedRegionName) throws Exception {
String method = name.getMethodName();
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, CONF, family); this.region = initHRegion(tableName, method, CONF, family);
final WALFactory wals = new WALFactory(CONF, null, method); final WALFactory wals = new WALFactory(CONF, null, method);
@ -1000,8 +988,6 @@ public class TestHRegion {
@Test @Test
public void testFlushMarkers() throws Exception { public void testFlushMarkers() throws Exception {
// tests that flush markers are written to WAL and handled at recovered edits // tests that flush markers are written to WAL and handled at recovered edits
String method = name.getMethodName();
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
Path logDir = TEST_UTIL.getDataTestDirOnTestFS(method + ".log"); Path logDir = TEST_UTIL.getDataTestDirOnTestFS(method + ".log");
final Configuration walConf = new Configuration(TEST_UTIL.getConfiguration()); final Configuration walConf = new Configuration(TEST_UTIL.getConfiguration());
@ -1010,7 +996,7 @@ public class TestHRegion {
final WAL wal = wals.getWAL(tableName.getName(), tableName.getNamespace()); final WAL wal = wals.getWAL(tableName.getName(), tableName.getNamespace());
this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW, this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW,
HConstants.EMPTY_END_ROW, method, CONF, false, Durability.USE_DEFAULT, wal, family); HConstants.EMPTY_END_ROW, false, Durability.USE_DEFAULT, wal, family);
try { try {
Path regiondir = region.getRegionFileSystem().getRegionDir(); Path regiondir = region.getRegionFileSystem().getRegionDir();
FileSystem fs = region.getRegionFileSystem().getFileSystem(); FileSystem fs = region.getRegionFileSystem().getFileSystem();
@ -1154,8 +1140,6 @@ public class TestHRegion {
@Test @Test
public void testFlushMarkersWALFail() throws Exception { public void testFlushMarkersWALFail() throws Exception {
// test the cases where the WAL append for flush markers fail. // test the cases where the WAL append for flush markers fail.
String method = name.getMethodName();
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
// spy an actual WAL implementation to throw exception (was not able to mock) // spy an actual WAL implementation to throw exception (was not able to mock)
@ -1211,9 +1195,9 @@ public class TestHRegion {
} }
FailAppendFlushMarkerWAL wal = FailAppendFlushMarkerWAL wal =
new FailAppendFlushMarkerWAL(FileSystem.get(walConf), FSUtils.getRootDir(walConf), new FailAppendFlushMarkerWAL(FileSystem.get(walConf), FSUtils.getRootDir(walConf),
getName(), walConf); method, walConf);
this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW, this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW,
HConstants.EMPTY_END_ROW, method, CONF, false, Durability.USE_DEFAULT, wal, family); HConstants.EMPTY_END_ROW, false, Durability.USE_DEFAULT, wal, family);
try { try {
int i = 0; int i = 0;
Put put = new Put(Bytes.toBytes(i)); Put put = new Put(Bytes.toBytes(i));
@ -1242,10 +1226,10 @@ public class TestHRegion {
// 2. Test case where START_FLUSH succeeds but COMMIT_FLUSH will throw exception // 2. Test case where START_FLUSH succeeds but COMMIT_FLUSH will throw exception
wal.flushActions = new FlushAction [] {FlushAction.COMMIT_FLUSH}; wal.flushActions = new FlushAction [] {FlushAction.COMMIT_FLUSH};
wal = new FailAppendFlushMarkerWAL(FileSystem.get(walConf), FSUtils.getRootDir(walConf), wal = new FailAppendFlushMarkerWAL(FileSystem.get(walConf), FSUtils.getRootDir(walConf),
getName(), walConf); method, walConf);
this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW, this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW,
HConstants.EMPTY_END_ROW, method, CONF, false, Durability.USE_DEFAULT, wal, family); HConstants.EMPTY_END_ROW, false, Durability.USE_DEFAULT, wal, family);
region.put(put); region.put(put);
// 3. Test case where ABORT_FLUSH will throw exception. // 3. Test case where ABORT_FLUSH will throw exception.
@ -1271,13 +1255,11 @@ public class TestHRegion {
@Test @Test
public void testGetWhileRegionClose() throws IOException { public void testGetWhileRegionClose() throws IOException {
TableName tableName = TableName.valueOf(name.getMethodName());
Configuration hc = initSplit(); Configuration hc = initSplit();
int numRows = 100; int numRows = 100;
byte[][] families = { fam1, fam2, fam3 }; byte[][] families = { fam1, fam2, fam3 };
// Setting up region // Setting up region
String method = name.getMethodName();
this.region = initHRegion(tableName, method, hc, families); this.region = initHRegion(tableName, method, hc, families);
try { try {
// Put data in region // Put data in region
@ -1366,7 +1348,7 @@ public class TestHRegion {
TableName TABLE = TableName.valueOf("testWeirdCacheBehaviour"); TableName TABLE = TableName.valueOf("testWeirdCacheBehaviour");
byte[][] FAMILIES = new byte[][] { Bytes.toBytes("trans-blob"), Bytes.toBytes("trans-type"), byte[][] FAMILIES = new byte[][] { Bytes.toBytes("trans-blob"), Bytes.toBytes("trans-type"),
Bytes.toBytes("trans-date"), Bytes.toBytes("trans-tags"), Bytes.toBytes("trans-group") }; Bytes.toBytes("trans-date"), Bytes.toBytes("trans-tags"), Bytes.toBytes("trans-group") };
this.region = initHRegion(TABLE, getName(), CONF, FAMILIES); this.region = initHRegion(TABLE, method, CONF, FAMILIES);
try { try {
String value = "this is the value"; String value = "this is the value";
String value2 = "this is some other value"; String value2 = "this is some other value";
@ -1407,7 +1389,7 @@ public class TestHRegion {
@Test @Test
public void testAppendWithReadOnlyTable() throws Exception { public void testAppendWithReadOnlyTable() throws Exception {
TableName TABLE = TableName.valueOf("readOnlyTable"); TableName TABLE = TableName.valueOf("readOnlyTable");
this.region = initHRegion(TABLE, getName(), CONF, true, Bytes.toBytes("somefamily")); this.region = initHRegion(TABLE, method, CONF, true, Bytes.toBytes("somefamily"));
boolean exceptionCaught = false; boolean exceptionCaught = false;
Append append = new Append(Bytes.toBytes("somerow")); Append append = new Append(Bytes.toBytes("somerow"));
append.setDurability(Durability.SKIP_WAL); append.setDurability(Durability.SKIP_WAL);
@ -1427,7 +1409,7 @@ public class TestHRegion {
@Test @Test
public void testIncrWithReadOnlyTable() throws Exception { public void testIncrWithReadOnlyTable() throws Exception {
TableName TABLE = TableName.valueOf("readOnlyTable"); TableName TABLE = TableName.valueOf("readOnlyTable");
this.region = initHRegion(TABLE, getName(), CONF, true, Bytes.toBytes("somefamily")); this.region = initHRegion(TABLE, method, CONF, true, Bytes.toBytes("somefamily"));
boolean exceptionCaught = false; boolean exceptionCaught = false;
Increment inc = new Increment(Bytes.toBytes("somerow")); Increment inc = new Increment(Bytes.toBytes("somerow"));
inc.setDurability(Durability.SKIP_WAL); inc.setDurability(Durability.SKIP_WAL);
@ -1518,11 +1500,10 @@ public class TestHRegion {
@Test @Test
public void testFamilyWithAndWithoutColon() throws Exception { public void testFamilyWithAndWithoutColon() throws Exception {
TableName b = TableName.valueOf(getName());
byte[] cf = Bytes.toBytes(COLUMN_FAMILY); byte[] cf = Bytes.toBytes(COLUMN_FAMILY);
this.region = initHRegion(b, getName(), CONF, cf); this.region = initHRegion(tableName, method, CONF, cf);
try { try {
Put p = new Put(b.toBytes()); Put p = new Put(tableName.toBytes());
byte[] cfwithcolon = Bytes.toBytes(COLUMN_FAMILY + ":"); byte[] cfwithcolon = Bytes.toBytes(COLUMN_FAMILY + ":");
p.addColumn(cfwithcolon, cfwithcolon, cfwithcolon); p.addColumn(cfwithcolon, cfwithcolon, cfwithcolon);
boolean exception = false; boolean exception = false;
@ -1543,7 +1524,7 @@ public class TestHRegion {
byte[] cf = Bytes.toBytes(COLUMN_FAMILY); byte[] cf = Bytes.toBytes(COLUMN_FAMILY);
byte[] qual = Bytes.toBytes("qual"); byte[] qual = Bytes.toBytes("qual");
byte[] val = Bytes.toBytes("val"); byte[] val = Bytes.toBytes("val");
this.region = initHRegion(TableName.valueOf(getName()), getName(), CONF, cf); this.region = initHRegion(tableName, method, CONF, cf);
MetricsWALSource source = CompatibilitySingletonFactory.getInstance(MetricsWALSource.class); MetricsWALSource source = CompatibilitySingletonFactory.getInstance(MetricsWALSource.class);
try { try {
long syncs = metricsAssertHelper.getCounter("syncTimeNumOps", source); long syncs = metricsAssertHelper.getCounter("syncTimeNumOps", source);
@ -1584,7 +1565,7 @@ public class TestHRegion {
byte[] cf = Bytes.toBytes(COLUMN_FAMILY); byte[] cf = Bytes.toBytes(COLUMN_FAMILY);
byte[] qual = Bytes.toBytes("qual"); byte[] qual = Bytes.toBytes("qual");
byte[] val = Bytes.toBytes("val"); byte[] val = Bytes.toBytes("val");
this.region = initHRegion(TableName.valueOf(getName()), getName(), CONF, cf); this.region = initHRegion(tableName, method, CONF, cf);
MetricsWALSource source = CompatibilitySingletonFactory.getInstance(MetricsWALSource.class); MetricsWALSource source = CompatibilitySingletonFactory.getInstance(MetricsWALSource.class);
try { try {
long syncs = metricsAssertHelper.getCounter("syncTimeNumOps", source); long syncs = metricsAssertHelper.getCounter("syncTimeNumOps", source);
@ -1683,14 +1664,13 @@ public class TestHRegion {
@Test @Test
public void testBatchPutWithTsSlop() throws Exception { public void testBatchPutWithTsSlop() throws Exception {
TableName b = TableName.valueOf(getName());
byte[] cf = Bytes.toBytes(COLUMN_FAMILY); byte[] cf = Bytes.toBytes(COLUMN_FAMILY);
byte[] qual = Bytes.toBytes("qual"); byte[] qual = Bytes.toBytes("qual");
byte[] val = Bytes.toBytes("val"); byte[] val = Bytes.toBytes("val");
// add data with a timestamp that is too recent for range. Ensure assert // add data with a timestamp that is too recent for range. Ensure assert
CONF.setInt("hbase.hregion.keyvalue.timestamp.slop.millisecs", 1000); CONF.setInt("hbase.hregion.keyvalue.timestamp.slop.millisecs", 1000);
this.region = initHRegion(b, getName(), CONF, cf); this.region = initHRegion(tableName, method, CONF, cf);
try { try {
MetricsWALSource source = CompatibilitySingletonFactory.getInstance(MetricsWALSource.class); MetricsWALSource source = CompatibilitySingletonFactory.getInstance(MetricsWALSource.class);
@ -1730,7 +1710,6 @@ public class TestHRegion {
byte[] val2 = Bytes.toBytes("value2"); byte[] val2 = Bytes.toBytes("value2");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Putting empty data in key // Putting empty data in key
@ -1804,7 +1783,6 @@ public class TestHRegion {
byte[] val2 = Bytes.toBytes("value2"); byte[] val2 = Bytes.toBytes("value2");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Putting data in key // Putting data in key
@ -1837,7 +1815,6 @@ public class TestHRegion {
byte[] val1 = Bytes.toBytes("value1"); byte[] val1 = Bytes.toBytes("value1");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Putting data in key // Putting data in key
@ -1873,7 +1850,6 @@ public class TestHRegion {
byte[] val4 = Bytes.toBytes("value4"); byte[] val4 = Bytes.toBytes("value4");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Putting val3 in key // Putting val3 in key
@ -1969,7 +1945,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam2 }; byte[][] families = { fam1, fam2 };
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
// Putting data in the key to check // Putting data in the key to check
@ -2006,8 +1981,7 @@ public class TestHRegion {
@Test @Test
public void testCheckAndPut_wrongRowInPut() throws IOException { public void testCheckAndPut_wrongRowInPut() throws IOException {
TableName tableName = TableName.valueOf(name.getMethodName()); this.region = initHRegion(tableName, method, CONF, COLUMNS);
this.region = initHRegion(tableName, this.getName(), CONF, COLUMNS);
try { try {
Put put = new Put(row2); Put put = new Put(row2);
put.addColumn(fam1, qual1, value1); put.addColumn(fam1, qual1, value1);
@ -2040,7 +2014,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam2 }; byte[][] families = { fam1, fam2 };
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
// Put content // Put content
@ -2115,7 +2088,6 @@ public class TestHRegion {
put.addColumn(fam1, qual, (long) 1, value); put.addColumn(fam1, qual, (long) 1, value);
put.addColumn(fam1, qual, (long) 2, value); put.addColumn(fam1, qual, (long) 2, value);
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
region.put(put); region.put(put);
@ -2145,7 +2117,6 @@ public class TestHRegion {
byte[] fam4 = Bytes.toBytes("fam4"); byte[] fam4 = Bytes.toBytes("fam4");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1, fam2, fam3); this.region = initHRegion(tableName, method, CONF, fam1, fam2, fam3);
try { try {
List<Cell> kvs = new ArrayList<Cell>(); List<Cell> kvs = new ArrayList<Cell>();
@ -2184,7 +2155,6 @@ public class TestHRegion {
public void testDelete_mixed() throws IOException, InterruptedException { public void testDelete_mixed() throws IOException, InterruptedException {
byte[] fam = Bytes.toBytes("info"); byte[] fam = Bytes.toBytes("info");
byte[][] families = { fam }; byte[][] families = { fam };
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
EnvironmentEdgeManagerTestHelper.injectEdge(new IncrementingEnvironmentEdge()); EnvironmentEdgeManagerTestHelper.injectEdge(new IncrementingEnvironmentEdge());
@ -2252,7 +2222,6 @@ public class TestHRegion {
public void testDeleteRowWithFutureTs() throws IOException { public void testDeleteRowWithFutureTs() throws IOException {
byte[] fam = Bytes.toBytes("info"); byte[] fam = Bytes.toBytes("info");
byte[][] families = { fam }; byte[][] families = { fam };
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
byte[] row = Bytes.toBytes("table_name"); byte[] row = Bytes.toBytes("table_name");
@ -2295,7 +2264,6 @@ public class TestHRegion {
public void testPutWithLatestTS() throws IOException { public void testPutWithLatestTS() throws IOException {
byte[] fam = Bytes.toBytes("info"); byte[] fam = Bytes.toBytes("info");
byte[][] families = { fam }; byte[][] families = { fam };
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
byte[] row = Bytes.toBytes("row1"); byte[] row = Bytes.toBytes("row1");
@ -2347,7 +2315,6 @@ public class TestHRegion {
public void testPutWithTsSlop() throws IOException { public void testPutWithTsSlop() throws IOException {
byte[] fam = Bytes.toBytes("info"); byte[] fam = Bytes.toBytes("info");
byte[][] families = { fam }; byte[][] families = { fam };
String method = this.getName();
// add data with a timestamp that is too recent for range. Ensure assert // add data with a timestamp that is too recent for range. Ensure assert
CONF.setInt("hbase.hregion.keyvalue.timestamp.slop.millisecs", 1000); CONF.setInt("hbase.hregion.keyvalue.timestamp.slop.millisecs", 1000);
@ -2376,7 +2343,7 @@ public class TestHRegion {
public void testScanner_DeleteOneFamilyNotAnother() throws IOException { public void testScanner_DeleteOneFamilyNotAnother() throws IOException {
byte[] fam1 = Bytes.toBytes("columnA"); byte[] fam1 = Bytes.toBytes("columnA");
byte[] fam2 = Bytes.toBytes("columnB"); byte[] fam2 = Bytes.toBytes("columnB");
this.region = initHRegion(tableName, getName(), CONF, fam1, fam2); this.region = initHRegion(tableName, method, CONF, fam1, fam2);
try { try {
byte[] rowA = Bytes.toBytes("rowA"); byte[] rowA = Bytes.toBytes("rowA");
byte[] rowB = Bytes.toBytes("rowB"); byte[] rowB = Bytes.toBytes("rowB");
@ -2419,8 +2386,8 @@ public class TestHRegion {
FileSystem fs = FileSystem.get(CONF); FileSystem fs = FileSystem.get(CONF);
Path rootDir = new Path(dir + "testDataInMemoryWithoutWAL"); Path rootDir = new Path(dir + "testDataInMemoryWithoutWAL");
FSHLog hLog = new FSHLog(fs, rootDir, "testDataInMemoryWithoutWAL", CONF); FSHLog hLog = new FSHLog(fs, rootDir, "testDataInMemoryWithoutWAL", CONF);
HRegion region = initHRegion(tableName, null, null, name.getMethodName(), HRegion region = initHRegion(tableName, null, null, false, Durability.SYNC_WAL, hLog,
CONF, false, Durability.SYNC_WAL, hLog, COLUMN_FAMILY_BYTES); COLUMN_FAMILY_BYTES);
Cell originalCell = CellUtil.createCell(row, COLUMN_FAMILY_BYTES, qual1, Cell originalCell = CellUtil.createCell(row, COLUMN_FAMILY_BYTES, qual1,
System.currentTimeMillis(), KeyValue.Type.Put.getCode(), value1); System.currentTimeMillis(), KeyValue.Type.Put.getCode(), value1);
@ -2500,8 +2467,7 @@ public class TestHRegion {
} }
public void doTestDelete_AndPostInsert(Delete delete) throws IOException, InterruptedException { public void doTestDelete_AndPostInsert(Delete delete) throws IOException, InterruptedException {
TableName tableName = TableName.valueOf(name.getMethodName()); this.region = initHRegion(tableName, method, CONF, fam1);
this.region = initHRegion(tableName, getName(), CONF, fam1);
try { try {
EnvironmentEdgeManagerTestHelper.injectEdge(new IncrementingEnvironmentEdge()); EnvironmentEdgeManagerTestHelper.injectEdge(new IncrementingEnvironmentEdge());
Put put = new Put(row); Put put = new Put(row);
@ -2546,14 +2512,12 @@ public class TestHRegion {
@Test @Test
public void testDelete_CheckTimestampUpdated() throws IOException { public void testDelete_CheckTimestampUpdated() throws IOException {
TableName tableName = TableName.valueOf(name.getMethodName());
byte[] row1 = Bytes.toBytes("row1"); byte[] row1 = Bytes.toBytes("row1");
byte[] col1 = Bytes.toBytes("col1"); byte[] col1 = Bytes.toBytes("col1");
byte[] col2 = Bytes.toBytes("col2"); byte[] col2 = Bytes.toBytes("col2");
byte[] col3 = Bytes.toBytes("col3"); byte[] col3 = Bytes.toBytes("col3");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Building checkerList // Building checkerList
@ -2595,7 +2559,6 @@ public class TestHRegion {
byte[] col1 = Bytes.toBytes("col1"); byte[] col1 = Bytes.toBytes("col1");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
Get get = new Get(row1); Get get = new Get(row1);
@ -2626,7 +2589,6 @@ public class TestHRegion {
byte[] col5 = Bytes.toBytes("col5"); byte[] col5 = Bytes.toBytes("col5");
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Add to memstore // Add to memstore
@ -2672,7 +2634,6 @@ public class TestHRegion {
byte[] row = Bytes.toBytes("row"); byte[] row = Bytes.toBytes("row");
byte[] fam = Bytes.toBytes("fam"); byte[] fam = Bytes.toBytes("fam");
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam); this.region = initHRegion(tableName, method, CONF, fam);
try { try {
Get get = new Get(row); Get get = new Get(row);
@ -2694,7 +2655,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam2, fam3 }; byte[][] families = { fam1, fam2, fam3 };
Configuration hc = initSplit(); Configuration hc = initSplit();
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, hc, families); this.region = initHRegion(tableName, method, hc, families);
try { try {
LOG.info("" + HBaseTestCase.addContent(region, fam3)); LOG.info("" + HBaseTestCase.addContent(region, fam3));
@ -2786,7 +2746,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam2 }; byte[][] families = { fam1, fam2 };
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
Scan scan = new Scan(); Scan scan = new Scan();
@ -2811,7 +2770,6 @@ public class TestHRegion {
byte[][] families = { fam1 }; byte[][] families = { fam1 };
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
Scan scan = new Scan(); Scan scan = new Scan();
@ -2840,7 +2798,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam2, fam3, fam4 }; byte[][] families = { fam1, fam2, fam3, fam4 };
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
@ -2886,7 +2843,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam2 }; byte[][] families = { fam1, fam2 };
// Setting up region // Setting up region
String method = this.getName();
try { try {
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
} catch (IOException e) { } catch (IOException e) {
@ -2924,7 +2880,6 @@ public class TestHRegion {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
// Putting data in Region // Putting data in Region
@ -2990,7 +2945,6 @@ public class TestHRegion {
long ts3 = ts1 + 2; long ts3 = ts1 + 2;
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
// Putting data in Region // Putting data in Region
@ -3049,7 +3003,6 @@ public class TestHRegion {
long ts3 = ts1 + 2; long ts3 = ts1 + 2;
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
// Putting data in Region // Putting data in Region
@ -3114,7 +3067,6 @@ public class TestHRegion {
long ts4 = ts1 + 3; long ts4 = ts1 + 3;
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
// Putting data in Region // Putting data in Region
@ -3195,7 +3147,6 @@ public class TestHRegion {
long ts3 = ts1 + 2; long ts3 = ts1 + 2;
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {
// Putting data in Region // Putting data in Region
@ -3255,7 +3206,6 @@ public class TestHRegion {
long ts3 = ts1 + 2; long ts3 = ts1 + 2;
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Putting data in Region // Putting data in Region
@ -3307,7 +3257,7 @@ public class TestHRegion {
@Test @Test
public void testScanner_StopRow1542() throws IOException { public void testScanner_StopRow1542() throws IOException {
byte[] family = Bytes.toBytes("testFamily"); byte[] family = Bytes.toBytes("testFamily");
this.region = initHRegion(tableName, getName(), CONF, family); this.region = initHRegion(tableName, method, CONF, family);
try { try {
byte[] row1 = Bytes.toBytes("row111"); byte[] row1 = Bytes.toBytes("row111");
byte[] row2 = Bytes.toBytes("row222"); byte[] row2 = Bytes.toBytes("row222");
@ -3365,7 +3315,6 @@ public class TestHRegion {
long ts4 = ts1 + 3; long ts4 = ts1 + 3;
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, CONF, fam1); this.region = initHRegion(tableName, method, CONF, fam1);
try { try {
// Putting data in Region // Putting data in Region
@ -3442,7 +3391,7 @@ public class TestHRegion {
byte[] cf_essential = Bytes.toBytes("essential"); byte[] cf_essential = Bytes.toBytes("essential");
byte[] cf_joined = Bytes.toBytes("joined"); byte[] cf_joined = Bytes.toBytes("joined");
byte[] cf_alpha = Bytes.toBytes("alpha"); byte[] cf_alpha = Bytes.toBytes("alpha");
this.region = initHRegion(tableName, getName(), CONF, cf_essential, cf_joined, cf_alpha); this.region = initHRegion(tableName, method, CONF, cf_essential, cf_joined, cf_alpha);
try { try {
byte[] row1 = Bytes.toBytes("row1"); byte[] row1 = Bytes.toBytes("row1");
byte[] row2 = Bytes.toBytes("row2"); byte[] row2 = Bytes.toBytes("row2");
@ -3510,7 +3459,7 @@ public class TestHRegion {
final byte[] cf_first = Bytes.toBytes("first"); final byte[] cf_first = Bytes.toBytes("first");
final byte[] cf_second = Bytes.toBytes("second"); final byte[] cf_second = Bytes.toBytes("second");
this.region = initHRegion(tableName, getName(), CONF, cf_first, cf_second); this.region = initHRegion(tableName, method, CONF, cf_first, cf_second);
try { try {
final byte[] col_a = Bytes.toBytes("a"); final byte[] col_a = Bytes.toBytes("a");
final byte[] col_b = Bytes.toBytes("b"); final byte[] col_b = Bytes.toBytes("b");
@ -3603,8 +3552,6 @@ public class TestHRegion {
*/ */
@Test @Test
public void testLongQualifier() throws Exception { public void testLongQualifier() throws Exception {
String method = name.getMethodName();
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, CONF, family); this.region = initHRegion(tableName, method, CONF, family);
byte[] q = new byte[Short.MAX_VALUE+2]; byte[] q = new byte[Short.MAX_VALUE+2];
@ -3634,7 +3581,6 @@ public class TestHRegion {
Configuration hc = initSplit(); Configuration hc = initSplit();
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, hc, families); this.region = initHRegion(tableName, method, hc, families);
try { try {
@ -3723,7 +3669,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam3 }; byte[][] families = { fam1, fam3 };
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, hc, families); this.region = initHRegion(tableName, method, hc, families);
// Put data in region // Put data in region
@ -3762,7 +3707,6 @@ public class TestHRegion {
byte[][] families = { fam1, fam3 }; byte[][] families = { fam1, fam3 };
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, hc, families); this.region = initHRegion(tableName, method, hc, families);
// Put data in region // Put data in region
@ -3839,7 +3783,6 @@ public class TestHRegion {
int flushAndScanInterval = 10; int flushAndScanInterval = 10;
int compactInterval = 10 * flushAndScanInterval; int compactInterval = 10 * flushAndScanInterval;
String method = "testFlushCacheWhileScanning";
this.region = initHRegion(tableName, method, CONF, family); this.region = initHRegion(tableName, method, CONF, family);
FlushThread flushThread = new FlushThread(); FlushThread flushThread = new FlushThread();
try { try {
@ -3981,7 +3924,6 @@ public class TestHRegion {
qualifiers[i] = Bytes.toBytes("qual" + i); qualifiers[i] = Bytes.toBytes("qual" + i);
} }
String method = "testWritesWhileScanning";
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
FlushThread flushThread = new FlushThread(); FlushThread flushThread = new FlushThread();
PutThread putThread = new PutThread(numRows, families, qualifiers); PutThread putThread = new PutThread(numRows, families, qualifiers);
@ -4156,7 +4098,6 @@ public class TestHRegion {
} }
String method = "testWritesWhileGetting";
// This test flushes constantly and can cause many files to be created, // This test flushes constantly and can cause many files to be created,
// possibly // possibly
// extending over the ulimit. Make sure compactions are aggressive in // extending over the ulimit. Make sure compactions are aggressive in
@ -4273,7 +4214,6 @@ public class TestHRegion {
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
// Setting up region // Setting up region
String method = "testIndexesScanWithOneDeletedRow";
this.region = initHRegion(tableName, method, CONF, family); this.region = initHRegion(tableName, method, CONF, family);
try { try {
Put put = new Put(Bytes.toBytes(1L)); Put put = new Put(Bytes.toBytes(1L));
@ -4475,7 +4415,7 @@ public class TestHRegion {
try { try {
cluster = htu.startMiniCluster(1, regionServersCount, dataNodeHosts); cluster = htu.startMiniCluster(1, regionServersCount, dataNodeHosts);
byte[][] families = { fam1, fam2 }; byte[][] families = { fam1, fam2 };
Table ht = htu.createTable(TableName.valueOf(this.getName()), families); Table ht = htu.createTable(tableName, families);
// Setting up region // Setting up region
byte row[] = Bytes.toBytes("row1"); byte row[] = Bytes.toBytes("row1");
@ -4486,8 +4426,7 @@ public class TestHRegion {
put.addColumn(fam2, col, (long) 1, Bytes.toBytes("test2")); put.addColumn(fam2, col, (long) 1, Bytes.toBytes("test2"));
ht.put(put); ht.put(put);
HRegion firstRegion = htu.getHBaseCluster().getRegions(TableName.valueOf(this.getName())) HRegion firstRegion = htu.getHBaseCluster().getRegions(tableName).get(0);
.get(0);
firstRegion.flush(true); firstRegion.flush(true);
HDFSBlocksDistribution blocksDistribution1 = firstRegion.getHDFSBlocksDistribution(); HDFSBlocksDistribution blocksDistribution1 = firstRegion.getHDFSBlocksDistribution();
@ -4535,8 +4474,7 @@ public class TestHRegion {
*/ */
@Test @Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception { public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
TableName tableName = TableName.valueOf(name.getMethodName()); HRegionInfo info;
HRegionInfo info = null;
try { try {
FileSystem fs = Mockito.mock(FileSystem.class); FileSystem fs = Mockito.mock(FileSystem.class);
Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException()); Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
@ -4621,7 +4559,7 @@ public class TestHRegion {
private final static byte[] incRow = Bytes.toBytes("incRow"); private final static byte[] incRow = Bytes.toBytes("incRow");
private final static byte[] family = Bytes.toBytes("family"); private final static byte[] family = Bytes.toBytes("family");
private final static byte[] qualifier = Bytes.toBytes("qualifier"); private final static byte[] qualifier = Bytes.toBytes("qualifier");
private final static long ONE = 1l; private final static long ONE = 1L;
private int incCounter; private int incCounter;
public Incrementer(HRegion region, int incCounter) { public Incrementer(HRegion region, int incCounter) {
@ -4800,7 +4738,6 @@ public class TestHRegion {
@Test @Test
public void testPutWithMemStoreFlush() throws Exception { public void testPutWithMemStoreFlush() throws Exception {
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
;
byte[] qualifier = Bytes.toBytes("qualifier"); byte[] qualifier = Bytes.toBytes("qualifier");
byte[] row = Bytes.toBytes("putRow"); byte[] row = Bytes.toBytes("putRow");
byte[] value = null; byte[] value = null;
@ -4812,7 +4749,7 @@ public class TestHRegion {
put = new Put(row); put = new Put(row);
value = Bytes.toBytes("value0"); value = Bytes.toBytes("value0");
put.addColumn(family, qualifier, 1234567l, value); put.addColumn(family, qualifier, 1234567L, value);
region.put(put); region.put(put);
get = new Get(row); get = new Get(row);
get.addColumn(family, qualifier); get.addColumn(family, qualifier);
@ -4833,7 +4770,7 @@ public class TestHRegion {
put = new Put(row); put = new Put(row);
value = Bytes.toBytes("value1"); value = Bytes.toBytes("value1");
put.addColumn(family, qualifier, 1234567l, value); put.addColumn(family, qualifier, 1234567L, value);
region.put(put); region.put(put);
get = new Get(row); get = new Get(row);
get.addColumn(family, qualifier); get.addColumn(family, qualifier);
@ -4855,7 +4792,6 @@ public class TestHRegion {
@Test @Test
public void testDurability() throws Exception { public void testDurability() throws Exception {
String method = "testDurability";
// there are 5 x 5 cases: // there are 5 x 5 cases:
// table durability(SYNC,FSYNC,ASYC,SKIP,USE_DEFAULT) x mutation // table durability(SYNC,FSYNC,ASYC,SKIP,USE_DEFAULT) x mutation
// durability(SYNC,FSYNC,ASYC,SKIP,USE_DEFAULT) // durability(SYNC,FSYNC,ASYC,SKIP,USE_DEFAULT)
@ -4909,7 +4845,6 @@ public class TestHRegion {
final boolean expectSyncFromLogSyncer) throws Exception { final boolean expectSyncFromLogSyncer) throws Exception {
Configuration conf = HBaseConfiguration.create(CONF); Configuration conf = HBaseConfiguration.create(CONF);
method = method + "_" + tableDurability.name() + "_" + mutationDurability.name(); method = method + "_" + tableDurability.name() + "_" + mutationDurability.name();
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
Path logDir = new Path(new Path(dir + method), "log"); Path logDir = new Path(new Path(dir + method), "log");
final Configuration walConf = new Configuration(conf); final Configuration walConf = new Configuration(conf);
@ -4920,7 +4855,7 @@ public class TestHRegion {
final WALFactory wals = new WALFactory(walConf, null, UUID.randomUUID().toString()); final WALFactory wals = new WALFactory(walConf, null, UUID.randomUUID().toString());
final WAL wal = spy(wals.getWAL(tableName.getName(), tableName.getNamespace())); final WAL wal = spy(wals.getWAL(tableName.getName(), tableName.getNamespace()));
this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW, this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW,
HConstants.EMPTY_END_ROW, method, conf, false, tableDurability, wal, HConstants.EMPTY_END_ROW, false, tableDurability, wal,
new byte[][] { family }); new byte[][] { family });
Put put = new Put(Bytes.toBytes("r1")); Put put = new Put(Bytes.toBytes("r1"));
@ -5224,8 +5159,6 @@ public class TestHRegion {
*/ */
@Test @Test
public void testFlushResult() throws IOException { public void testFlushResult() throws IOException {
String method = name.getMethodName();
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, family); this.region = initHRegion(tableName, method, family);
@ -5278,7 +5211,7 @@ public class TestHRegion {
*/ */
protected HRegion initHRegion(TableName tableName, String callingMethod, Configuration conf, protected HRegion initHRegion(TableName tableName, String callingMethod, Configuration conf,
byte[]... families) throws IOException { byte[]... families) throws IOException {
return initHRegion(tableName, null, null, callingMethod, conf, false, families); return initHRegion(tableName, callingMethod, conf, false, families);
} }
/** /**
@ -5296,7 +5229,7 @@ public class TestHRegion {
Path logDir = TEST_UTIL.getDataTestDirOnTestFS(callingMethod + ".log"); Path logDir = TEST_UTIL.getDataTestDirOnTestFS(callingMethod + ".log");
HRegionInfo hri = new HRegionInfo(tableName, startKey, stopKey); HRegionInfo hri = new HRegionInfo(tableName, startKey, stopKey);
final WAL wal = HBaseTestingUtility.createWal(conf, logDir, hri); final WAL wal = HBaseTestingUtility.createWal(conf, logDir, hri);
return initHRegion(tableName, startKey, stopKey, callingMethod, conf, isReadOnly, return initHRegion(tableName, startKey, stopKey, isReadOnly,
Durability.SYNC_WAL, wal, families); Durability.SYNC_WAL, wal, families);
} }
@ -5305,8 +5238,7 @@ public class TestHRegion {
* {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done. * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} when done.
*/ */
public HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey, public HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey,
String callingMethod, Configuration conf, boolean isReadOnly, Durability durability, boolean isReadOnly, Durability durability, WAL wal, byte[]... families) throws IOException {
WAL wal, byte[]... families) throws IOException {
return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey, return TEST_UTIL.createLocalHRegion(tableName, startKey, stopKey,
isReadOnly, durability, wal, families); isReadOnly, durability, wal, families);
} }
@ -5338,7 +5270,6 @@ public class TestHRegion {
byte[][] families = { cf }; byte[][] families = { cf };
byte[] col = Bytes.toBytes("C"); byte[] col = Bytes.toBytes("C");
long ts = 1; long ts = 1;
String method = this.getName();
this.region = initHRegion(tableName, method, families); this.region = initHRegion(tableName, method, families);
try { try {
KeyValue kv1 = new KeyValue(rowC, cf, col, ts, KeyValue.Type.Put, null); KeyValue kv1 = new KeyValue(rowC, cf, col, ts, KeyValue.Type.Put, null);
@ -5398,7 +5329,6 @@ public class TestHRegion {
byte[][] families = { cf }; byte[][] families = { cf };
byte[] col = Bytes.toBytes("C"); byte[] col = Bytes.toBytes("C");
long ts = 1; long ts = 1;
String method = this.getName();
this.region = initHRegion(tableName, method, families); this.region = initHRegion(tableName, method, families);
try { try {
KeyValue kv1 = new KeyValue(rowC, cf, col, ts, KeyValue.Type.Put, null); KeyValue kv1 = new KeyValue(rowC, cf, col, ts, KeyValue.Type.Put, null);
@ -5457,7 +5387,6 @@ public class TestHRegion {
byte[][] families = { cf }; byte[][] families = { cf };
byte[] col = Bytes.toBytes("C"); byte[] col = Bytes.toBytes("C");
long ts = 1; long ts = 1;
String method = this.getName();
this.region = initHRegion(tableName, method, families); this.region = initHRegion(tableName, method, families);
try { try {
KeyValue kv1 = new KeyValue(rowC, cf, col, ts, KeyValue.Type.Put, null); KeyValue kv1 = new KeyValue(rowC, cf, col, ts, KeyValue.Type.Put, null);
@ -5517,7 +5446,6 @@ public class TestHRegion {
byte[] col1 = Bytes.toBytes("col1"); byte[] col1 = Bytes.toBytes("col1");
byte[] col2 = Bytes.toBytes("col2"); byte[] col2 = Bytes.toBytes("col2");
long ts = 1; long ts = 1;
String method = this.getName();
this.region = initHRegion(tableName, method, families); this.region = initHRegion(tableName, method, families);
try { try {
KeyValue kv1 = new KeyValue(rowA, cf, col1, ts, KeyValue.Type.Put, null); KeyValue kv1 = new KeyValue(rowA, cf, col1, ts, KeyValue.Type.Put, null);
@ -5599,7 +5527,6 @@ public class TestHRegion {
byte[] col1 = Bytes.toBytes("col1"); byte[] col1 = Bytes.toBytes("col1");
byte[] col2 = Bytes.toBytes("col2"); byte[] col2 = Bytes.toBytes("col2");
long ts = 1; long ts = 1;
String method = this.getName();
HBaseConfiguration config = new HBaseConfiguration(); HBaseConfiguration config = new HBaseConfiguration();
config.setInt("test.block.size", 1); config.setInt("test.block.size", 1);
this.region = initHRegion(tableName, method, config, families); this.region = initHRegion(tableName, method, config, families);
@ -5685,7 +5612,6 @@ public class TestHRegion {
byte[][] families = { cf1, cf2, cf3 }; byte[][] families = { cf1, cf2, cf3 };
byte[] col = Bytes.toBytes("C"); byte[] col = Bytes.toBytes("C");
long ts = 1; long ts = 1;
String method = this.getName();
HBaseConfiguration conf = new HBaseConfiguration(); HBaseConfiguration conf = new HBaseConfiguration();
// disable compactions in this test. // disable compactions in this test.
conf.setInt("hbase.hstore.compactionThreshold", 10000); conf.setInt("hbase.hstore.compactionThreshold", 10000);
@ -5853,7 +5779,6 @@ public class TestHRegion {
byte[][] families = { cf1, cf2, cf3, cf4 }; byte[][] families = { cf1, cf2, cf3, cf4 };
byte[] col = Bytes.toBytes("C"); byte[] col = Bytes.toBytes("C");
long ts = 1; long ts = 1;
String method = this.getName();
HBaseConfiguration conf = new HBaseConfiguration(); HBaseConfiguration conf = new HBaseConfiguration();
// disable compactions in this test. // disable compactions in this test.
conf.setInt("hbase.hstore.compactionThreshold", 10000); conf.setInt("hbase.hstore.compactionThreshold", 10000);
@ -5925,7 +5850,6 @@ public class TestHRegion {
byte[] cf1 = Bytes.toBytes("CF1"); byte[] cf1 = Bytes.toBytes("CF1");
byte[][] families = {cf1}; byte[][] families = {cf1};
byte[] col = Bytes.toBytes("C"); byte[] col = Bytes.toBytes("C");
String method = this.getName();
HBaseConfiguration conf = new HBaseConfiguration(); HBaseConfiguration conf = new HBaseConfiguration();
this.region = initHRegion(tableName, method, conf, families); this.region = initHRegion(tableName, method, conf, families);
try { try {
@ -5980,7 +5904,6 @@ public class TestHRegion {
byte[] cf1 = Bytes.toBytes("CF1"); byte[] cf1 = Bytes.toBytes("CF1");
byte[][] families = { cf1 }; byte[][] families = { cf1 };
byte[] col = Bytes.toBytes("C"); byte[] col = Bytes.toBytes("C");
String method = this.getName();
HBaseConfiguration conf = new HBaseConfiguration(); HBaseConfiguration conf = new HBaseConfiguration();
this.region = initHRegion(tableName, method, conf, families); this.region = initHRegion(tableName, method, conf, families);
try { try {
@ -6042,7 +5965,6 @@ public class TestHRegion {
byte [][] families = {fam1}; byte [][] families = {fam1};
//Setting up region //Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, hc, families); this.region = initHRegion(tableName, method, hc, families);
//Put data in region //Put data in region
@ -6439,8 +6361,6 @@ public class TestHRegion {
*/ */
@Test @Test
public void testRegionTooBusy() throws IOException { public void testRegionTooBusy() throws IOException {
String method = "testRegionTooBusy";
TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family"); byte[] family = Bytes.toBytes("family");
long defaultBusyWaitDuration = CONF.getLong("hbase.busy.wait.duration", long defaultBusyWaitDuration = CONF.getLong("hbase.busy.wait.duration",
HRegion.DEFAULT_BUSY_WAIT_DURATION); HRegion.DEFAULT_BUSY_WAIT_DURATION);
@ -6616,7 +6536,7 @@ public class TestHRegion {
@Test @Test
public void testIncrementTimestampsAreMonotonic() throws IOException { public void testIncrementTimestampsAreMonotonic() throws IOException {
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1); HRegion region = initHRegion(tableName, method, CONF, fam1);
ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
EnvironmentEdgeManager.injectEdge(edge); EnvironmentEdgeManager.injectEdge(edge);
@ -6641,7 +6561,7 @@ public class TestHRegion {
@Test @Test
public void testAppendTimestampsAreMonotonic() throws IOException { public void testAppendTimestampsAreMonotonic() throws IOException {
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1); HRegion region = initHRegion(tableName, method, CONF, fam1);
ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
EnvironmentEdgeManager.injectEdge(edge); EnvironmentEdgeManager.injectEdge(edge);
@ -6672,7 +6592,7 @@ public class TestHRegion {
@Test @Test
public void testCheckAndMutateTimestampsAreMonotonic() throws IOException { public void testCheckAndMutateTimestampsAreMonotonic() throws IOException {
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1); HRegion region = initHRegion(tableName, method, CONF, fam1);
ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
EnvironmentEdgeManager.injectEdge(edge); EnvironmentEdgeManager.injectEdge(edge);
@ -6708,7 +6628,7 @@ public class TestHRegion {
int prevLockTimeout = CONF.getInt("hbase.rowlock.wait.duration", 30000); int prevLockTimeout = CONF.getInt("hbase.rowlock.wait.duration", 30000);
CONF.setInt("hbase.rowlock.wait.duration", 1000); CONF.setInt("hbase.rowlock.wait.duration", 1000);
final HRegion region = initHRegion(tableName, a, c, name.getMethodName(), CONF, false, fam1); final HRegion region = initHRegion(tableName, a, c, method, CONF, false, fam1);
Mutation[] mutations = new Mutation[] { Mutation[] mutations = new Mutation[] {
new Put(a).addImmutable(fam1, null, null), new Put(a).addImmutable(fam1, null, null),
@ -6764,7 +6684,7 @@ public class TestHRegion {
@Test @Test
public void testCheckAndRowMutateTimestampsAreMonotonic() throws IOException { public void testCheckAndRowMutateTimestampsAreMonotonic() throws IOException {
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1); HRegion region = initHRegion(tableName, method, CONF, fam1);
ManualEnvironmentEdge edge = new ManualEnvironmentEdge(); ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
EnvironmentEdgeManager.injectEdge(edge); EnvironmentEdgeManager.injectEdge(edge);
@ -6822,7 +6742,6 @@ public class TestHRegion {
qualifiers[i] = Bytes.toBytes("qual" + i); qualifiers[i] = Bytes.toBytes("qual" + i);
} }
String method = "testWritesWhileRollWriter";
CONF.setInt("hbase.regionserver.wal.disruptor.event.count", 2); CONF.setInt("hbase.regionserver.wal.disruptor.event.count", 2);
this.region = initHRegion(tableName, method, CONF, families); this.region = initHRegion(tableName, method, CONF, families);
try { try {

View File

@ -29,14 +29,11 @@ import org.apache.hadoop.hbase.HBaseTestCase;
import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Durability; import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.TestMobSnapshotCloneIndependence;
import org.apache.hadoop.hbase.master.procedure.TestMasterFailoverWithProcedures;
import org.apache.hadoop.hbase.testclassification.LargeTests; import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.VerySlowRegionServerTests; import org.apache.hadoop.hbase.testclassification.VerySlowRegionServerTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.wal.WAL; import org.apache.hadoop.hbase.wal.WAL;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule; import org.junit.rules.TestRule;
@ -66,8 +63,7 @@ public class TestHRegionWithInMemoryFlush extends TestHRegion{
*/ */
@Override @Override
public HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey, public HRegion initHRegion(TableName tableName, byte[] startKey, byte[] stopKey,
String callingMethod, Configuration conf, boolean isReadOnly, Durability durability, boolean isReadOnly, Durability durability, WAL wal, byte[]... families) throws IOException {
WAL wal, byte[]... families) throws IOException {
boolean[] inMemory = new boolean[families.length]; boolean[] inMemory = new boolean[families.length];
for(int i = 0; i < inMemory.length; i++) { for(int i = 0; i < inMemory.length; i++) {
inMemory[i] = true; inMemory[i] = true;
@ -87,7 +83,6 @@ public class TestHRegionWithInMemoryFlush extends TestHRegion{
Configuration hc = initSplit(); Configuration hc = initSplit();
// Setting up region // Setting up region
String method = this.getName();
this.region = initHRegion(tableName, method, hc, families); this.region = initHRegion(tableName, method, hc, families);
try { try {