Skip to content

Commit 7a54ae2

Browse files
committed
HBASE-26096 Cleanup the deprecated methods in HBTU related classes and format code
1 parent 4a3c7d7 commit 7a54ae2

File tree

12 files changed

+762
-1350
lines changed

12 files changed

+762
-1350
lines changed

hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseCommonTestingUtil.java

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,19 @@ public class HBaseCommonTestingUtil {
4949
* Compression algorithms to use in parameterized JUnit 4 tests
5050
*/
5151
public static final List<Object[]> COMPRESSION_ALGORITHMS_PARAMETERIZED =
52-
Arrays.asList(new Object[][] {
53-
{ Compression.Algorithm.NONE },
54-
{ Compression.Algorithm.GZ }
55-
});
52+
Arrays.asList(new Object[][] { { Compression.Algorithm.NONE }, { Compression.Algorithm.GZ } });
5653

5754
/**
5855
* This is for unit tests parameterized with a two booleans.
5956
*/
6057
public static final List<Object[]> BOOLEAN_PARAMETERIZED =
61-
Arrays.asList(new Object[][] {
62-
{false},
63-
{true}
64-
});
58+
Arrays.asList(new Object[][] { { false }, { true } });
6559

6660
/**
6761
* Compression algorithms to use in testing
6862
*/
69-
public static final Compression.Algorithm[] COMPRESSION_ALGORITHMS = {
70-
Compression.Algorithm.NONE, Compression.Algorithm.GZ
71-
};
63+
public static final Compression.Algorithm[] COMPRESSION_ALGORITHMS =
64+
{ Compression.Algorithm.NONE, Compression.Algorithm.GZ };
7265

7366
protected final Configuration conf;
7467

@@ -82,7 +75,6 @@ public HBaseCommonTestingUtil(Configuration conf) {
8275

8376
/**
8477
* Returns this classes's instance of {@link Configuration}.
85-
*
8678
* @return Instance of Configuration.
8779
*/
8880
public Configuration getConfiguration() {
@@ -92,8 +84,7 @@ public Configuration getConfiguration() {
9284
/**
9385
* System property key to get base test directory value
9486
*/
95-
public static final String BASE_TEST_DIRECTORY_KEY =
96-
"test.build.data.basedirectory";
87+
public static final String BASE_TEST_DIRECTORY_KEY = "test.build.data.basedirectory";
9788

9889
/**
9990
* Default base directory for test output.
@@ -127,13 +118,11 @@ public Path getDataTestDir(final String name) {
127118

128119
/**
129120
* Sets up a directory for a test to use.
130-
*
131121
* @return New directory path, if created.
132122
*/
133123
protected Path setupDataTestDir() {
134124
if (this.dataTestDir != null) {
135-
LOG.warn("Data test dir already setup in " +
136-
dataTestDir.getAbsolutePath());
125+
LOG.warn("Data test dir already setup in " + dataTestDir.getAbsolutePath());
137126
return null;
138127
}
139128
Path testPath = getRandomDir();
@@ -151,16 +140,15 @@ protected Path setupDataTestDir() {
151140
}
152141

153142
/**
154-
* Returns A dir with a random (uuid) name under the test dir
143+
* Returns a dir with a random (uuid) name under the test dir
155144
* @see #getBaseTestDir()
156145
*/
157146
public Path getRandomDir() {
158147
return new Path(getBaseTestDir(), getRandomUUID().toString());
159148
}
160149

161150
public static UUID getRandomUUID() {
162-
return new UUID(ThreadLocalRandom.current().nextLong(),
163-
ThreadLocalRandom.current().nextLong());
151+
return new UUID(ThreadLocalRandom.current().nextLong(), ThreadLocalRandom.current().nextLong());
164152
}
165153

166154
protected void createSubDir(String propertyName, Path parent, String subDirName) {
@@ -212,8 +200,7 @@ public boolean cleanupTestDir(final String subdir) {
212200
* @see #setupDataTestDir()
213201
*/
214202
private Path getBaseTestDir() {
215-
String PathName = System.getProperty(
216-
BASE_TEST_DIRECTORY_KEY, DEFAULT_BASE_TEST_DIRECTORY);
203+
String PathName = System.getProperty(BASE_TEST_DIRECTORY_KEY, DEFAULT_BASE_TEST_DIRECTORY);
217204

218205
return new Path(PathName);
219206
}
@@ -248,24 +235,23 @@ boolean deleteDir(final File dir) {
248235
/**
249236
* Wrapper method for {@link Waiter#waitFor(Configuration, long, Predicate)}.
250237
*/
251-
public <E extends Exception> long waitFor(long timeout, Predicate<E> predicate)
252-
throws E {
238+
public <E extends Exception> long waitFor(long timeout, Predicate<E> predicate) throws E {
253239
return Waiter.waitFor(this.conf, timeout, predicate);
254240
}
255241

256242
/**
257243
* Wrapper method for {@link Waiter#waitFor(Configuration, long, long, Predicate)}.
258244
*/
259245
public <E extends Exception> long waitFor(long timeout, long interval, Predicate<E> predicate)
260-
throws E {
246+
throws E {
261247
return Waiter.waitFor(this.conf, timeout, interval, predicate);
262248
}
263249

264250
/**
265251
* Wrapper method for {@link Waiter#waitFor(Configuration, long, long, boolean, Predicate)}.
266252
*/
267-
public <E extends Exception> long waitFor(long timeout, long interval,
268-
boolean failIfTimeout, Predicate<E> predicate) throws E {
253+
public <E extends Exception> long waitFor(long timeout, long interval, boolean failIfTimeout,
254+
Predicate<E> predicate) throws E {
269255
return Waiter.waitFor(this.conf, timeout, interval, failIfTimeout, predicate);
270256
}
271257

@@ -331,12 +317,11 @@ public int randomFreePort() {
331317
}
332318

333319
/**
334-
* Returns a random port. These ports cannot be registered with IANA and are
335-
* intended for dynamic allocation (see http://bit.ly/dynports).
320+
* Returns a random port. These ports cannot be registered with IANA and are intended for
321+
* dynamic allocation (see http://bit.ly/dynports).
336322
*/
337323
private int randomPort() {
338-
return MIN_RANDOM_PORT
339-
+ random.nextInt(MAX_RANDOM_PORT - MIN_RANDOM_PORT);
324+
return MIN_RANDOM_PORT + random.nextInt(MAX_RANDOM_PORT - MIN_RANDOM_PORT);
340325
}
341326

342327
interface AvailablePortChecker {

hbase-it/src/test/java/org/apache/hadoop/hbase/mapreduce/IntegrationTestBulkLoad.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private void installSlowingCoproc() throws IOException, InterruptedException {
211211
TableDescriptor desc = admin.getDescriptor(t);
212212
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(desc);
213213
builder.setCoprocessor(SlowMeCoproScanOperations.class.getName());
214-
HBaseTestingUtil.modifyTableSync(admin, builder.build());
214+
admin.modifyTable(builder.build());
215215
}
216216

217217
@Test

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatTestBase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.hadoop.hbase.client.Scan;
3838
import org.apache.hadoop.hbase.client.Table;
3939
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
40+
import org.apache.hadoop.hbase.logging.Log4jUtils;
4041
import org.apache.hadoop.hbase.util.Bytes;
4142
import org.apache.hadoop.io.NullWritable;
4243
import org.apache.hadoop.mapreduce.Job;
@@ -73,7 +74,7 @@ public abstract class MultiTableInputFormatTestBase {
7374
@BeforeClass
7475
public static void setUpBeforeClass() throws Exception {
7576
// switch TIF to log at DEBUG level
76-
TEST_UTIL.enableDebug(MultiTableInputFormatBase.class);
77+
Log4jUtils.enableDebug(MultiTableInputFormatBase.class);
7778
// start mini hbase cluster
7879
TEST_UTIL.startMiniCluster(3);
7980
// create and fill table

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableInputFormat.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.hadoop.hbase.HBaseClassTestRule;
2323
import org.apache.hadoop.hbase.client.Scan;
2424
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
25+
import org.apache.hadoop.hbase.logging.Log4jUtils;
2526
import org.apache.hadoop.hbase.testclassification.LargeTests;
2627
import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
2728
import org.apache.hadoop.mapreduce.Job;
@@ -43,8 +44,8 @@ public class TestMultiTableInputFormat extends MultiTableInputFormatTestBase {
4344

4445
@BeforeClass
4546
public static void setupLogging() {
46-
TEST_UTIL.enableDebug(MultiTableInputFormat.class);
47-
}
47+
Log4jUtils.enableDebug(MultiTableInputFormat.class);
48+
}
4849

4950
@Override
5051
protected void initJob(List<Scan> scans, Job job) throws IOException {

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestMultiTableSnapshotInputFormat.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.hadoop.hbase.TableName;
2828
import org.apache.hadoop.hbase.client.Scan;
2929
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
30+
import org.apache.hadoop.hbase.logging.Log4jUtils;
3031
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
3132
import org.apache.hadoop.hbase.testclassification.LargeTests;
3233
import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
@@ -53,8 +54,8 @@ public class TestMultiTableSnapshotInputFormat extends MultiTableInputFormatTest
5354

5455
@BeforeClass
5556
public static void setUpSnapshots() throws Exception {
56-
TEST_UTIL.enableDebug(MultiTableSnapshotInputFormat.class);
57-
TEST_UTIL.enableDebug(MultiTableSnapshotInputFormatImpl.class);
57+
Log4jUtils.enableDebug(MultiTableSnapshotInputFormat.class);
58+
Log4jUtils.enableDebug(MultiTableSnapshotInputFormatImpl.class);
5859

5960
// take a snapshot of every table we have.
6061
for (String tableName : TABLES) {

0 commit comments

Comments
 (0)