HBASE-13809 TestRowTooBig should use HDFS directory for its region directory (Stephen Yuan Jiang)
This commit is contained in:
parent
1bb84fd80c
commit
aefc78d4fc
|
@ -283,6 +283,15 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
||||||
return htu;
|
return htu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the Region {@code r}. For use in tests.
|
||||||
|
*/
|
||||||
|
public static void closeRegion(final Region r) throws IOException {
|
||||||
|
if (r != null) {
|
||||||
|
((HRegion)r).close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this classes's instance of {@link Configuration}. Be careful how
|
* Returns this classes's instance of {@link Configuration}. Be careful how
|
||||||
* you use the returned Configuration since {@link HConnection} instances
|
* you use the returned Configuration since {@link HConnection} instances
|
||||||
|
@ -1851,6 +1860,18 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
|
||||||
MAXVERSIONS, HConstants.FOREVER, HColumnDescriptor.DEFAULT_KEEP_DELETED);
|
MAXVERSIONS, HConstants.FOREVER, HColumnDescriptor.DEFAULT_KEEP_DELETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an HRegion. Be sure to call {@link HBaseTestingUtility#closeRegion(Region)}
|
||||||
|
* when you're finished with it.
|
||||||
|
*/
|
||||||
|
public HRegion createHRegion(
|
||||||
|
final HRegionInfo info,
|
||||||
|
final Path rootDir,
|
||||||
|
final Configuration conf,
|
||||||
|
final HTableDescriptor htd) throws IOException {
|
||||||
|
return HRegion.createHRegion(info, rootDir, conf, htd);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an HRegion that writes to the local tmp dirs
|
* Create an HRegion that writes to the local tmp dirs
|
||||||
* @param desc
|
* @param desc
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.apache.hadoop.hbase.regionserver;
|
package org.apache.hadoop.hbase.regionserver;
|
||||||
|
|
||||||
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hbase.*;
|
import org.apache.hadoop.hbase.*;
|
||||||
import org.apache.hadoop.hbase.client.Get;
|
import org.apache.hadoop.hbase.client.Get;
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
import org.apache.hadoop.hbase.client.Put;
|
||||||
|
@ -38,6 +39,7 @@ import java.io.IOException;
|
||||||
@Category(MediumTests.class)
|
@Category(MediumTests.class)
|
||||||
public class TestRowTooBig {
|
public class TestRowTooBig {
|
||||||
private final static HBaseTestingUtility HTU = HBaseTestingUtility.createLocalHTU();
|
private final static HBaseTestingUtility HTU = HBaseTestingUtility.createLocalHTU();
|
||||||
|
private static Path rootRegionDir;
|
||||||
private static final HTableDescriptor TEST_HTD =
|
private static final HTableDescriptor TEST_HTD =
|
||||||
new HTableDescriptor(TableName.valueOf(TestRowTooBig.class.getSimpleName()));
|
new HTableDescriptor(TableName.valueOf(TestRowTooBig.class.getSimpleName()));
|
||||||
|
|
||||||
|
@ -46,6 +48,7 @@ public class TestRowTooBig {
|
||||||
HTU.startMiniCluster();
|
HTU.startMiniCluster();
|
||||||
HTU.getConfiguration().setLong(HConstants.TABLE_MAX_ROWSIZE_KEY,
|
HTU.getConfiguration().setLong(HConstants.TABLE_MAX_ROWSIZE_KEY,
|
||||||
10 * 1024 * 1024L);
|
10 * 1024 * 1024L);
|
||||||
|
rootRegionDir = HTU.getDataTestDirOnTestFS("TestRowTooBig");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
@ -80,19 +83,22 @@ public class TestRowTooBig {
|
||||||
final HRegionInfo hri =
|
final HRegionInfo hri =
|
||||||
new HRegionInfo(htd.getTableName(), HConstants.EMPTY_END_ROW,
|
new HRegionInfo(htd.getTableName(), HConstants.EMPTY_END_ROW,
|
||||||
HConstants.EMPTY_END_ROW);
|
HConstants.EMPTY_END_ROW);
|
||||||
Region region = HTU.createLocalHRegion(hri, htd);
|
Region region = HTU.createHRegion(hri, rootRegionDir, HTU.getConfiguration(), htd);
|
||||||
|
try {
|
||||||
|
// Add 5 cells to memstore
|
||||||
|
for (int i = 0; i < 5 ; i++) {
|
||||||
|
Put put = new Put(row1);
|
||||||
|
|
||||||
// Add 5 cells to memstore
|
put.add(fam1, Bytes.toBytes("col_" + i ), new byte[5 * 1024 * 1024]);
|
||||||
for (int i = 0; i < 5 ; i++) {
|
region.put(put);
|
||||||
Put put = new Put(row1);
|
region.flush(true);
|
||||||
|
}
|
||||||
|
|
||||||
put.add(fam1, Bytes.toBytes("col_" + i ), new byte[5 * 1024 * 1024]);
|
Get get = new Get(row1);
|
||||||
region.put(put);
|
region.get(get);
|
||||||
region.flush(true);
|
} finally {
|
||||||
|
HBaseTestingUtility.closeRegion(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
Get get = new Get(row1);
|
|
||||||
region.get(get);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,20 +128,23 @@ public class TestRowTooBig {
|
||||||
final HRegionInfo hri =
|
final HRegionInfo hri =
|
||||||
new HRegionInfo(htd.getTableName(), HConstants.EMPTY_END_ROW,
|
new HRegionInfo(htd.getTableName(), HConstants.EMPTY_END_ROW,
|
||||||
HConstants.EMPTY_END_ROW);
|
HConstants.EMPTY_END_ROW);
|
||||||
Region region = HTU.createLocalHRegion(hri, htd);
|
Region region = HTU.createHRegion(hri, rootRegionDir, HTU.getConfiguration(), htd);
|
||||||
|
try {
|
||||||
// Add to memstore
|
// Add to memstore
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
Put put = new Put(row1);
|
Put put = new Put(row1);
|
||||||
for (int j = 0; j < 10 * 10000; j++) {
|
for (int j = 0; j < 10 * 10000; j++) {
|
||||||
put.add(fam1, Bytes.toBytes("col_" + i + "_" + j), new byte[10]);
|
put.add(fam1, Bytes.toBytes("col_" + i + "_" + j), new byte[10]);
|
||||||
|
}
|
||||||
|
region.put(put);
|
||||||
|
region.flush(true);
|
||||||
}
|
}
|
||||||
region.put(put);
|
region.compact(true);
|
||||||
region.flush(true);
|
|
||||||
}
|
|
||||||
region.compact(true);
|
|
||||||
|
|
||||||
Get get = new Get(row1);
|
Get get = new Get(row1);
|
||||||
region.get(get);
|
region.get(get);
|
||||||
|
} finally {
|
||||||
|
HBaseTestingUtility.closeRegion(region);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue