Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,6 @@
@InterfaceAudience.Public
@SuppressWarnings("deprecation")
public class HBaseTestingUtility extends HBaseZKTestingUtility {

/**
* System property key to get test directory value. Name is as it is because mini dfs has
* hard-codings to put test data here. It should NOT be used directly in HBase, as it's a property
* used in mini dfs.
* @deprecated since 2.0.0 and will be removed in 3.0.0. Can be used only with mini dfs.
* @see <a href="https://issues.apache.org/jira/browse/HBASE-19410">HBASE-19410</a>
*/
@Deprecated
private static final String TEST_DIRECTORY_KEY = "test.build.data";

public static final String REGIONS_PER_SERVER_KEY = "hbase.test.regions-per-server";
/**
* The default number of regions per regionserver when creating a pre-split
Expand Down Expand Up @@ -306,9 +295,7 @@ public static List<Object[]> memStoreTSTagsAndOffheapCombination() {
* Once {@link #startMiniDFSCluster} is called, either directly or via
* {@link #startMiniCluster()}, tmp data will be written to the DFS directory instead.
*
* <p>Previously, there was a distinction between the type of utility returned by
* {@link #createLocalHTU()} and this constructor; this is no longer the case. All
* HBaseTestingUtility objects will behave as local until a DFS cluster is started,
* <p>All HBaseTestingUtility objects will behave as local until a DFS cluster is started,
* at which point they will switch to using mini DFS for storage.
*/
public HBaseTestingUtility() {
Expand All @@ -322,9 +309,7 @@ public HBaseTestingUtility() {
* Once {@link #startMiniDFSCluster} is called, either directly or via
* {@link #startMiniCluster()}, tmp data will be written to the DFS directory instead.
*
* <p>Previously, there was a distinction between the type of utility returned by
* {@link #createLocalHTU()} and this constructor; this is no longer the case. All
* HBaseTestingUtility objects will behave as local until a DFS cluster is started,
* <p>All HBaseTestingUtility objects will behave as local until a DFS cluster is started,
* at which point they will switch to using mini DFS for storage.
*
* @param conf The configuration to use for further operations
Expand Down Expand Up @@ -355,30 +340,6 @@ public HBaseTestingUtility(@Nullable Configuration conf) {
this.conf.getBoolean(LocalHBaseCluster.ASSIGN_RANDOM_PORTS, true));
}

/**
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use {@link #HBaseTestingUtility()}
* instead.
* @return a normal HBaseTestingUtility
* @see #HBaseTestingUtility()
* @see <a href="https://issues.apache.org/jira/browse/HBASE-19841">HBASE-19841</a>
*/
@Deprecated
public static HBaseTestingUtility createLocalHTU() {
return new HBaseTestingUtility();
}

/**
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use
* {@link #HBaseTestingUtility(Configuration)} instead.
* @return a normal HBaseTestingUtility
* @see #HBaseTestingUtility(Configuration)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-19841">HBASE-19841</a>
*/
@Deprecated
public static HBaseTestingUtility createLocalHTU(Configuration c) {
return new HBaseTestingUtility(c);
}

/**
* Close both the region {@code r} and it's underlying WAL. For use in tests.
*/
Expand Down Expand Up @@ -419,9 +380,7 @@ public void setHBaseCluster(HBaseCluster hbaseCluster) {
/**
* Home our data in a dir under {@link #DEFAULT_BASE_TEST_DIRECTORY}.
* Give it a random name so can have many concurrent tests running if
* we need to. It needs to amend the {@link #TEST_DIRECTORY_KEY}
* System property, as it's what minidfscluster bases
* it data dir on. Moding a System property is not the way to do concurrent
* we need to. Moding a System property is not the way to do concurrent
* instances -- another instance could grab the temporary
* value unintentionally -- but not anything can do about it at moment;
* single instance only is how the minidfscluster works.
Expand Down Expand Up @@ -686,8 +645,6 @@ public MiniDFSCluster startMiniDFSClusterForTestWAL(int namenodePort) throws IOE
/** This is used before starting HDFS and map-reduce mini-clusters */
private void createDirsAndSetProperties() throws IOException {
setupClusterTestDir();
conf.set(TEST_DIRECTORY_KEY, clusterTestDir.getPath());
System.setProperty(TEST_DIRECTORY_KEY, clusterTestDir.getPath());
createDirAndSetProperty("cache_data", "test.cache.data");
createDirAndSetProperty("hadoop_tmp", "hadoop.tmp.dir");
hadoopLogDir = createDirAndSetProperty("hadoop_logs", "hadoop.log.dir");
Expand Down Expand Up @@ -1077,7 +1034,6 @@ public MiniHBaseCluster startMiniCluster(StartMiniClusterOption option) throws E
miniClusterRunning = true;

setupClusterTestDir();
System.setProperty(TEST_DIRECTORY_KEY, this.clusterTestDir.getPath());

// Bring up mini dfs cluster. This spews a bunch of warnings about missing
// scheme. Complaints are 'Scheme is undefined for build/test/data/dfs/name1'.
Expand Down Expand Up @@ -1927,34 +1883,6 @@ public void deleteTableIfAny(TableName tableName) throws IOException {
public static final byte [] START_KEY_BYTES = {FIRST_CHAR, FIRST_CHAR, FIRST_CHAR};
public static final String START_KEY = new String(START_KEY_BYTES, HConstants.UTF8_CHARSET);

/**
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use
* {@link #createTableDescriptor(TableName, int, int, int, KeepDeletedCells)} instead.
* @see #createTableDescriptor(TableName, int, int, int, KeepDeletedCells)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-13893">HBASE-13893</a>
*/
@Deprecated
public HTableDescriptor createTableDescriptor(final String name,
final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) {
return this.createTableDescriptor(TableName.valueOf(name), minVersions, versions, ttl,
keepDeleted);
}

/**
* Create a table of name <code>name</code>.
* @param name Name to give table.
* @return Column descriptor.
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use
* {@link #createTableDescriptor(TableName, int, int, int, KeepDeletedCells)} instead.
* @see #createTableDescriptor(TableName, int, int, int, KeepDeletedCells)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-13893">HBASE-13893</a>
*/
@Deprecated
public HTableDescriptor createTableDescriptor(final String name) {
return createTableDescriptor(TableName.valueOf(name), HColumnDescriptor.DEFAULT_MIN_VERSIONS,
MAXVERSIONS, HConstants.FOREVER, HColumnDescriptor.DEFAULT_KEEP_DELETED);
}

public HTableDescriptor createTableDescriptor(final TableName name,
final int minVersions, final int versions, final int ttl, KeepDeletedCells keepDeleted) {
HTableDescriptor htd = new HTableDescriptor(name);
Expand Down Expand Up @@ -2038,32 +1966,6 @@ public HRegion createLocalHRegion(RegionInfo info, TableDescriptor desc, WAL wal
return HRegion.createHRegion(info, getDataTestDir(), getConfiguration(), desc, wal);
}

/**
* @param tableName the name of the table
* @param startKey the start key of the region
* @param stopKey the stop key of the region
* @param callingMethod the name of the calling method probably a test method
* @param conf the configuration to use
* @param isReadOnly {@code true} if the table is read only, {@code false} otherwise
* @param families the column families to use
* @throws IOException if an IO problem is encountered
* @return A region on which you must call {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)}
* when done.
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use
* {@link #createLocalHRegion(TableName, byte[], byte[], boolean, Durability, WAL, byte[]...)}
* instead.
* @see #createLocalHRegion(TableName, byte[], byte[], boolean, Durability, WAL, byte[]...)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-13893">HBASE-13893</a>
*/
@Deprecated
public HRegion createLocalHRegion(byte[] tableName, byte[] startKey, byte[] stopKey,
String callingMethod, Configuration conf, boolean isReadOnly, Durability durability,
WAL wal, byte[]... families) throws IOException {
return this
.createLocalHRegion(TableName.valueOf(tableName), startKey, stopKey, isReadOnly, durability,
wal, families);
}

/**
* @param tableName
* @param startKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static void tearDownAfterClass() throws Exception {
*/
@Test
public void testDuplicateAppend() throws Exception {
HTableDescriptor hdt = TEST_UTIL.createTableDescriptor(name.getMethodName());
HTableDescriptor hdt = TEST_UTIL.createTableDescriptor(TableName.valueOf(name.getMethodName()));
Map<String, String> kvs = new HashMap<>();
kvs.put(SleepAtFirstRpcCall.SLEEP_TIME_CONF_KEY, "2000");
hdt.addCoprocessor(SleepAtFirstRpcCall.class.getName(), null, 1, kvs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static void afterClass() throws Exception {
@Test
public void testCreateDeleteTable() throws IOException {
// Create table then get the single region for our new table.
HTableDescriptor hdt = HTU.createTableDescriptor("testCreateDeleteTable");
HTableDescriptor hdt = HTU.createTableDescriptor(TableName.valueOf("testCreateDeleteTable"));
hdt.setRegionReplication(NB_SERVERS);
hdt.addCoprocessor(SlowMeCopro.class.getName());
Table table = HTU.createTable(hdt, new byte[][]{f}, null);
Expand Down Expand Up @@ -370,7 +370,8 @@ public void testChangeTable() throws Exception {
@SuppressWarnings("deprecation")
@Test
public void testReplicaAndReplication() throws Exception {
HTableDescriptor hdt = HTU.createTableDescriptor("testReplicaAndReplication");
HTableDescriptor hdt =
HTU.createTableDescriptor(TableName.valueOf("testReplicaAndReplication"));
hdt.setRegionReplication(NB_SERVERS);

HColumnDescriptor fam = new HColumnDescriptor(row);
Expand Down Expand Up @@ -456,7 +457,7 @@ public void testReplicaAndReplication() throws Exception {
public void testBulkLoad() throws IOException {
// Create table then get the single region for our new table.
LOG.debug("Creating test table");
HTableDescriptor hdt = HTU.createTableDescriptor("testBulkLoad");
HTableDescriptor hdt = HTU.createTableDescriptor(TableName.valueOf("testBulkLoad"));
hdt.setRegionReplication(NB_SERVERS);
hdt.addCoprocessor(SlowMeCopro.class.getName());
Table table = HTU.createTable(hdt, new byte[][]{f}, null);
Expand Down Expand Up @@ -512,7 +513,7 @@ public void testBulkLoad() throws IOException {
@Test
public void testReplicaGetWithPrimaryDown() throws IOException {
// Create table then get the single region for our new table.
HTableDescriptor hdt = HTU.createTableDescriptor("testCreateDeleteTable");
HTableDescriptor hdt = HTU.createTableDescriptor(TableName.valueOf("testCreateDeleteTable"));
hdt.setRegionReplication(NB_SERVERS);
hdt.addCoprocessor(RegionServerStoppedCopro.class.getName());
try {
Expand Down Expand Up @@ -546,7 +547,7 @@ public void testReplicaGetWithPrimaryDown() throws IOException {
@Test
public void testReplicaScanWithPrimaryDown() throws IOException {
// Create table then get the single region for our new table.
HTableDescriptor hdt = HTU.createTableDescriptor("testCreateDeleteTable");
HTableDescriptor hdt = HTU.createTableDescriptor(TableName.valueOf("testCreateDeleteTable"));
hdt.setRegionReplication(NB_SERVERS);
hdt.addCoprocessor(RegionServerStoppedCopro.class.getName());

Expand Down Expand Up @@ -592,7 +593,8 @@ public void testReplicaGetWithRpcClientImpl() throws IOException {
HTU.getConfiguration().setBoolean("hbase.ipc.client.specificThreadForWriting", true);
HTU.getConfiguration().set("hbase.rpc.client.impl", "org.apache.hadoop.hbase.ipc.RpcClientImpl");
// Create table then get the single region for our new table.
HTableDescriptor hdt = HTU.createTableDescriptor("testReplicaGetWithRpcClientImpl");
HTableDescriptor hdt =
HTU.createTableDescriptor(TableName.valueOf("testReplicaGetWithRpcClientImpl"));
hdt.setRegionReplication(NB_SERVERS);
hdt.addCoprocessor(SlowMeCopro.class.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public static void beforeClass() throws Exception {
HTU.startMiniCluster(NB_SERVERS);

// Create table then get the single region for our new table.
HTableDescriptor hdt = HTU.createTableDescriptor(TestReplicasClient.class.getSimpleName());
HTableDescriptor hdt =
HTU.createTableDescriptor(TableName.valueOf(TestReplicasClient.class.getSimpleName()));
hdt.addCoprocessor(SlowMeCopro.class.getName());
HTU.createTable(hdt, new byte[][]{f}, null);
TABLE_NAME = hdt.getTableName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class TestCoprocessorInterface {

@Rule public TestName name = new TestName();
private static final Logger LOG = LoggerFactory.getLogger(TestCoprocessorInterface.class);
private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
static final Path DIR = TEST_UTIL.getDataTestDir();

private static class CustomScanner implements RegionScanner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class TestCoreMasterCoprocessor {
HBaseClassTestRule.forClass(TestCoreMasterCoprocessor.class);

@Rule public TestName name = new TestName();
private static final HBaseTestingUtility HTU = HBaseTestingUtility.createLocalHTU();
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
private MasterServices ms;
private MasterCoprocessorHost mch;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class TestCoreRegionCoprocessor {
HBaseClassTestRule.forClass(TestCoreRegionCoprocessor.class);

@Rule public TestName name = new TestName();
HBaseTestingUtility HTU = HBaseTestingUtility.createLocalHTU();
HBaseTestingUtility HTU = new HBaseTestingUtility();
private HRegion region = null;
private RegionServerServices rss;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class TestCoreRegionServerCoprocessor {
HBaseClassTestRule.forClass(TestCoreRegionServerCoprocessor.class);

@Rule public TestName name = new TestName();
private static final HBaseTestingUtility HTU = HBaseTestingUtility.createLocalHTU();
private static final HBaseTestingUtility HTU = new HBaseTestingUtility();
private RegionServerServices rss;
private RegionServerCoprocessorHost rsch;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class TestEncodedSeekers {
private static final int NUM_HFILES = 4;
private static final int NUM_ROWS_PER_FLUSH = NUM_ROWS / NUM_HFILES;

private final HBaseTestingUtility testUtil = HBaseTestingUtility.createLocalHTU();
private final HBaseTestingUtility testUtil = new HBaseTestingUtility();
private final DataBlockEncoding encoding;
private final boolean includeTags;
private final boolean compressTags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class TestCacheOnWrite {

private static final Logger LOG = LoggerFactory.getLogger(TestCacheOnWrite.class);

private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private Configuration conf;
private CacheConfig cacheConf;
private FileSystem fs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class TestForceCacheImportantBlocks {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestForceCacheImportantBlocks.class);

private final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();

private static final String TABLE = "myTable";
private static final String CF = "myCF";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class TestScannerFromBucketCache {
private TableName tableName;

private void setUp(boolean useBucketCache) throws IOException {
test_util = HBaseTestingUtility.createLocalHTU();
test_util = new HBaseTestingUtility();
conf = test_util.getConfiguration();
if (useBucketCache) {
conf.setInt("hbase.bucketcache.size", 400);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class TestScannerSelectionUsingKeyRange {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestScannerSelectionUsingKeyRange.class);

private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static TableName TABLE = TableName.valueOf("myTable");
private static String FAMILY = "myCF";
private static byte[] FAMILY_BYTES = Bytes.toBytes(FAMILY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class TestScannerSelectionUsingTTL {
private static final Logger LOG =
LoggerFactory.getLogger(TestScannerSelectionUsingTTL.class);

private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static TableName TABLE = TableName.valueOf("myTable");
private static String FAMILY = "myCF";
private static byte[] FAMILY_BYTES = Bytes.toBytes(FAMILY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class TestHMasterRPCException {

private static final Logger LOG = LoggerFactory.getLogger(TestHMasterRPCException.class);

private final HBaseTestingUtility testUtil = HBaseTestingUtility.createLocalHTU();
private final HBaseTestingUtility testUtil = new HBaseTestingUtility();

private HMaster master;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public class TestMobFileCache {

@Before
public void setUp() throws Exception {
UTIL = HBaseTestingUtility.createLocalHTU();
UTIL = new HBaseTestingUtility();
conf = UTIL.getConfiguration();
conf.set(MobConstants.MOB_FILE_CACHE_SIZE_KEY, TEST_CACHE_SIZE);
HTableDescriptor htd = UTIL.createTableDescriptor("testMobFileCache");
HTableDescriptor htd = UTIL.createTableDescriptor(TableName.valueOf("testMobFileCache"));
HColumnDescriptor hcd1 = new HColumnDescriptor(FAMILY1);
hcd1.setMobEnabled(true);
hcd1.setMobThreshold(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class TestAtomicOperation {
@Rule public TestName name = new TestName();

HRegion region = null;
private HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();

// Test names
static byte[] tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class TestCacheOnWriteInSchema {
private static final Logger LOG = LoggerFactory.getLogger(TestCacheOnWriteInSchema.class);
@Rule public TestName name = new TestName();

private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static final String DIR = TEST_UTIL.getDataTestDir("TestCacheOnWriteInSchema").toString();
private static byte [] table;
private static byte [] family = Bytes.toBytes("family");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class TestColumnSeeking {
HBaseClassTestRule.forClass(TestColumnSeeking.class);

@Rule public TestName name = new TestName();
private final static HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();

private static final Logger LOG = LoggerFactory.getLogger(TestColumnSeeking.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected void compactingSetUp() throws Exception {
conf.setBoolean(MemStoreLAB.USEMSLAB_KEY, true);
conf.setFloat(MemStoreLAB.CHUNK_POOL_MAXSIZE_KEY, 0.2f);
conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, 1000);
HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);
HBaseTestingUtility hbaseUtility = new HBaseTestingUtility(conf);
HColumnDescriptor hcd = new HColumnDescriptor(FAMILY);
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("foobar"));
htd.addFamily(hcd);
Expand Down
Loading