From eb361fc33d333b257c50ddbbcf4de8656bebadd0 Mon Sep 17 00:00:00 2001 From: stack Date: Tue, 30 Sep 2014 16:35:55 -0700 Subject: [PATCH] HBASE-12038 Replace internal uses of signatures with byte[] and String tableNames to use the TableName equivalents (Solomon Duskis) Conflicts: hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaAdmin.java hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaTableUtil.java hbase-server/src/test/java/org/apache/hadoop/hbase/quotas/TestQuotaThrottle.java --- .../hadoop/hbase/client/HTableFactory.java | 3 +- .../security/access/AccessControlClient.java | 6 ++-- .../security/visibility/VisibilityClient.java | 6 ++-- .../example/TestBulkDeleteProtocol.java | 26 ++++++++-------- .../example/TestRowCountEndpoint.java | 4 +-- .../hbase/mapred/HRegionPartitioner.java | 3 +- .../hadoop/hbase/mapred/TableInputFormat.java | 4 ++- .../hbase/mapred/TableOutputFormat.java | 3 +- .../mapreduce/MultiTableInputFormatBase.java | 7 +++-- .../mapreduce/MultiTableOutputFormat.java | 3 +- .../hbase/mapreduce/TableMapReduceUtil.java | 30 +++++++++++++++++++ .../org/apache/hadoop/hbase/tool/Canary.java | 4 +-- .../hadoop/hbase/util/RegionSplitter.java | 8 ++--- .../hadoop/hbase/HBaseTestingUtility.java | 16 +++++----- .../hadoop/hbase/TestAcidGuarantees.java | 2 +- .../hadoop/hbase/TestMultiVersions.java | 4 +-- .../apache/hadoop/hbase/client/TestAdmin.java | 20 ++++++------- .../hbase/client/TestFromClientSide.java | 7 ++--- .../apache/hadoop/hbase/client/TestHCM.java | 18 +++++------ .../hadoop/hbase/client/TestHTablePool.java | 24 +++++++-------- .../hbase/client/TestMultiParallel.java | 2 +- .../hbase/coprocessor/TestClassLoading.java | 2 +- .../filter/TestFilterWithScanLimits.java | 4 +-- .../hbase/filter/TestFilterWrapper.java | 4 +-- .../mapreduce/TestHFileOutputFormat.java | 6 ++-- .../mapreduce/TestHFileOutputFormat2.java | 4 +-- .../TestSecureLoadIncrementalHFiles.java | 2 +- ...ureLoadIncrementalHFilesSplitRecovery.java | 2 +- .../mapreduce/TestTableMapReduceBase.java | 2 +- .../hbase/mapreduce/TestTimeRangeMapRed.java | 6 ++-- ...TestMasterOperationsForRegionReplicas.java | 8 ++--- .../hbase/master/TestRegionPlacement.java | 6 ++-- .../hbase/master/TestRestartCluster.java | 6 ++-- .../hbase/master/TestTableLockManager.java | 1 + .../TestEncryptionKeyRotation.java | 2 +- .../regionserver/TestFSErrorsExposed.java | 4 +-- .../regionserver/TestJoinedScanners.java | 4 +-- .../replication/TestMasterReplication.java | 6 ++-- .../TestMultiSlaveReplication.java | 4 +-- .../TestPerTableCFReplication.java | 10 +++---- .../replication/TestReplicationBase.java | 4 +-- .../TestReplicationSmallTests.java | 2 +- .../TestReplicationSyncUpTool.java | 12 ++++---- .../replication/TestReplicationWithTags.java | 4 +-- .../hbase/security/access/SecureTestUtil.java | 6 ++-- .../security/access/TestAccessController.java | 4 +-- .../access/TestAccessController2.java | 4 +-- .../TestCellACLWithMultipleVersions.java | 4 +-- .../hbase/security/access/TestCellACLs.java | 4 +-- .../access/TestScanEarlyTermination.java | 4 +-- .../security/access/TestTablePermissions.java | 2 +- .../TestVisibilityLabelsWithACL.java | 8 ++--- ...ilityLabelsWithDefaultVisLabelService.java | 2 +- .../snapshot/TestSecureExportSnapshot.java | 2 +- .../hbase/util/TestProcessBasedCluster.java | 2 +- .../hadoop/hbase/util/TestRegionSplitter.java | 6 ++-- 56 files changed, 195 insertions(+), 158 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java index c38c386d5a1..d053e66a38e 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTableFactory.java @@ -18,6 +18,7 @@ */ package org.apache.hadoop.hbase.client; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -37,7 +38,7 @@ public class HTableFactory implements HTableInterfaceFactory { public HTableInterface createHTableInterface(Configuration config, byte[] tableName) { try { - return new HTable(config, tableName); + return new HTable(config, TableName.valueOf(tableName)); } catch (IOException ioe) { throw new RuntimeException(ioe); } diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java index a2afe55c001..6a743da409f 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlClient.java @@ -76,7 +76,7 @@ public class AccessControlClient { try { TableName aclTableName = TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl"); - ht = new HTable(conf, aclTableName.getName()); + ht = new HTable(conf, aclTableName); Batch.Call callable = new Batch.Call() { ServerRpcController controller = new ServerRpcController(); @@ -156,7 +156,7 @@ public class AccessControlClient { try { TableName aclTableName = TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl"); - ht = new HTable(conf, aclTableName.getName()); + ht = new HTable(conf, aclTableName); Batch.Call callable = new Batch.Call() { ServerRpcController controller = new ServerRpcController(); @@ -219,7 +219,7 @@ public class AccessControlClient { TableName aclTableName = TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl"); ha = new HBaseAdmin(conf); - ht = new HTable(conf, aclTableName.getName()); + ht = new HTable(conf, aclTableName); CoprocessorRpcChannel service = ht.coprocessorService(HConstants.EMPTY_START_ROW); BlockingInterface protocol = AccessControlProtos.AccessControlService.newBlockingStub(service); diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java index a56ddc3c00f..6ac1d3f395c 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityClient.java @@ -75,7 +75,7 @@ public class VisibilityClient { throws Throwable { Table ht = null; try { - ht = new HTable(conf, LABELS_TABLE_NAME.getName()); + ht = new HTable(conf, LABELS_TABLE_NAME); Batch.Call callable = new Batch.Call() { ServerRpcController controller = new ServerRpcController(); @@ -129,7 +129,7 @@ public class VisibilityClient { public static GetAuthsResponse getAuths(Configuration conf, final String user) throws Throwable { Table ht = null; try { - ht = new HTable(conf, LABELS_TABLE_NAME.getName()); + ht = new HTable(conf, LABELS_TABLE_NAME); Batch.Call callable = new Batch.Call() { ServerRpcController controller = new ServerRpcController(); @@ -171,7 +171,7 @@ public class VisibilityClient { final String user, final boolean setOrClear) throws IOException, ServiceException, Throwable { Table ht = null; try { - ht = new HTable(conf, LABELS_TABLE_NAME.getName()); + ht = new HTable(conf, LABELS_TABLE_NAME); Batch.Call callable = new Batch.Call() { ServerRpcController controller = new ServerRpcController(); diff --git a/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestBulkDeleteProtocol.java b/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestBulkDeleteProtocol.java index 16327ba5f38..2da2fb92134 100644 --- a/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestBulkDeleteProtocol.java +++ b/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestBulkDeleteProtocol.java @@ -78,7 +78,7 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteEndpoint() throws Throwable { - byte[] tableName = Bytes.toBytes("testBulkDeleteEndpoint"); + TableName tableName = TableName.valueOf("testBulkDeleteEndpoint"); Table ht = createTable(tableName); List puts = new ArrayList(100); for (int j = 0; j < 100; j++) { @@ -101,8 +101,8 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteEndpointWhenRowBatchSizeLessThanRowsToDeleteFromARegion() throws Throwable { - byte[] tableName = Bytes - .toBytes("testBulkDeleteEndpointWhenRowBatchSizeLessThanRowsToDeleteFromARegion"); + TableName tableName = TableName + .valueOf("testBulkDeleteEndpointWhenRowBatchSizeLessThanRowsToDeleteFromARegion"); Table ht = createTable(tableName); List puts = new ArrayList(100); for (int j = 0; j < 100; j++) { @@ -122,7 +122,7 @@ public class TestBulkDeleteProtocol { ht.close(); } - private long invokeBulkDeleteProtocol(byte[] tableName, final Scan scan, final int rowBatchSize, + private long invokeBulkDeleteProtocol(TableName tableName, final Scan scan, final int rowBatchSize, final DeleteType deleteType, final Long timeStamp) throws Throwable { Table ht = new HTable(TEST_UTIL.getConfiguration(), tableName); long noOfDeletedRows = 0L; @@ -155,7 +155,7 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteWithConditionBasedDelete() throws Throwable { - byte[] tableName = Bytes.toBytes("testBulkDeleteWithConditionBasedDelete"); + TableName tableName = TableName.valueOf("testBulkDeleteWithConditionBasedDelete"); Table ht = createTable(tableName); List puts = new ArrayList(100); for (int j = 0; j < 100; j++) { @@ -185,7 +185,7 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteColumn() throws Throwable { - byte[] tableName = Bytes.toBytes("testBulkDeleteColumn"); + TableName tableName = TableName.valueOf("testBulkDeleteColumn"); Table ht = createTable(tableName); List puts = new ArrayList(100); for (int j = 0; j < 100; j++) { @@ -214,8 +214,8 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteFamily() throws Throwable { - byte[] tableName = Bytes.toBytes("testBulkDeleteFamily"); - HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); + TableName tableName = TableName.valueOf("testBulkDeleteFamily"); + HTableDescriptor htd = new HTableDescriptor(tableName); htd.addFamily(new HColumnDescriptor(FAMILY1)); htd.addFamily(new HColumnDescriptor(FAMILY2)); TEST_UTIL.getHBaseAdmin().createTable(htd, Bytes.toBytes(0), Bytes.toBytes(120), 5); @@ -245,7 +245,7 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteColumnVersion() throws Throwable { - byte[] tableName = Bytes.toBytes("testBulkDeleteColumnVersion"); + TableName tableName = TableName.valueOf("testBulkDeleteColumnVersion"); Table ht = createTable(tableName); List puts = new ArrayList(100); for (int j = 0; j < 100; j++) { @@ -293,7 +293,7 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteColumnVersionBasedOnTS() throws Throwable { - byte[] tableName = Bytes.toBytes("testBulkDeleteColumnVersionBasedOnTS"); + TableName tableName = TableName.valueOf("testBulkDeleteColumnVersionBasedOnTS"); Table ht = createTable(tableName); List puts = new ArrayList(100); for (int j = 0; j < 100; j++) { @@ -340,7 +340,7 @@ public class TestBulkDeleteProtocol { // @Ignore @Test public void testBulkDeleteWithNumberOfVersions() throws Throwable { - byte[] tableName = Bytes.toBytes("testBulkDeleteWithNumberOfVersions"); + TableName tableName = TableName.valueOf("testBulkDeleteWithNumberOfVersions"); Table ht = createTable(tableName); List puts = new ArrayList(100); for (int j = 0; j < 100; j++) { @@ -423,8 +423,8 @@ public class TestBulkDeleteProtocol { ht.close(); } - private Table createTable(byte[] tableName) throws IOException { - HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); + private Table createTable(TableName tableName) throws IOException { + HTableDescriptor htd = new HTableDescriptor(tableName); HColumnDescriptor hcd = new HColumnDescriptor(FAMILY1); hcd.setMaxVersions(10);// Just setting 10 as I am not testing with more than 10 versions here htd.addFamily(hcd); diff --git a/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestRowCountEndpoint.java b/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestRowCountEndpoint.java index 01a9aa57eed..887be8698df 100644 --- a/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestRowCountEndpoint.java +++ b/hbase-examples/src/test/java/org/apache/hadoop/hbase/coprocessor/example/TestRowCountEndpoint.java @@ -45,7 +45,7 @@ import static junit.framework.Assert.*; */ @Category(MediumTests.class) public class TestRowCountEndpoint { - private static final byte[] TEST_TABLE = Bytes.toBytes("testrowcounter"); + private static final TableName TEST_TABLE = TableName.valueOf("testrowcounter"); private static final byte[] TEST_FAMILY = Bytes.toBytes("f"); private static final byte[] TEST_COLUMN = Bytes.toBytes("col"); @@ -60,7 +60,7 @@ public class TestRowCountEndpoint { RowCountEndpoint.class.getName()); TEST_UTIL.startMiniCluster(); - TEST_UTIL.createTable(TableName.valueOf(TEST_TABLE), new byte[][]{TEST_FAMILY}); + TEST_UTIL.createTable(TEST_TABLE, new byte[][]{TEST_FAMILY}); } // @Ignore @AfterClass diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java index 60a2c994960..11acea03d96 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/HRegionPartitioner.java @@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.io.ImmutableBytesWritable; @@ -52,7 +53,7 @@ implements Partitioner { public void configure(JobConf job) { try { this.table = new HTable(HBaseConfiguration.create(job), - job.get(TableOutputFormat.OUTPUT_TABLE)); + TableName.valueOf(job.get(TableOutputFormat.OUTPUT_TABLE))); } catch (IOException e) { LOG.error(e); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java index 6c96f862247..e1220fbc18d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableInputFormat.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.fs.Path; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.mapred.FileInputFormat; @@ -57,7 +58,8 @@ public class TableInputFormat extends TableInputFormatBase implements } setInputColumns(m_cols); try { - setHTable(new HTable(HBaseConfiguration.create(job), tableNames[0].getName())); + setHTable( + new HTable(HBaseConfiguration.create(job), TableName.valueOf(tableNames[0].getName()))); } catch (Exception e) { LOG.error(StringUtils.stringifyException(e)); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java index 0f7cdedf7cb..5a5f5447ccd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableOutputFormat.java @@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Table; @@ -85,7 +86,7 @@ FileOutputFormat { // expecting exactly one path - String tableName = job.get(OUTPUT_TABLE); + TableName tableName = TableName.valueOf(job.get(OUTPUT_TABLE)); HTable table = null; try { table = new HTable(HBaseConfiguration.create(job), tableName); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java index 761c46ffb79..20169e06c26 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableInputFormatBase.java @@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Scan; @@ -80,13 +81,13 @@ public abstract class MultiTableInputFormatBase extends TableSplit tSplit = (TableSplit) split; LOG.info(MessageFormat.format("Input split length: {0} bytes.", tSplit.getLength())); - if (tSplit.getTableName() == null) { + if (tSplit.getTable() == null) { throw new IOException("Cannot create a record reader because of a" + " previous error. Please look at the previous logs lines from" + " the task's full log for more details."); } Table table = - new HTable(context.getConfiguration(), tSplit.getTableName()); + new HTable(context.getConfiguration(), tSplit.getTable()); TableRecordReader trr = this.tableRecordReader; @@ -133,7 +134,7 @@ public abstract class MultiTableInputFormatBase extends HTable table = null; try { - table = new HTable(context.getConfiguration(), tableName); + table = new HTable(context.getConfiguration(), TableName.valueOf(tableName)); Pair keys = table.getStartEndKeys(); if (keys == null || keys.getFirst() == null || keys.getFirst().length == 0) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java index 5902a8e072c..c1d837358e6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/MultiTableOutputFormat.java @@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Mutation; @@ -102,7 +103,7 @@ public class MultiTableOutputFormat extends OutputFormat mapper, + Class outputKeyClass, + Class outputValueClass, + Job job) throws IOException { + initTableMapperJob(table.getNameAsString(), + scan, + mapper, + outputKeyClass, + outputValueClass, + job, + true); + } + /** * Use this before submitting a TableMap job. It will appropriately set up * the job. diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java index d5cdb391ce4..e6e975f165b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java @@ -480,7 +480,7 @@ public final class Canary implements Tool { Table table = null; try { - table = new HTable(admin.getConfiguration(), tableDesc.getName()); + table = new HTable(admin.getConfiguration(), tableDesc.getTableName()); } catch (TableNotFoundException e) { return; } @@ -679,7 +679,7 @@ public final class Canary implements Tool { HTableDescriptor[] tableDescs = this.admin.listTables(); List regions = null; for (HTableDescriptor tableDesc : tableDescs) { - table = new HTable(this.admin.getConfiguration(), tableDesc.getName()); + table = new HTable(this.admin.getConfiguration(), tableDesc.getTableName()); for (Map.Entry entry : table .getRegionLocations().entrySet()) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java index 9055e5174e5..483da8f7a56 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java @@ -339,7 +339,7 @@ public class RegionSplitter { "UniformSplit treats keys as arbitrary bytes.", opt); return; } - String tableName = cmd.getArgs()[0]; + TableName tableName = TableName.valueOf(cmd.getArgs()[0]); String splitClass = cmd.getArgs()[1]; SplitAlgorithm splitAlgo = newSplitAlgoInstance(conf, splitClass); @@ -363,7 +363,7 @@ public class RegionSplitter { } } - static void createPresplitTable(String tableName, SplitAlgorithm splitAlgo, + static void createPresplitTable(TableName tableName, SplitAlgorithm splitAlgo, String[] columnFamilies, Configuration conf) throws IOException, InterruptedException { final int splitCount = conf.getInt("split.count", 0); @@ -374,7 +374,7 @@ public class RegionSplitter { LOG.debug("Creating table " + tableName + " with " + columnFamilies.length + " column families. Presplitting to " + splitCount + " regions"); - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + HTableDescriptor desc = new HTableDescriptor(tableName); for (String cf : columnFamilies) { desc.addFamily(new HColumnDescriptor(Bytes.toBytes(cf))); } @@ -399,7 +399,7 @@ public class RegionSplitter { LOG.debug("Finished creating table with " + splitCount + " regions"); } - static void rollingSplit(String tableName, SplitAlgorithm splitAlgo, + static void rollingSplit(TableName tableName, SplitAlgorithm splitAlgo, Configuration conf) throws IOException, InterruptedException { final int minOS = conf.getInt("split.outstanding", 2); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 8cd2e1518d5..9853e5b31a0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -1231,7 +1231,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { desc.addFamily(hcd); } getHBaseAdmin().createTable(desc); - return new HTable(c, tableName); + return new HTable(c, desc.getTableName()); } /** @@ -1277,7 +1277,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { desc.addFamily(hcd); } getHBaseAdmin().createTable(desc); - return new HTable(c, tableName); + return new HTable(c, desc.getTableName()); } /** @@ -1467,8 +1467,8 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { } getHBaseAdmin().createTable(desc, splitRows); // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are assigned - waitUntilAllRegionsAssigned(TableName.valueOf(tableName)); - return new HTable(getConfiguration(), tableName); + waitUntilAllRegionsAssigned(desc.getTableName()); + return new HTable(getConfiguration(), desc.getTableName()); } /** @@ -2634,9 +2634,9 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { * @throws InterruptedException * @throws IOException */ - public void waitTableAvailable(byte[] table) + public void waitTableAvailable(TableName table) throws InterruptedException, IOException { - waitTableAvailable(getHBaseAdmin(), table, 30000); + waitTableAvailable(getHBaseAdmin(), table.getName(), 30000); } public void waitTableAvailable(Admin admin, byte[] table) @@ -2676,9 +2676,9 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { * @throws InterruptedException * @throws IOException */ - public void waitTableEnabled(byte[] table) + public void waitTableEnabled(TableName table) throws InterruptedException, IOException { - waitTableEnabled(getHBaseAdmin(), table, 30000); + waitTableEnabled(getHBaseAdmin(), table.getName(), 30000); } public void waitTableEnabled(Admin admin, byte[] table) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java index 172395a73be..270c08fff73 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java @@ -56,7 +56,7 @@ import com.google.common.collect.Lists; @Category(MediumTests.class) public class TestAcidGuarantees implements Tool { protected static final Log LOG = LogFactory.getLog(TestAcidGuarantees.class); - public static final byte [] TABLE_NAME = Bytes.toBytes("TestAcidGuarantees"); + public static final TableName TABLE_NAME = TableName.valueOf("TestAcidGuarantees"); public static final byte [] FAMILY_A = Bytes.toBytes("A"); public static final byte [] FAMILY_B = Bytes.toBytes("B"); public static final byte [] FAMILY_C = Bytes.toBytes("C"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMultiVersions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMultiVersions.java index 08835aa2789..07de07eda18 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMultiVersions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestMultiVersions.java @@ -195,8 +195,8 @@ public class TestMultiVersions { */ @Test public void testScanMultipleVersions() throws Exception { - final byte [] tableName = Bytes.toBytes("testScanMultipleVersions"); - final HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + final TableName tableName = TableName.valueOf("testScanMultipleVersions"); + final HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); final byte [][] rows = new byte[][] { Bytes.toBytes("row_0200"), diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java index 04bd466d1d8..e443ebb767e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java @@ -611,8 +611,8 @@ public class TestAdmin { @Test (timeout=300000) public void testCreateTableNumberOfRegions() throws IOException, InterruptedException { - byte[] tableName = Bytes.toBytes("testCreateTableNumberOfRegions"); - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + TableName tableName = TableName.valueOf("testCreateTableNumberOfRegions"); + HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc); HTable ht = new HTable(TEST_UTIL.getConfiguration(), tableName); @@ -620,8 +620,8 @@ public class TestAdmin { assertEquals("Table should have only 1 region", 1, regions.size()); ht.close(); - byte [] TABLE_2 = Bytes.add(tableName, Bytes.toBytes("_2")); - desc = new HTableDescriptor(TableName.valueOf(TABLE_2)); + TableName TABLE_2 = TableName.valueOf(tableName.getNameAsString() + "_2"); + desc = new HTableDescriptor(TABLE_2); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, new byte[][]{new byte[]{42}}); HTable ht2 = new HTable(TEST_UTIL.getConfiguration(), TABLE_2); @@ -629,8 +629,8 @@ public class TestAdmin { assertEquals("Table should have only 2 region", 2, regions.size()); ht2.close(); - byte [] TABLE_3 = Bytes.add(tableName, Bytes.toBytes("_3")); - desc = new HTableDescriptor(TableName.valueOf(TABLE_3)); + TableName TABLE_3 = TableName.valueOf(tableName.getNameAsString() + "_3"); + desc = new HTableDescriptor(TABLE_3); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, "a".getBytes(), "z".getBytes(), 3); HTable ht3 = new HTable(TEST_UTIL.getConfiguration(), TABLE_3); @@ -638,8 +638,8 @@ public class TestAdmin { assertEquals("Table should have only 3 region", 3, regions.size()); ht3.close(); - byte [] TABLE_4 = Bytes.add(tableName, Bytes.toBytes("_4")); - desc = new HTableDescriptor(TableName.valueOf(TABLE_4)); + TableName TABLE_4 = TableName.valueOf(tableName.getNameAsString() + "_4"); + desc = new HTableDescriptor(TABLE_4); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); try { admin.createTable(desc, "a".getBytes(), "z".getBytes(), 2); @@ -648,8 +648,8 @@ public class TestAdmin { // Expected } - byte [] TABLE_5 = Bytes.add(tableName, Bytes.toBytes("_5")); - desc = new HTableDescriptor(TableName.valueOf(TABLE_5)); + TableName TABLE_5 = TableName.valueOf(tableName.getNameAsString() + "_5"); + desc = new HTableDescriptor(TABLE_5); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, new byte[] {1}, new byte[] {127}, 16); HTable ht5 = new HTable(TEST_UTIL.getConfiguration(), TABLE_5); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java index 22d2e3906d1..94653454a21 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java @@ -171,7 +171,7 @@ public class TestFromClientSide { */ @Test public void testKeepDeletedCells() throws Exception { - final byte[] TABLENAME = Bytes.toBytes("testKeepDeletesCells"); + final TableName TABLENAME = TableName.valueOf("testKeepDeletesCells"); final byte[] FAMILY = Bytes.toBytes("family"); final byte[] C0 = Bytes.toBytes("c0"); @@ -399,7 +399,7 @@ public class TestFromClientSide { */ @Test public void testWeirdCacheBehaviour() throws Exception { - byte [] TABLE = Bytes.toBytes("testWeirdCacheBehaviour"); + TableName TABLE = TableName.valueOf("testWeirdCacheBehaviour"); byte [][] FAMILIES = new byte[][] { Bytes.toBytes("trans-blob"), Bytes.toBytes("trans-type"), Bytes.toBytes("trans-date"), Bytes.toBytes("trans-tags"), Bytes.toBytes("trans-group") }; @@ -4208,8 +4208,7 @@ public class TestFromClientSide { // Test that attribute changes were applied desc = a.getTableDescriptor(); - assertTrue("wrong table descriptor returned", - desc.getTableName().equals(tableAname)); + assertEquals("wrong table descriptor returned", desc.getTableName(), tableAname); // check HTD attribute value = desc.getValue(attrName); assertFalse("missing HTD attribute value", value == null); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java index ed26e73558d..798b393e5b2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java @@ -235,7 +235,7 @@ public class TestHCM { final ServerName sn = rs.getRegionServer().getServerName(); HTable t = TEST_UTIL.createTable(tn, cf); - TEST_UTIL.waitTableAvailable(tn.getName()); + TEST_UTIL.waitTableAvailable(tn); while(TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager(). getRegionStates().isRegionsInTransition()){ @@ -332,8 +332,8 @@ public class TestHCM { private void testConnectionClose(boolean allowsInterrupt) throws Exception { - String tableName = "HCM-testConnectionClose" + allowsInterrupt; - TEST_UTIL.createTable(tableName.getBytes(), FAM_NAM).close(); + TableName tableName = TableName.valueOf("HCM-testConnectionClose" + allowsInterrupt); + TEST_UTIL.createTable(tableName, FAM_NAM).close(); boolean previousBalance = TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, true); @@ -345,7 +345,7 @@ public class TestHCM { c2.setInt(RpcClient.FAILED_SERVER_EXPIRY_KEY, 0); // Server do not really expire c2.setBoolean(RpcClient.SPECIFIC_WRITE_THREAD, allowsInterrupt); - final HTable table = new HTable(c2, tableName.getBytes()); + final HTable table = new HTable(c2, tableName); Put put = new Put(ROW); put.add(FAM_NAM, ROW, ROW); @@ -414,8 +414,8 @@ public class TestHCM { */ @Test public void testConnectionIdle() throws Exception { - String tableName = "HCM-testConnectionIdle"; - TEST_UTIL.createTable(tableName.getBytes(), FAM_NAM).close(); + TableName tableName = TableName.valueOf("HCM-testConnectionIdle"); + TEST_UTIL.createTable(tableName, FAM_NAM).close(); int idleTime = 20000; boolean previousBalance = TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, true); @@ -425,7 +425,7 @@ public class TestHCM { c2.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1); // Don't retry: retry = test failed c2.setInt(RpcClient.IDLE_TIME, idleTime); - final Table table = new HTable(c2, tableName.getBytes()); + final Table table = new HTable(c2, tableName); Put put = new Put(ROW); put.add(FAM_NAM, ROW, ROW); @@ -477,9 +477,9 @@ public class TestHCM { return; } - String tableName = "HCM-testConnectionCut"; + TableName tableName = TableName.valueOf("HCM-testConnectionCut"); - TEST_UTIL.createTable(tableName.getBytes(), FAM_NAM).close(); + TEST_UTIL.createTable(tableName, FAM_NAM).close(); boolean previousBalance = TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, true); Configuration c2 = new Configuration(TEST_UTIL.getConfiguration()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTablePool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTablePool.java index cf6ea921f37..3b31789fe67 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTablePool.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHTablePool.java @@ -40,14 +40,14 @@ import org.junit.runners.Suite; @Category(MediumTests.class) public class TestHTablePool { private static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); - private final static byte[] TABLENAME = Bytes.toBytes("TestHTablePool"); + private final static String TABLENAME = "TestHTablePool"; public abstract static class TestHTablePoolType { @BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(1); - TEST_UTIL.createTable(TABLENAME, HConstants.CATALOG_FAMILY); + TEST_UTIL.createTable(TableName.valueOf(TABLENAME), HConstants.CATALOG_FAMILY); } @AfterClass @@ -61,7 +61,7 @@ public class TestHTablePool { public void testTableWithStringName() throws Exception { HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), Integer.MAX_VALUE, getPoolType()); - String tableName = Bytes.toString(TABLENAME); + String tableName = TABLENAME; // Request a table from an empty pool Table table = pool.getTable(tableName); @@ -130,7 +130,7 @@ public class TestHTablePool { public void testProxyImplementationReturned() { HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), Integer.MAX_VALUE); - String tableName = Bytes.toString(TABLENAME);// Request a table from + String tableName = TABLENAME;// Request a table from // an // empty pool Table table = pool.getTable(tableName); @@ -143,7 +143,7 @@ public class TestHTablePool { public void testDeprecatedUsagePattern() throws IOException { HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), Integer.MAX_VALUE); - String tableName = Bytes.toString(TABLENAME);// Request a table from + String tableName = TABLENAME;// Request a table from // an // empty pool @@ -165,14 +165,14 @@ public class TestHTablePool { public void testReturnDifferentTable() throws IOException { HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), Integer.MAX_VALUE); - String tableName = Bytes.toString(TABLENAME);// Request a table from + String tableName = TABLENAME;// Request a table from // an // empty pool // get table will return proxy implementation final Table table = pool.getTable(tableName); HTableInterface alienTable = new HTable(TEST_UTIL.getConfiguration(), - TABLENAME) { + TableName.valueOf(TABLENAME)) { // implementation doesn't matter as long the table is not from // pool }; @@ -189,7 +189,7 @@ public class TestHTablePool { public void testHTablePoolCloseTwice() throws Exception { HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), Integer.MAX_VALUE, getPoolType()); - String tableName = Bytes.toString(TABLENAME); + String tableName = TABLENAME; // Request a table from an empty pool Table table = pool.getTable(tableName); @@ -280,12 +280,12 @@ public class TestHTablePool { } Assert.assertEquals(4, - pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); + pool.getCurrentPoolSize(TABLENAME)); pool.closeTablePool(TABLENAME); Assert.assertEquals(0, - pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); + pool.getCurrentPoolSize(TABLENAME)); } } @@ -356,12 +356,12 @@ public class TestHTablePool { } Assert.assertEquals(1, - pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); + pool.getCurrentPoolSize(TABLENAME)); pool.closeTablePool(TABLENAME); Assert.assertEquals(0, - pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); + pool.getCurrentPoolSize(TABLENAME)); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java index 98f02ff81c8..4e059b2fb15 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMultiParallel.java @@ -81,7 +81,7 @@ public class TestMultiParallel { UTIL.startMiniCluster(slaves); HTable t = UTIL.createTable(TEST_TABLE, Bytes.toBytes(FAMILY)); UTIL.createMultiRegions(t, Bytes.toBytes(FAMILY)); - UTIL.waitTableEnabled(TEST_TABLE.getName()); + UTIL.waitTableEnabled(TEST_TABLE); t.close(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java index 850aedb40f9..d8721af34a8 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestClassLoading.java @@ -532,7 +532,7 @@ public class TestClassLoading { private void waitForTable(TableName name) throws InterruptedException, IOException { // First wait until all regions are online - TEST_UTIL.waitTableEnabled(name.getName()); + TEST_UTIL.waitTableEnabled(name); // Now wait a bit longer for the coprocessor hosts to load the CPs Thread.sleep(1000); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWithScanLimits.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWithScanLimits.java index 3955d36675f..567bd694a85 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWithScanLimits.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWithScanLimits.java @@ -70,7 +70,7 @@ public class TestFilterWithScanLimits { private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static Configuration conf = null; private static HBaseAdmin admin = null; - private static byte[] name = Bytes.toBytes("test"); + private static TableName name = TableName.valueOf("test"); @Test public void testScanWithLimit() { @@ -140,7 +140,7 @@ public class TestFilterWithScanLimits { assertNotNull("HBaseAdmin is not initialized successfully.", admin); if (admin != null) { - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name)); + HTableDescriptor desc = new HTableDescriptor(name); HColumnDescriptor coldef = new HColumnDescriptor(Bytes.toBytes("f1")); desc.addFamily(coldef); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWrapper.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWrapper.java index 46a70429e17..1b33b80cd05 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWrapper.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterWrapper.java @@ -64,7 +64,7 @@ public class TestFilterWrapper { private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static Configuration conf = null; private static HBaseAdmin admin = null; - private static byte[] name = Bytes.toBytes("test"); + private static TableName name = TableName.valueOf("test"); @Test public void testFilterWrapper() { @@ -143,7 +143,7 @@ public class TestFilterWrapper { assertNotNull("HBaseAdmin is not initialized successfully.", admin); if (admin != null) { - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name)); + HTableDescriptor desc = new HTableDescriptor(name); HColumnDescriptor coldef = new HColumnDescriptor(Bytes.toBytes("f1")); desc.addFamily(coldef); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java index c257cf3f56b..fa7b3805199 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat.java @@ -448,7 +448,7 @@ public class TestHFileOutputFormat { LOG.info("Waiting for table to disable"); } admin.enableTable(TABLE_NAME); - util.waitTableAvailable(TABLE_NAME.getName()); + util.waitTableAvailable(TABLE_NAME); assertEquals("Data should remain after reopening of regions", tableDigestBefore, util.checksumRows(table)); } finally { @@ -1048,7 +1048,7 @@ public class TestHFileOutputFormat { Configuration conf = HBaseConfiguration.create(); util = new HBaseTestingUtility(conf); if ("newtable".equals(args[0])) { - byte[] tname = args[1].getBytes(); + TableName tname = TableName.valueOf(args[1]); HTable table = util.createTable(tname, FAMILIES); HBaseAdmin admin = new HBaseAdmin(conf); admin.disableTable(tname); @@ -1056,7 +1056,7 @@ public class TestHFileOutputFormat { util.createMultiRegions(conf, table, FAMILIES[0], startKeys); admin.enableTable(tname); } else if ("incremental".equals(args[0])) { - byte[] tname = args[1].getBytes(); + TableName tname = TableName.valueOf(args[1]); HTable table = new HTable(conf, tname); Path outDir = new Path("incremental-out"); runIncrementalPELoad(conf, table, outDir); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java index edfd3395c08..01e4963a8b3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java @@ -447,7 +447,7 @@ public class TestHFileOutputFormat2 { LOG.info("Waiting for table to disable"); } admin.enableTable(TABLE_NAME); - util.waitTableAvailable(TABLE_NAME.getName()); + util.waitTableAvailable(TABLE_NAME); assertEquals("Data should remain after reopening of regions", tableDigestBefore, util.checksumRows(table)); } finally { @@ -1056,7 +1056,7 @@ public class TestHFileOutputFormat2 { util.createMultiRegions(conf, table, FAMILIES[0], startKeys); admin.enableTable(tname); } else if ("incremental".equals(args[0])) { - byte[] tname = args[1].getBytes(); + TableName tname = TableName.valueOf(args[1]); HTable table = new HTable(conf, tname); Path outDir = new Path("incremental-out"); runIncrementalPELoad(conf, table, outDir); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFiles.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFiles.java index bac110d868a..ee2854fe341 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFiles.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFiles.java @@ -55,7 +55,7 @@ public class TestSecureLoadIncrementalHFiles extends TestLoadIncrementalHFiles{ util.startMiniCluster(); // Wait for the ACL table to become available - util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); setupNamespace(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFilesSplitRecovery.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFilesSplitRecovery.java index f4619e838ab..48554b56e0a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFilesSplitRecovery.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestSecureLoadIncrementalHFilesSplitRecovery.java @@ -57,7 +57,7 @@ public class TestSecureLoadIncrementalHFilesSplitRecovery extends TestLoadIncrem util.startMiniCluster(); // Wait for the ACL table to become available - util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); } //Disabling this test as it does not work in secure mode diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java index c218bc926ba..c82d82ffb2b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTableMapReduceBase.java @@ -54,7 +54,7 @@ import org.junit.Test; public abstract class TestTableMapReduceBase { protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); - protected static final byte[] MULTI_REGION_TABLE_NAME = Bytes.toBytes("mrtest"); + protected static final TableName MULTI_REGION_TABLE_NAME = TableName.valueOf("mrtest"); protected static final byte[] INPUT_FAMILY = Bytes.toBytes("contents"); protected static final byte[] OUTPUT_FAMILY = Bytes.toBytes("text"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java index e6520dfc095..597efbaf7e9 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mapreduce/TestTimeRangeMapRed.java @@ -76,7 +76,7 @@ public class TestTimeRangeMapRed { static final long MINSTAMP = 1245620005; static final long MAXSTAMP = 1245620100 + 1; // maxStamp itself is excluded. so increment it. - static final byte[] TABLE_NAME = Bytes.toBytes("table123"); + static final TableName TABLE_NAME = TableName.valueOf("table123"); static final byte[] FAMILY_NAME = Bytes.toBytes("text"); static final byte[] COLUMN_NAME = Bytes.toBytes("input"); @@ -144,7 +144,7 @@ public class TestTimeRangeMapRed { @Test public void testTimeRangeMapRed() throws IOException, InterruptedException, ClassNotFoundException { - final HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLE_NAME)); + final HTableDescriptor desc = new HTableDescriptor(TABLE_NAME); final HColumnDescriptor col = new HColumnDescriptor(FAMILY_NAME); col.setMaxVersions(Integer.MAX_VALUE); desc.addFamily(col); @@ -177,7 +177,7 @@ public class TestTimeRangeMapRed { scan.addColumn(FAMILY_NAME, COLUMN_NAME); scan.setTimeRange(MINSTAMP, MAXSTAMP); scan.setMaxVersions(); - TableMapReduceUtil.initTableMapperJob(Bytes.toString(TABLE_NAME), + TableMapReduceUtil.initTableMapperJob(TABLE_NAME, scan, ProcessTimeRangeMapper.class, Text.class, Text.class, job); job.waitForCompletion(true); } catch (IOException e) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java index 27848ef6697..746fcd0888d 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterOperationsForRegionReplicas.java @@ -112,7 +112,7 @@ public class TestMasterOperationsForRegionReplicas { desc.setRegionReplication(numReplica); desc.addFamily(new HColumnDescriptor("family")); admin.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), numRegions); - TEST_UTIL.waitTableEnabled(table.getName()); + TEST_UTIL.waitTableEnabled(table); validateNumberOfRowsInMeta(table, numRegions, admin.getConnection()); List hris = MetaTableAccessor.getTableRegions(TEST_UTIL.getZooKeeperWatcher(), @@ -169,7 +169,7 @@ public class TestMasterOperationsForRegionReplicas { TEST_UTIL.getConfiguration().setBoolean("hbase.master.startup.retainassign", true); TEST_UTIL.shutdownMiniHBaseCluster(); TEST_UTIL.startMiniHBaseCluster(1, numSlaves); - TEST_UTIL.waitTableEnabled(table.getName()); + TEST_UTIL.waitTableEnabled(table); admin.close(); admin = new HBaseAdmin(conf); validateFromSnapshotFromMeta(TEST_UTIL, table, numRegions, numReplica, @@ -179,7 +179,7 @@ public class TestMasterOperationsForRegionReplicas { // one server running TEST_UTIL.shutdownMiniHBaseCluster(); TEST_UTIL.startMiniHBaseCluster(1, 1); - TEST_UTIL.waitTableEnabled(table.getName()); + TEST_UTIL.waitTableEnabled(table); admin.close(); admin = new HBaseAdmin(conf); validateSingleRegionServerAssignment(admin.getConnection(), numRegions, numReplica); @@ -243,7 +243,7 @@ public class TestMasterOperationsForRegionReplicas { desc.setRegionReplication(numReplica); desc.addFamily(new HColumnDescriptor("family")); admin.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), numRegions); - TEST_UTIL.waitTableEnabled(table.getName()); + TEST_UTIL.waitTableEnabled(table); Set tableRows = new HashSet(); List hris = MetaTableAccessor.getTableRegions(TEST_UTIL.getZooKeeperWatcher(), admin.getConnection(), table); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java index 7062473379d..2f521b69120 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java @@ -212,7 +212,7 @@ public class TestRegionPlacement { @Test public void testRegionPlacement() throws Exception { String tableStr = "testRegionAssignment"; - byte[] table = Bytes.toBytes(tableStr); + TableName table = TableName.valueOf(tableStr); // Create a table with REGION_NUM regions. createTable(table, REGION_NUM); @@ -667,7 +667,7 @@ public class TestRegionPlacement { * @return * @throws IOException */ - private static void createTable(byte[] tableName, int regionNum) + private static void createTable(TableName tableName, int regionNum) throws IOException { int expectedRegions = regionNum; byte[][] splitKeys = new byte[expectedRegions - 1][]; @@ -676,7 +676,7 @@ public class TestRegionPlacement { splitKeys[i - 1] = new byte[] { splitKey, splitKey, splitKey }; } - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); admin.createTable(desc, splitKeys); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java index 847d19afe31..3a33be886ba 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java @@ -99,7 +99,7 @@ public class TestRestartCluster { UTIL.createTable(TABLE, FAMILY); } for(TableName TABLE : TABLES) { - UTIL.waitTableEnabled(TABLE.getName()); + UTIL.waitTableEnabled(TABLE); } List allRegions = @@ -128,7 +128,7 @@ public class TestRestartCluster { } catch(TableExistsException tee) { LOG.info("Table already exists as expected"); } - UTIL.waitTableAvailable(TABLE.getName()); + UTIL.waitTableAvailable(TABLE); } } @@ -149,7 +149,7 @@ public class TestRestartCluster { UTIL.createTable(TABLE, FAMILY); } for(TableName TABLE : TABLES) { - UTIL.waitTableEnabled(TABLE.getName()); + UTIL.waitTableEnabled(TABLE); } HMaster master = UTIL.getMiniHBaseCluster().getMaster(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java index a04e4d04a08..3c77bb0a8a3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java @@ -392,6 +392,7 @@ public class TestTableLockManager { alterThread.start(); splitThread.start(); + TEST_UTIL.waitTableEnabled(tableName); while (true) { List regions = admin.getTableRegions(tableName); LOG.info(String.format("Table #regions: %d regions: %s:", regions.size(), regions)); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java index 4cbbfccc3b2..d446e69c158 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEncryptionKeyRotation.java @@ -207,7 +207,7 @@ public class TestEncryptionKeyRotation { TEST_UTIL.getHBaseAdmin().createTable(htd); TEST_UTIL.waitTableAvailable(htd.getName(), 5000); // Create a store file - Table table = new HTable(conf, htd.getName()); + Table table = new HTable(conf, htd.getTableName()); try { table.put(new Put(Bytes.toBytes("testrow")) .add(hcd.getName(), Bytes.toBytes("q"), Bytes.toBytes("value"))); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java index 4884a812f98..40726995b38 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java @@ -186,11 +186,11 @@ public class TestFSErrorsExposed { util.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 3); util.startMiniCluster(1); - byte[] tableName = Bytes.toBytes("table"); + TableName tableName = TableName.valueOf("table"); byte[] fam = Bytes.toBytes("fam"); Admin admin = new HBaseAdmin(util.getConfiguration()); - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + HTableDescriptor desc = new HTableDescriptor(tableName); desc.addFamily(new HColumnDescriptor(fam) .setMaxVersions(1) .setBlockCacheEnabled(false) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java index e3c5d3a0446..a996a702caa 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestJoinedScanners.java @@ -93,8 +93,8 @@ public class TestJoinedScanners { cluster = htu.startMiniCluster(1, regionServersCount, dataNodeHosts); byte [][] families = {cf_essential, cf_joined}; - byte[] tableName = Bytes.toBytes(this.getClass().getSimpleName()); - HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); + TableName tableName = TableName.valueOf(this.getClass().getSimpleName()); + HTableDescriptor desc = new HTableDescriptor(tableName); for(byte[] family : families) { HColumnDescriptor hcd = new HColumnDescriptor(family); hcd.setDataBlockEncoding(blockEncoding); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java index efff6dd5443..074d3f19255 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMasterReplication.java @@ -74,7 +74,7 @@ public class TestMasterReplication { private static final long SLEEP_TIME = 500; private static final int NB_RETRIES = 10; - private static final byte[] tableName = Bytes.toBytes("test"); + private static final TableName tableName = TableName.valueOf("test"); private static final byte[] famName = Bytes.toBytes("f"); private static final byte[] row = Bytes.toBytes("row"); private static final byte[] row1 = Bytes.toBytes("row1"); @@ -107,7 +107,7 @@ public class TestMasterReplication { CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, CoprocessorCounter.class.getName()); - table = new HTableDescriptor(TableName.valueOf(tableName)); + table = new HTableDescriptor(tableName); HColumnDescriptor fam = new HColumnDescriptor(famName); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); table.addFamily(fam); @@ -345,7 +345,7 @@ public class TestMasterReplication { } @SuppressWarnings("resource") - private Table[] getHTablesOnClusters(byte[] tableName) throws Exception { + private Table[] getHTablesOnClusters(TableName tableName) throws Exception { int numClusters = utilities.length; Table[] htables = new Table[numClusters]; for (int i = 0; i < numClusters; i++) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java index 5abfeea9d71..3ef91e2bc1b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java @@ -60,7 +60,7 @@ public class TestMultiSlaveReplication { private static final long SLEEP_TIME = 500; private static final int NB_RETRIES = 100; - private static final byte[] tableName = Bytes.toBytes("test"); + private static final TableName tableName = TableName.valueOf("test"); private static final byte[] famName = Bytes.toBytes("f"); private static final byte[] row = Bytes.toBytes("row"); private static final byte[] row1 = Bytes.toBytes("row1"); @@ -106,7 +106,7 @@ public class TestMultiSlaveReplication { utility3.setZkCluster(miniZK); new ZooKeeperWatcher(conf3, "cluster3", null, true); - table = new HTableDescriptor(TableName.valueOf(tableName)); + table = new HTableDescriptor(tableName); HColumnDescriptor fam = new HColumnDescriptor(famName); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); table.addFamily(fam); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java index 6d8b68cea9d..ddd9bcb8e1c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestPerTableCFReplication.java @@ -65,10 +65,10 @@ public class TestPerTableCFReplication { private static final long SLEEP_TIME = 500; private static final int NB_RETRIES = 100; - private static final byte[] tableName = Bytes.toBytes("test"); - private static final byte[] tabAName = Bytes.toBytes("TA"); - private static final byte[] tabBName = Bytes.toBytes("TB"); - private static final byte[] tabCName = Bytes.toBytes("TC"); + private static final TableName tableName = TableName.valueOf("test"); + private static final TableName tabAName = TableName.valueOf("TA"); + private static final TableName tabBName = TableName.valueOf("TB"); + private static final TableName tabCName = TableName.valueOf("TC"); private static final byte[] famName = Bytes.toBytes("f"); private static final byte[] f1Name = Bytes.toBytes("f1"); private static final byte[] f2Name = Bytes.toBytes("f2"); @@ -119,7 +119,7 @@ public class TestPerTableCFReplication { utility3.setZkCluster(miniZK); new ZooKeeperWatcher(conf3, "cluster3", null, true); - table = new HTableDescriptor(TableName.valueOf(tableName)); + table = new HTableDescriptor(tableName); HColumnDescriptor fam = new HColumnDescriptor(famName); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); table.addFamily(fam); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java index 252d3a49539..9fe2e0bcc2c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationBase.java @@ -75,7 +75,7 @@ public class TestReplicationBase { protected static final long SLEEP_TIME = 500; protected static final int NB_RETRIES = 10; - protected static final byte[] tableName = Bytes.toBytes("test"); + protected static final TableName tableName = TableName.valueOf("test"); protected static final byte[] famName = Bytes.toBytes("f"); protected static final byte[] row = Bytes.toBytes("row"); protected static final byte[] noRepfamName = Bytes.toBytes("norep"); @@ -129,7 +129,7 @@ public class TestReplicationBase { utility1.startMiniCluster(2); utility2.startMiniCluster(2); - HTableDescriptor table = new HTableDescriptor(TableName.valueOf(tableName)); + HTableDescriptor table = new HTableDescriptor(tableName); HColumnDescriptor fam = new HColumnDescriptor(famName); fam.setMaxVersions(3); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java index 68a99aa3a55..80d30a5166b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSmallTests.java @@ -445,7 +445,7 @@ public class TestReplicationSmallTests extends TestReplicationBase { // identical since it does the check testSmallBatch(); - String[] args = new String[] {"2", Bytes.toString(tableName)}; + String[] args = new String[] {"2", tableName.getNameAsString()}; Job job = VerifyReplication.createSubmittableJob(CONF_WITH_LOCALFS, args); if (job == null) { fail("Job wasn't created, see the log"); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java index aded6365a28..7e36152d87e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationSyncUpTool.java @@ -43,8 +43,8 @@ public class TestReplicationSyncUpTool extends TestReplicationBase { private static final Log LOG = LogFactory.getLog(TestReplicationSyncUpTool.class); - private static final byte[] t1_su = Bytes.toBytes("t1_syncup"); - private static final byte[] t2_su = Bytes.toBytes("t2_syncup"); + private static final TableName t1_su = TableName.valueOf("t1_syncup"); + private static final TableName t2_su = TableName.valueOf("t2_syncup"); private static final byte[] famName = Bytes.toBytes("cf1"); private static final byte[] qualName = Bytes.toBytes("q1"); @@ -61,27 +61,27 @@ public class TestReplicationSyncUpTool extends TestReplicationBase { HColumnDescriptor fam; - t1_syncupSource = new HTableDescriptor(TableName.valueOf(t1_su)); + t1_syncupSource = new HTableDescriptor(t1_su); fam = new HColumnDescriptor(famName); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); t1_syncupSource.addFamily(fam); fam = new HColumnDescriptor(noRepfamName); t1_syncupSource.addFamily(fam); - t1_syncupTarget = new HTableDescriptor(TableName.valueOf(t1_su)); + t1_syncupTarget = new HTableDescriptor(t1_su); fam = new HColumnDescriptor(famName); t1_syncupTarget.addFamily(fam); fam = new HColumnDescriptor(noRepfamName); t1_syncupTarget.addFamily(fam); - t2_syncupSource = new HTableDescriptor(TableName.valueOf(t2_su)); + t2_syncupSource = new HTableDescriptor(t2_su); fam = new HColumnDescriptor(famName); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); t2_syncupSource.addFamily(fam); fam = new HColumnDescriptor(noRepfamName); t2_syncupSource.addFamily(fam); - t2_syncupTarget = new HTableDescriptor(TableName.valueOf(t2_su)); + t2_syncupTarget = new HTableDescriptor(t2_su); fam = new HColumnDescriptor(famName); t2_syncupTarget.addFamily(fam); fam = new HColumnDescriptor(noRepfamName); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java index 9a49e9c7155..8f5c5c3c6a0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java @@ -80,7 +80,7 @@ public class TestReplicationWithTags { private static final long SLEEP_TIME = 500; private static final int NB_RETRIES = 10; - private static final byte[] TABLE_NAME = Bytes.toBytes("TestReplicationWithTags"); + private static final TableName TABLE_NAME = TableName.valueOf("TestReplicationWithTags"); private static final byte[] FAMILY = Bytes.toBytes("f"); private static final byte[] ROW = Bytes.toBytes("row"); @@ -131,7 +131,7 @@ public class TestReplicationWithTags { utility1.startMiniCluster(2); utility2.startMiniCluster(2); - HTableDescriptor table = new HTableDescriptor(TableName.valueOf(TABLE_NAME)); + HTableDescriptor table = new HTableDescriptor(TABLE_NAME); HColumnDescriptor fam = new HColumnDescriptor(FAMILY); fam.setMaxVersions(3); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java index 3e834bdaf6b..1141c9fa2b5 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/SecureTestUtil.java @@ -103,17 +103,17 @@ public class SecureTestUtil { } } - public static void checkTablePerms(Configuration conf, byte[] table, byte[] family, byte[] column, + public static void checkTablePerms(Configuration conf, TableName table, byte[] family, byte[] column, Permission.Action... actions) throws IOException { Permission[] perms = new Permission[actions.length]; for (int i = 0; i < actions.length; i++) { - perms[i] = new TablePermission(TableName.valueOf(table), family, column, actions[i]); + perms[i] = new TablePermission(table, family, column, actions[i]); } checkTablePerms(conf, table, perms); } - public static void checkTablePerms(Configuration conf, byte[] table, Permission... perms) throws IOException { + public static void checkTablePerms(Configuration conf, TableName table, Permission... perms) throws IOException { CheckPermissionsRequest.Builder request = CheckPermissionsRequest.newBuilder(); for (Permission p : perms) { request.addPermission(ProtobufUtil.toPermission(p)); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java index 1f691f78671..f0f7a14c34c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController.java @@ -191,7 +191,7 @@ public class TestAccessController extends SecureTestUtil { Coprocessor.PRIORITY_HIGHEST, 1, conf); // Wait for the ACL table to become available - TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); // create a set of test users SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" }); @@ -218,7 +218,7 @@ public class TestAccessController extends SecureTestUtil { htd.addFamily(hcd); htd.setOwner(USER_OWNER); admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); - TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); + TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0); RegionCoprocessorHost rcpHost = region.getCoprocessorHost(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java index dcc3d16211b..836e208760f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestAccessController2.java @@ -56,7 +56,7 @@ public class TestAccessController2 extends SecureTestUtil { verifyConfiguration(conf); TEST_UTIL.startMiniCluster(); // Wait for the ACL table to become available - TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); } @AfterClass @@ -85,7 +85,7 @@ public class TestAccessController2 extends SecureTestUtil { return null; } }, testUser); - TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); + TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); // Verify that owner permissions have been granted to the test user on the // table just created List perms = AccessControlLists.getTablePermissions(conf, TEST_TABLE.getTableName()) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java index 40e2a02ad3c..90d4c189182 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLWithMultipleVersions.java @@ -108,7 +108,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil { rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); // Wait for the ACL table to become available - TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); // create a set of test users USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); @@ -135,7 +135,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil { htd.setOwner(USER_OWNER); htd.addFamily(hcd); admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); - TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); + TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); } @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java index f58847ee37d..dadbd780aa4 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestCellACLs.java @@ -110,7 +110,7 @@ public class TestCellACLs extends SecureTestUtil { rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); // Wait for the ACL table to become available - TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); // create a set of test users USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); @@ -132,7 +132,7 @@ public class TestCellACLs extends SecureTestUtil { htd.setOwner(USER_OWNER); htd.addFamily(hcd); admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); - TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); + TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); } @Test diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java index d78e43ea7a7..6d7ff61efe6 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestScanEarlyTermination.java @@ -98,7 +98,7 @@ public class TestScanEarlyTermination extends SecureTestUtil { rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); // Wait for the ACL table to become available - TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); // create a set of test users USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); @@ -128,7 +128,7 @@ public class TestScanEarlyTermination extends SecureTestUtil { admin.createTable(htd); - TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); + TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName()); } @After diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java index c65ebefaf2f..572cff36ead 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/access/TestTablePermissions.java @@ -98,7 +98,7 @@ public class TestTablePermissions { UTIL.startMiniCluster(); // Wait for the ACL table to become available - UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); ZKW = new ZooKeeperWatcher(UTIL.getConfiguration(), "TestTablePermissions", ABORTABLE); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithACL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithACL.java index 17693d20bf9..5994ebdbaef 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithACL.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithACL.java @@ -123,7 +123,7 @@ public class TestVisibilityLabelsWithACL { public Void run() throws Exception { Scan s = new Scan(); s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); - Table t = new HTable(conf, table.getTableName()); + Table t = new HTable(conf, table.getName()); try { ResultScanner scanner = t.getScanner(s); Result result = scanner.next(); @@ -152,7 +152,7 @@ public class TestVisibilityLabelsWithACL { public Void run() throws Exception { Scan s = new Scan(); s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); - Table t = new HTable(conf, table.getTableName()); + Table t = new HTable(conf, table.getName()); try { ResultScanner scanner = t.getScanner(s); Result[] result = scanner.next(5); @@ -178,7 +178,7 @@ public class TestVisibilityLabelsWithACL { public Void run() throws Exception { Get g = new Get(row1); g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); - Table t = new HTable(conf, table.getTableName()); + Table t = new HTable(conf, table.getName()); try { Result result = t.get(g); assertTrue(!result.isEmpty()); @@ -207,7 +207,7 @@ public class TestVisibilityLabelsWithACL { public Void run() throws Exception { Get g = new Get(row1); g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); - Table t = new HTable(conf, table.getTableName()); + Table t = new HTable(conf, table.getName()); try { Result result = t.get(g); assertTrue(result.isEmpty()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java index 9a0400348eb..1a0272419c0 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsWithDefaultVisLabelService.java @@ -144,7 +144,7 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili // Scan the visibility label Scan s = new Scan(); s.setAuthorizations(new Authorizations(VisibilityUtils.SYSTEM_LABEL)); - Table ht = new HTable(conf, LABELS_TABLE_NAME.getName()); + Table ht = new HTable(conf, LABELS_TABLE_NAME); int i = 0; try { ResultScanner scanner = ht.getScanner(s); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSecureExportSnapshot.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSecureExportSnapshot.java index b9f76e6862e..444bb4bb6dc 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSecureExportSnapshot.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSecureExportSnapshot.java @@ -48,6 +48,6 @@ public class TestSecureExportSnapshot extends TestExportSnapshot { TEST_UTIL.startMiniMapReduceCluster(); // Wait for the ACL table to become available - TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); + TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestProcessBasedCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestProcessBasedCluster.java index 38f93ae85ba..6ea06da3bcb 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestProcessBasedCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestProcessBasedCluster.java @@ -61,7 +61,7 @@ public class TestProcessBasedCluster { HTestConst.DEFAULT_CF_STR_SET, HColumnDescriptor.DEFAULT_VERSIONS, COLS_PER_ROW, FLUSHES, NUM_REGIONS, ROWS_PER_FLUSH); - Table table = new HTable(TEST_UTIL.getConfiguration(), HTestConst.DEFAULT_TABLE_BYTES); + Table table = new HTable(TEST_UTIL.getConfiguration(), HTestConst.DEFAULT_TABLE); ResultScanner scanner = table.getScanner(HTestConst.DEFAULT_CF_BYTES); Result result; int rows = 0; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java index 7a35ea626b4..03ffdfc4c5c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestRegionSplitter.java @@ -279,8 +279,7 @@ public class TestRegionSplitter { final Configuration conf = UTIL.getConfiguration(); conf.setInt("split.count", numRegions); SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass); - RegionSplitter.createPresplitTable(tableName.getNameAsString(), splitAlgo, - new String[] {CF_NAME}, conf); + RegionSplitter.createPresplitTable(tableName, splitAlgo, new String[] {CF_NAME}, conf); verifyBounds(expectedBounds, tableName); } @@ -300,7 +299,7 @@ public class TestRegionSplitter { // Set this larger than the number of splits so RegionSplitter won't block conf.setInt("split.outstanding", 5); SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass); - RegionSplitter.rollingSplit(tableName.getNameAsString(), splitAlgo, conf); + RegionSplitter.rollingSplit(tableName, splitAlgo, conf); verifyBounds(expectedBounds, tableName); } @@ -327,6 +326,7 @@ public class TestRegionSplitter { startBoundaryIndex+1); assertEquals(0, Bytes.compareTo(regionEnd, expectedRegionEnd)); } + hTable.close(); } /**