Skip to content

HBASE-26096 Cleanup the deprecated methods in HBTU related classes and format code #3503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2021
Merged
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 @@ -49,26 +49,19 @@ public class HBaseCommonTestingUtil {
* Compression algorithms to use in parameterized JUnit 4 tests
*/
public static final List<Object[]> COMPRESSION_ALGORITHMS_PARAMETERIZED =
Arrays.asList(new Object[][] {
{ Compression.Algorithm.NONE },
{ Compression.Algorithm.GZ }
});
Arrays.asList(new Object[][] { { Compression.Algorithm.NONE }, { Compression.Algorithm.GZ } });

/**
* This is for unit tests parameterized with a two booleans.
*/
public static final List<Object[]> BOOLEAN_PARAMETERIZED =
Arrays.asList(new Object[][] {
{false},
{true}
});
Arrays.asList(new Object[][] { { false }, { true } });

/**
* Compression algorithms to use in testing
*/
public static final Compression.Algorithm[] COMPRESSION_ALGORITHMS = {
Compression.Algorithm.NONE, Compression.Algorithm.GZ
};
public static final Compression.Algorithm[] COMPRESSION_ALGORITHMS =
{ Compression.Algorithm.NONE, Compression.Algorithm.GZ };

protected final Configuration conf;

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

/**
* Returns this classes's instance of {@link Configuration}.
*
* @return Instance of Configuration.
*/
public Configuration getConfiguration() {
Expand All @@ -92,8 +84,7 @@ public Configuration getConfiguration() {
/**
* System property key to get base test directory value
*/
public static final String BASE_TEST_DIRECTORY_KEY =
"test.build.data.basedirectory";
public static final String BASE_TEST_DIRECTORY_KEY = "test.build.data.basedirectory";

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

/**
* Sets up a directory for a test to use.
*
* @return New directory path, if created.
*/
protected Path setupDataTestDir() {
if (this.dataTestDir != null) {
LOG.warn("Data test dir already setup in " +
dataTestDir.getAbsolutePath());
LOG.warn("Data test dir already setup in " + dataTestDir.getAbsolutePath());
return null;
}
Path testPath = getRandomDir();
Expand All @@ -151,16 +140,15 @@ protected Path setupDataTestDir() {
}

/**
* Returns A dir with a random (uuid) name under the test dir
* Returns a dir with a random (uuid) name under the test dir
* @see #getBaseTestDir()
*/
public Path getRandomDir() {
return new Path(getBaseTestDir(), getRandomUUID().toString());
}

public static UUID getRandomUUID() {
return new UUID(ThreadLocalRandom.current().nextLong(),
ThreadLocalRandom.current().nextLong());
return new UUID(ThreadLocalRandom.current().nextLong(), ThreadLocalRandom.current().nextLong());
}

protected void createSubDir(String propertyName, Path parent, String subDirName) {
Expand Down Expand Up @@ -212,8 +200,7 @@ public boolean cleanupTestDir(final String subdir) {
* @see #setupDataTestDir()
*/
private Path getBaseTestDir() {
String PathName = System.getProperty(
BASE_TEST_DIRECTORY_KEY, DEFAULT_BASE_TEST_DIRECTORY);
String PathName = System.getProperty(BASE_TEST_DIRECTORY_KEY, DEFAULT_BASE_TEST_DIRECTORY);

return new Path(PathName);
}
Expand Down Expand Up @@ -248,24 +235,23 @@ boolean deleteDir(final File dir) {
/**
* Wrapper method for {@link Waiter#waitFor(Configuration, long, Predicate)}.
*/
public <E extends Exception> long waitFor(long timeout, Predicate<E> predicate)
throws E {
public <E extends Exception> long waitFor(long timeout, Predicate<E> predicate) throws E {
return Waiter.waitFor(this.conf, timeout, predicate);
}

/**
* Wrapper method for {@link Waiter#waitFor(Configuration, long, long, Predicate)}.
*/
public <E extends Exception> long waitFor(long timeout, long interval, Predicate<E> predicate)
throws E {
throws E {
return Waiter.waitFor(this.conf, timeout, interval, predicate);
}

/**
* Wrapper method for {@link Waiter#waitFor(Configuration, long, long, boolean, Predicate)}.
*/
public <E extends Exception> long waitFor(long timeout, long interval,
boolean failIfTimeout, Predicate<E> predicate) throws E {
public <E extends Exception> long waitFor(long timeout, long interval, boolean failIfTimeout,
Predicate<E> predicate) throws E {
return Waiter.waitFor(this.conf, timeout, interval, failIfTimeout, predicate);
}

Expand Down Expand Up @@ -331,12 +317,11 @@ public int randomFreePort() {
}

/**
* Returns a random port. These ports cannot be registered with IANA and are
* intended for dynamic allocation (see http://bit.ly/dynports).
* Returns a random port. These ports cannot be registered with IANA and are intended for
* dynamic allocation (see http://bit.ly/dynports).
*/
private int randomPort() {
return MIN_RANDOM_PORT
+ random.nextInt(MAX_RANDOM_PORT - MIN_RANDOM_PORT);
return MIN_RANDOM_PORT + random.nextInt(MAX_RANDOM_PORT - MIN_RANDOM_PORT);
}

interface AvailablePortChecker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private void installSlowingCoproc() throws IOException, InterruptedException {
TableDescriptor desc = admin.getDescriptor(t);
TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(desc);
builder.setCoprocessor(SlowMeCoproScanOperations.class.getName());
HBaseTestingUtil.modifyTableSync(admin, builder.build());
admin.modifyTable(builder.build());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.logging.Log4jUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
Expand Down Expand Up @@ -73,7 +74,7 @@ public abstract class MultiTableInputFormatTestBase {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
// switch TIF to log at DEBUG level
TEST_UTIL.enableDebug(MultiTableInputFormatBase.class);
Log4jUtils.enableDebug(MultiTableInputFormatBase.class);
// start mini hbase cluster
TEST_UTIL.startMiniCluster(3);
// create and fill table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.logging.Log4jUtils;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
import org.apache.hadoop.mapreduce.Job;
Expand All @@ -43,8 +44,8 @@ public class TestMultiTableInputFormat extends MultiTableInputFormatTestBase {

@BeforeClass
public static void setupLogging() {
TEST_UTIL.enableDebug(MultiTableInputFormat.class);
}
Log4jUtils.enableDebug(MultiTableInputFormat.class);
}

@Override
protected void initJob(List<Scan> scans, Job job) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.logging.Log4jUtils;
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
Expand All @@ -53,8 +54,8 @@ public class TestMultiTableSnapshotInputFormat extends MultiTableInputFormatTest

@BeforeClass
public static void setUpSnapshots() throws Exception {
TEST_UTIL.enableDebug(MultiTableSnapshotInputFormat.class);
TEST_UTIL.enableDebug(MultiTableSnapshotInputFormatImpl.class);
Log4jUtils.enableDebug(MultiTableSnapshotInputFormat.class);
Log4jUtils.enableDebug(MultiTableSnapshotInputFormatImpl.class);

// take a snapshot of every table we have.
for (String tableName : TABLES) {
Expand Down
Loading