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
This commit is contained in:
stack 2014-09-30 16:35:55 -07:00
parent d7283ae8d5
commit eb361fc33d
56 changed files with 195 additions and 158 deletions

View File

@ -18,6 +18,7 @@
*/ */
package org.apache.hadoop.hbase.client; 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.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
@ -37,7 +38,7 @@ public class HTableFactory implements HTableInterfaceFactory {
public HTableInterface createHTableInterface(Configuration config, public HTableInterface createHTableInterface(Configuration config,
byte[] tableName) { byte[] tableName) {
try { try {
return new HTable(config, tableName); return new HTable(config, TableName.valueOf(tableName));
} catch (IOException ioe) { } catch (IOException ioe) {
throw new RuntimeException(ioe); throw new RuntimeException(ioe);
} }

View File

@ -76,7 +76,7 @@ public class AccessControlClient {
try { try {
TableName aclTableName = TableName aclTableName =
TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl"); TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl");
ht = new HTable(conf, aclTableName.getName()); ht = new HTable(conf, aclTableName);
Batch.Call<AccessControlService, GrantResponse> callable = Batch.Call<AccessControlService, GrantResponse> callable =
new Batch.Call<AccessControlService, GrantResponse>() { new Batch.Call<AccessControlService, GrantResponse>() {
ServerRpcController controller = new ServerRpcController(); ServerRpcController controller = new ServerRpcController();
@ -156,7 +156,7 @@ public class AccessControlClient {
try { try {
TableName aclTableName = TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, TableName aclTableName = TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR,
"acl"); "acl");
ht = new HTable(conf, aclTableName.getName()); ht = new HTable(conf, aclTableName);
Batch.Call<AccessControlService, AccessControlProtos.RevokeResponse> callable = Batch.Call<AccessControlService, AccessControlProtos.RevokeResponse> callable =
new Batch.Call<AccessControlService, AccessControlProtos.RevokeResponse>() { new Batch.Call<AccessControlService, AccessControlProtos.RevokeResponse>() {
ServerRpcController controller = new ServerRpcController(); ServerRpcController controller = new ServerRpcController();
@ -219,7 +219,7 @@ public class AccessControlClient {
TableName aclTableName = TableName aclTableName =
TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl"); TableName.valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "acl");
ha = new HBaseAdmin(conf); ha = new HBaseAdmin(conf);
ht = new HTable(conf, aclTableName.getName()); ht = new HTable(conf, aclTableName);
CoprocessorRpcChannel service = ht.coprocessorService(HConstants.EMPTY_START_ROW); CoprocessorRpcChannel service = ht.coprocessorService(HConstants.EMPTY_START_ROW);
BlockingInterface protocol = BlockingInterface protocol =
AccessControlProtos.AccessControlService.newBlockingStub(service); AccessControlProtos.AccessControlService.newBlockingStub(service);

View File

@ -75,7 +75,7 @@ public class VisibilityClient {
throws Throwable { throws Throwable {
Table ht = null; Table ht = null;
try { try {
ht = new HTable(conf, LABELS_TABLE_NAME.getName()); ht = new HTable(conf, LABELS_TABLE_NAME);
Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable = Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable =
new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() { new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() {
ServerRpcController controller = new ServerRpcController(); ServerRpcController controller = new ServerRpcController();
@ -129,7 +129,7 @@ public class VisibilityClient {
public static GetAuthsResponse getAuths(Configuration conf, final String user) throws Throwable { public static GetAuthsResponse getAuths(Configuration conf, final String user) throws Throwable {
Table ht = null; Table ht = null;
try { try {
ht = new HTable(conf, LABELS_TABLE_NAME.getName()); ht = new HTable(conf, LABELS_TABLE_NAME);
Batch.Call<VisibilityLabelsService, GetAuthsResponse> callable = Batch.Call<VisibilityLabelsService, GetAuthsResponse> callable =
new Batch.Call<VisibilityLabelsService, GetAuthsResponse>() { new Batch.Call<VisibilityLabelsService, GetAuthsResponse>() {
ServerRpcController controller = new ServerRpcController(); ServerRpcController controller = new ServerRpcController();
@ -171,7 +171,7 @@ public class VisibilityClient {
final String user, final boolean setOrClear) throws IOException, ServiceException, Throwable { final String user, final boolean setOrClear) throws IOException, ServiceException, Throwable {
Table ht = null; Table ht = null;
try { try {
ht = new HTable(conf, LABELS_TABLE_NAME.getName()); ht = new HTable(conf, LABELS_TABLE_NAME);
Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable = Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse> callable =
new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() { new Batch.Call<VisibilityLabelsService, VisibilityLabelsResponse>() {
ServerRpcController controller = new ServerRpcController(); ServerRpcController controller = new ServerRpcController();

View File

@ -78,7 +78,7 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteEndpoint() throws Throwable { public void testBulkDeleteEndpoint() throws Throwable {
byte[] tableName = Bytes.toBytes("testBulkDeleteEndpoint"); TableName tableName = TableName.valueOf("testBulkDeleteEndpoint");
Table ht = createTable(tableName); Table ht = createTable(tableName);
List<Put> puts = new ArrayList<Put>(100); List<Put> puts = new ArrayList<Put>(100);
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
@ -101,8 +101,8 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteEndpointWhenRowBatchSizeLessThanRowsToDeleteFromARegion() public void testBulkDeleteEndpointWhenRowBatchSizeLessThanRowsToDeleteFromARegion()
throws Throwable { throws Throwable {
byte[] tableName = Bytes TableName tableName = TableName
.toBytes("testBulkDeleteEndpointWhenRowBatchSizeLessThanRowsToDeleteFromARegion"); .valueOf("testBulkDeleteEndpointWhenRowBatchSizeLessThanRowsToDeleteFromARegion");
Table ht = createTable(tableName); Table ht = createTable(tableName);
List<Put> puts = new ArrayList<Put>(100); List<Put> puts = new ArrayList<Put>(100);
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
@ -122,7 +122,7 @@ public class TestBulkDeleteProtocol {
ht.close(); 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 { final DeleteType deleteType, final Long timeStamp) throws Throwable {
Table ht = new HTable(TEST_UTIL.getConfiguration(), tableName); Table ht = new HTable(TEST_UTIL.getConfiguration(), tableName);
long noOfDeletedRows = 0L; long noOfDeletedRows = 0L;
@ -155,7 +155,7 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteWithConditionBasedDelete() throws Throwable { public void testBulkDeleteWithConditionBasedDelete() throws Throwable {
byte[] tableName = Bytes.toBytes("testBulkDeleteWithConditionBasedDelete"); TableName tableName = TableName.valueOf("testBulkDeleteWithConditionBasedDelete");
Table ht = createTable(tableName); Table ht = createTable(tableName);
List<Put> puts = new ArrayList<Put>(100); List<Put> puts = new ArrayList<Put>(100);
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
@ -185,7 +185,7 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteColumn() throws Throwable { public void testBulkDeleteColumn() throws Throwable {
byte[] tableName = Bytes.toBytes("testBulkDeleteColumn"); TableName tableName = TableName.valueOf("testBulkDeleteColumn");
Table ht = createTable(tableName); Table ht = createTable(tableName);
List<Put> puts = new ArrayList<Put>(100); List<Put> puts = new ArrayList<Put>(100);
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
@ -214,8 +214,8 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteFamily() throws Throwable { public void testBulkDeleteFamily() throws Throwable {
byte[] tableName = Bytes.toBytes("testBulkDeleteFamily"); TableName tableName = TableName.valueOf("testBulkDeleteFamily");
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); HTableDescriptor htd = new HTableDescriptor(tableName);
htd.addFamily(new HColumnDescriptor(FAMILY1)); htd.addFamily(new HColumnDescriptor(FAMILY1));
htd.addFamily(new HColumnDescriptor(FAMILY2)); htd.addFamily(new HColumnDescriptor(FAMILY2));
TEST_UTIL.getHBaseAdmin().createTable(htd, Bytes.toBytes(0), Bytes.toBytes(120), 5); TEST_UTIL.getHBaseAdmin().createTable(htd, Bytes.toBytes(0), Bytes.toBytes(120), 5);
@ -245,7 +245,7 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteColumnVersion() throws Throwable { public void testBulkDeleteColumnVersion() throws Throwable {
byte[] tableName = Bytes.toBytes("testBulkDeleteColumnVersion"); TableName tableName = TableName.valueOf("testBulkDeleteColumnVersion");
Table ht = createTable(tableName); Table ht = createTable(tableName);
List<Put> puts = new ArrayList<Put>(100); List<Put> puts = new ArrayList<Put>(100);
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
@ -293,7 +293,7 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteColumnVersionBasedOnTS() throws Throwable { public void testBulkDeleteColumnVersionBasedOnTS() throws Throwable {
byte[] tableName = Bytes.toBytes("testBulkDeleteColumnVersionBasedOnTS"); TableName tableName = TableName.valueOf("testBulkDeleteColumnVersionBasedOnTS");
Table ht = createTable(tableName); Table ht = createTable(tableName);
List<Put> puts = new ArrayList<Put>(100); List<Put> puts = new ArrayList<Put>(100);
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
@ -340,7 +340,7 @@ public class TestBulkDeleteProtocol {
// @Ignore @Test // @Ignore @Test
public void testBulkDeleteWithNumberOfVersions() throws Throwable { public void testBulkDeleteWithNumberOfVersions() throws Throwable {
byte[] tableName = Bytes.toBytes("testBulkDeleteWithNumberOfVersions"); TableName tableName = TableName.valueOf("testBulkDeleteWithNumberOfVersions");
Table ht = createTable(tableName); Table ht = createTable(tableName);
List<Put> puts = new ArrayList<Put>(100); List<Put> puts = new ArrayList<Put>(100);
for (int j = 0; j < 100; j++) { for (int j = 0; j < 100; j++) {
@ -423,8 +423,8 @@ public class TestBulkDeleteProtocol {
ht.close(); ht.close();
} }
private Table createTable(byte[] tableName) throws IOException { private Table createTable(TableName tableName) throws IOException {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName)); HTableDescriptor htd = new HTableDescriptor(tableName);
HColumnDescriptor hcd = new HColumnDescriptor(FAMILY1); HColumnDescriptor hcd = new HColumnDescriptor(FAMILY1);
hcd.setMaxVersions(10);// Just setting 10 as I am not testing with more than 10 versions here hcd.setMaxVersions(10);// Just setting 10 as I am not testing with more than 10 versions here
htd.addFamily(hcd); htd.addFamily(hcd);

View File

@ -45,7 +45,7 @@ import static junit.framework.Assert.*;
*/ */
@Category(MediumTests.class) @Category(MediumTests.class)
public class TestRowCountEndpoint { 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_FAMILY = Bytes.toBytes("f");
private static final byte[] TEST_COLUMN = Bytes.toBytes("col"); private static final byte[] TEST_COLUMN = Bytes.toBytes("col");
@ -60,7 +60,7 @@ public class TestRowCountEndpoint {
RowCountEndpoint.class.getName()); RowCountEndpoint.class.getName());
TEST_UTIL.startMiniCluster(); 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 // @Ignore @AfterClass

View File

@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.HBaseConfiguration; 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.HTable;
import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@ -52,7 +53,7 @@ implements Partitioner<ImmutableBytesWritable, V2> {
public void configure(JobConf job) { public void configure(JobConf job) {
try { try {
this.table = new HTable(HBaseConfiguration.create(job), this.table = new HTable(HBaseConfiguration.create(job),
job.get(TableOutputFormat.OUTPUT_TABLE)); TableName.valueOf(job.get(TableOutputFormat.OUTPUT_TABLE)));
} catch (IOException e) { } catch (IOException e) {
LOG.error(e); LOG.error(e);
} }

View File

@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration; 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.HTable;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.mapred.FileInputFormat; import org.apache.hadoop.mapred.FileInputFormat;
@ -57,7 +58,8 @@ public class TableInputFormat extends TableInputFormatBase implements
} }
setInputColumns(m_cols); setInputColumns(m_cols);
try { try {
setHTable(new HTable(HBaseConfiguration.create(job), tableNames[0].getName())); setHTable(
new HTable(HBaseConfiguration.create(job), TableName.valueOf(tableNames[0].getName())));
} catch (Exception e) { } catch (Exception e) {
LOG.error(StringUtils.stringifyException(e)); LOG.error(StringUtils.stringifyException(e));
} }

View File

@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hbase.HBaseConfiguration; 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.HTable;
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table; import org.apache.hadoop.hbase.client.Table;
@ -85,7 +86,7 @@ FileOutputFormat<ImmutableBytesWritable, Put> {
// expecting exactly one path // expecting exactly one path
String tableName = job.get(OUTPUT_TABLE); TableName tableName = TableName.valueOf(job.get(OUTPUT_TABLE));
HTable table = null; HTable table = null;
try { try {
table = new HTable(HBaseConfiguration.create(job), tableName); table = new HTable(HBaseConfiguration.create(job), tableName);

View File

@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HRegionLocation; 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.HTable;
import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Scan;
@ -80,13 +81,13 @@ public abstract class MultiTableInputFormatBase extends
TableSplit tSplit = (TableSplit) split; TableSplit tSplit = (TableSplit) split;
LOG.info(MessageFormat.format("Input split length: {0} bytes.", tSplit.getLength())); 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" throw new IOException("Cannot create a record reader because of a"
+ " previous error. Please look at the previous logs lines from" + " previous error. Please look at the previous logs lines from"
+ " the task's full log for more details."); + " the task's full log for more details.");
} }
Table table = Table table =
new HTable(context.getConfiguration(), tSplit.getTableName()); new HTable(context.getConfiguration(), tSplit.getTable());
TableRecordReader trr = this.tableRecordReader; TableRecordReader trr = this.tableRecordReader;
@ -133,7 +134,7 @@ public abstract class MultiTableInputFormatBase extends
HTable table = null; HTable table = null;
try { try {
table = new HTable(context.getConfiguration(), tableName); table = new HTable(context.getConfiguration(), TableName.valueOf(tableName));
Pair<byte[][], byte[][]> keys = table.getStartEndKeys(); Pair<byte[][], byte[][]> keys = table.getStartEndKeys();
if (keys == null || keys.getFirst() == null || if (keys == null || keys.getFirst() == null ||
keys.getFirst().length == 0) { keys.getFirst().length == 0) {

View File

@ -28,6 +28,7 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
import org.apache.hadoop.hbase.classification.InterfaceStability; import org.apache.hadoop.hbase.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration; 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.Delete;
import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.Mutation;
@ -102,7 +103,7 @@ public class MultiTableOutputFormat extends OutputFormat<ImmutableBytesWritable,
HTable getTable(ImmutableBytesWritable tableName) throws IOException { HTable getTable(ImmutableBytesWritable tableName) throws IOException {
if (!tables.containsKey(tableName)) { if (!tables.containsKey(tableName)) {
LOG.debug("Opening HTable \"" + Bytes.toString(tableName.get())+ "\" for writing"); LOG.debug("Opening HTable \"" + Bytes.toString(tableName.get())+ "\" for writing");
HTable table = new HTable(conf, tableName.get()); HTable table = new HTable(conf, TableName.valueOf(tableName.get()));
table.setAutoFlush(false, true); table.setAutoFlush(false, true);
tables.put(tableName, table); tables.put(tableName, table);
} }

View File

@ -44,6 +44,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MetaTableAccessor; import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@ -102,6 +103,35 @@ public class TableMapReduceUtil {
job, true); job, true);
} }
/**
* Use this before submitting a TableMap job. It will appropriately set up
* the job.
*
* @param table The table name to read from.
* @param scan The scan instance with the columns, time range etc.
* @param mapper The mapper class to use.
* @param outputKeyClass The class of the output key.
* @param outputValueClass The class of the output value.
* @param job The current job to adjust. Make sure the passed job is
* carrying all necessary HBase configuration.
* @throws IOException When setting up the details fails.
*/
public static void initTableMapperJob(TableName table,
Scan scan,
Class<? extends TableMapper> 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 * Use this before submitting a TableMap job. It will appropriately set up
* the job. * the job.

View File

@ -480,7 +480,7 @@ public final class Canary implements Tool {
Table table = null; Table table = null;
try { try {
table = new HTable(admin.getConfiguration(), tableDesc.getName()); table = new HTable(admin.getConfiguration(), tableDesc.getTableName());
} catch (TableNotFoundException e) { } catch (TableNotFoundException e) {
return; return;
} }
@ -679,7 +679,7 @@ public final class Canary implements Tool {
HTableDescriptor[] tableDescs = this.admin.listTables(); HTableDescriptor[] tableDescs = this.admin.listTables();
List<HRegionInfo> regions = null; List<HRegionInfo> regions = null;
for (HTableDescriptor tableDesc : tableDescs) { for (HTableDescriptor tableDesc : tableDescs) {
table = new HTable(this.admin.getConfiguration(), tableDesc.getName()); table = new HTable(this.admin.getConfiguration(), tableDesc.getTableName());
for (Map.Entry<HRegionInfo, ServerName> entry : table for (Map.Entry<HRegionInfo, ServerName> entry : table
.getRegionLocations().entrySet()) { .getRegionLocations().entrySet()) {

View File

@ -339,7 +339,7 @@ public class RegionSplitter {
"UniformSplit treats keys as arbitrary bytes.", opt); "UniformSplit treats keys as arbitrary bytes.", opt);
return; return;
} }
String tableName = cmd.getArgs()[0]; TableName tableName = TableName.valueOf(cmd.getArgs()[0]);
String splitClass = cmd.getArgs()[1]; String splitClass = cmd.getArgs()[1];
SplitAlgorithm splitAlgo = newSplitAlgoInstance(conf, splitClass); 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, String[] columnFamilies, Configuration conf) throws IOException,
InterruptedException { InterruptedException {
final int splitCount = conf.getInt("split.count", 0); final int splitCount = conf.getInt("split.count", 0);
@ -374,7 +374,7 @@ public class RegionSplitter {
LOG.debug("Creating table " + tableName + " with " + columnFamilies.length LOG.debug("Creating table " + tableName + " with " + columnFamilies.length
+ " column families. Presplitting to " + splitCount + " regions"); + " column families. Presplitting to " + splitCount + " regions");
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); HTableDescriptor desc = new HTableDescriptor(tableName);
for (String cf : columnFamilies) { for (String cf : columnFamilies) {
desc.addFamily(new HColumnDescriptor(Bytes.toBytes(cf))); desc.addFamily(new HColumnDescriptor(Bytes.toBytes(cf)));
} }
@ -399,7 +399,7 @@ public class RegionSplitter {
LOG.debug("Finished creating table with " + splitCount + " regions"); 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 { Configuration conf) throws IOException, InterruptedException {
final int minOS = conf.getInt("split.outstanding", 2); final int minOS = conf.getInt("split.outstanding", 2);

View File

@ -1231,7 +1231,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
desc.addFamily(hcd); desc.addFamily(hcd);
} }
getHBaseAdmin().createTable(desc); 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); desc.addFamily(hcd);
} }
getHBaseAdmin().createTable(desc); 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); getHBaseAdmin().createTable(desc, splitRows);
// HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are assigned // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are assigned
waitUntilAllRegionsAssigned(TableName.valueOf(tableName)); waitUntilAllRegionsAssigned(desc.getTableName());
return new HTable(getConfiguration(), tableName); return new HTable(getConfiguration(), desc.getTableName());
} }
/** /**
@ -2634,9 +2634,9 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
* @throws InterruptedException * @throws InterruptedException
* @throws IOException * @throws IOException
*/ */
public void waitTableAvailable(byte[] table) public void waitTableAvailable(TableName table)
throws InterruptedException, IOException { throws InterruptedException, IOException {
waitTableAvailable(getHBaseAdmin(), table, 30000); waitTableAvailable(getHBaseAdmin(), table.getName(), 30000);
} }
public void waitTableAvailable(Admin admin, byte[] table) public void waitTableAvailable(Admin admin, byte[] table)
@ -2676,9 +2676,9 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
* @throws InterruptedException * @throws InterruptedException
* @throws IOException * @throws IOException
*/ */
public void waitTableEnabled(byte[] table) public void waitTableEnabled(TableName table)
throws InterruptedException, IOException { throws InterruptedException, IOException {
waitTableEnabled(getHBaseAdmin(), table, 30000); waitTableEnabled(getHBaseAdmin(), table.getName(), 30000);
} }
public void waitTableEnabled(Admin admin, byte[] table) public void waitTableEnabled(Admin admin, byte[] table)

View File

@ -56,7 +56,7 @@ import com.google.common.collect.Lists;
@Category(MediumTests.class) @Category(MediumTests.class)
public class TestAcidGuarantees implements Tool { public class TestAcidGuarantees implements Tool {
protected static final Log LOG = LogFactory.getLog(TestAcidGuarantees.class); 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_A = Bytes.toBytes("A");
public static final byte [] FAMILY_B = Bytes.toBytes("B"); public static final byte [] FAMILY_B = Bytes.toBytes("B");
public static final byte [] FAMILY_C = Bytes.toBytes("C"); public static final byte [] FAMILY_C = Bytes.toBytes("C");

View File

@ -195,8 +195,8 @@ public class TestMultiVersions {
*/ */
@Test @Test
public void testScanMultipleVersions() throws Exception { public void testScanMultipleVersions() throws Exception {
final byte [] tableName = Bytes.toBytes("testScanMultipleVersions"); final TableName tableName = TableName.valueOf("testScanMultipleVersions");
final HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); final HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
final byte [][] rows = new byte[][] { final byte [][] rows = new byte[][] {
Bytes.toBytes("row_0200"), Bytes.toBytes("row_0200"),

View File

@ -611,8 +611,8 @@ public class TestAdmin {
@Test (timeout=300000) @Test (timeout=300000)
public void testCreateTableNumberOfRegions() throws IOException, InterruptedException { public void testCreateTableNumberOfRegions() throws IOException, InterruptedException {
byte[] tableName = Bytes.toBytes("testCreateTableNumberOfRegions"); TableName tableName = TableName.valueOf("testCreateTableNumberOfRegions");
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
admin.createTable(desc); admin.createTable(desc);
HTable ht = new HTable(TEST_UTIL.getConfiguration(), tableName); 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()); assertEquals("Table should have only 1 region", 1, regions.size());
ht.close(); ht.close();
byte [] TABLE_2 = Bytes.add(tableName, Bytes.toBytes("_2")); TableName TABLE_2 = TableName.valueOf(tableName.getNameAsString() + "_2");
desc = new HTableDescriptor(TableName.valueOf(TABLE_2)); desc = new HTableDescriptor(TABLE_2);
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
admin.createTable(desc, new byte[][]{new byte[]{42}}); admin.createTable(desc, new byte[][]{new byte[]{42}});
HTable ht2 = new HTable(TEST_UTIL.getConfiguration(), TABLE_2); 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()); assertEquals("Table should have only 2 region", 2, regions.size());
ht2.close(); ht2.close();
byte [] TABLE_3 = Bytes.add(tableName, Bytes.toBytes("_3")); TableName TABLE_3 = TableName.valueOf(tableName.getNameAsString() + "_3");
desc = new HTableDescriptor(TableName.valueOf(TABLE_3)); desc = new HTableDescriptor(TABLE_3);
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
admin.createTable(desc, "a".getBytes(), "z".getBytes(), 3); admin.createTable(desc, "a".getBytes(), "z".getBytes(), 3);
HTable ht3 = new HTable(TEST_UTIL.getConfiguration(), TABLE_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()); assertEquals("Table should have only 3 region", 3, regions.size());
ht3.close(); ht3.close();
byte [] TABLE_4 = Bytes.add(tableName, Bytes.toBytes("_4")); TableName TABLE_4 = TableName.valueOf(tableName.getNameAsString() + "_4");
desc = new HTableDescriptor(TableName.valueOf(TABLE_4)); desc = new HTableDescriptor(TABLE_4);
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
try { try {
admin.createTable(desc, "a".getBytes(), "z".getBytes(), 2); admin.createTable(desc, "a".getBytes(), "z".getBytes(), 2);
@ -648,8 +648,8 @@ public class TestAdmin {
// Expected // Expected
} }
byte [] TABLE_5 = Bytes.add(tableName, Bytes.toBytes("_5")); TableName TABLE_5 = TableName.valueOf(tableName.getNameAsString() + "_5");
desc = new HTableDescriptor(TableName.valueOf(TABLE_5)); desc = new HTableDescriptor(TABLE_5);
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY)); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
admin.createTable(desc, new byte[] {1}, new byte[] {127}, 16); admin.createTable(desc, new byte[] {1}, new byte[] {127}, 16);
HTable ht5 = new HTable(TEST_UTIL.getConfiguration(), TABLE_5); HTable ht5 = new HTable(TEST_UTIL.getConfiguration(), TABLE_5);

View File

@ -171,7 +171,7 @@ public class TestFromClientSide {
*/ */
@Test @Test
public void testKeepDeletedCells() throws Exception { 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[] FAMILY = Bytes.toBytes("family");
final byte[] C0 = Bytes.toBytes("c0"); final byte[] C0 = Bytes.toBytes("c0");
@ -399,7 +399,7 @@ public class TestFromClientSide {
*/ */
@Test @Test
public void testWeirdCacheBehaviour() throws Exception { public void testWeirdCacheBehaviour() throws Exception {
byte [] TABLE = Bytes.toBytes("testWeirdCacheBehaviour"); TableName TABLE = TableName.valueOf("testWeirdCacheBehaviour");
byte [][] FAMILIES = new byte[][] { Bytes.toBytes("trans-blob"), byte [][] FAMILIES = new byte[][] { Bytes.toBytes("trans-blob"),
Bytes.toBytes("trans-type"), Bytes.toBytes("trans-date"), Bytes.toBytes("trans-type"), Bytes.toBytes("trans-date"),
Bytes.toBytes("trans-tags"), Bytes.toBytes("trans-group") }; Bytes.toBytes("trans-tags"), Bytes.toBytes("trans-group") };
@ -4208,8 +4208,7 @@ public class TestFromClientSide {
// Test that attribute changes were applied // Test that attribute changes were applied
desc = a.getTableDescriptor(); desc = a.getTableDescriptor();
assertTrue("wrong table descriptor returned", assertEquals("wrong table descriptor returned", desc.getTableName(), tableAname);
desc.getTableName().equals(tableAname));
// check HTD attribute // check HTD attribute
value = desc.getValue(attrName); value = desc.getValue(attrName);
assertFalse("missing HTD attribute value", value == null); assertFalse("missing HTD attribute value", value == null);

View File

@ -235,7 +235,7 @@ public class TestHCM {
final ServerName sn = rs.getRegionServer().getServerName(); final ServerName sn = rs.getRegionServer().getServerName();
HTable t = TEST_UTIL.createTable(tn, cf); HTable t = TEST_UTIL.createTable(tn, cf);
TEST_UTIL.waitTableAvailable(tn.getName()); TEST_UTIL.waitTableAvailable(tn);
while(TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager(). while(TEST_UTIL.getHBaseCluster().getMaster().getAssignmentManager().
getRegionStates().isRegionsInTransition()){ getRegionStates().isRegionsInTransition()){
@ -332,8 +332,8 @@ public class TestHCM {
private void testConnectionClose(boolean allowsInterrupt) throws Exception { private void testConnectionClose(boolean allowsInterrupt) throws Exception {
String tableName = "HCM-testConnectionClose" + allowsInterrupt; TableName tableName = TableName.valueOf("HCM-testConnectionClose" + allowsInterrupt);
TEST_UTIL.createTable(tableName.getBytes(), FAM_NAM).close(); TEST_UTIL.createTable(tableName, FAM_NAM).close();
boolean previousBalance = TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, true); 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.setInt(RpcClient.FAILED_SERVER_EXPIRY_KEY, 0); // Server do not really expire
c2.setBoolean(RpcClient.SPECIFIC_WRITE_THREAD, allowsInterrupt); 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 put = new Put(ROW);
put.add(FAM_NAM, ROW, ROW); put.add(FAM_NAM, ROW, ROW);
@ -414,8 +414,8 @@ public class TestHCM {
*/ */
@Test @Test
public void testConnectionIdle() throws Exception { public void testConnectionIdle() throws Exception {
String tableName = "HCM-testConnectionIdle"; TableName tableName = TableName.valueOf("HCM-testConnectionIdle");
TEST_UTIL.createTable(tableName.getBytes(), FAM_NAM).close(); TEST_UTIL.createTable(tableName, FAM_NAM).close();
int idleTime = 20000; int idleTime = 20000;
boolean previousBalance = TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, true); 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(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1); // Don't retry: retry = test failed
c2.setInt(RpcClient.IDLE_TIME, idleTime); 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 put = new Put(ROW);
put.add(FAM_NAM, ROW, ROW); put.add(FAM_NAM, ROW, ROW);
@ -477,9 +477,9 @@ public class TestHCM {
return; 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); boolean previousBalance = TEST_UTIL.getHBaseAdmin().setBalancerRunning(false, true);
Configuration c2 = new Configuration(TEST_UTIL.getConfiguration()); Configuration c2 = new Configuration(TEST_UTIL.getConfiguration());

View File

@ -40,14 +40,14 @@ import org.junit.runners.Suite;
@Category(MediumTests.class) @Category(MediumTests.class)
public class TestHTablePool { public class TestHTablePool {
private static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); 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 { public abstract static class TestHTablePoolType {
@BeforeClass @BeforeClass
public static void setUpBeforeClass() throws Exception { public static void setUpBeforeClass() throws Exception {
TEST_UTIL.startMiniCluster(1); TEST_UTIL.startMiniCluster(1);
TEST_UTIL.createTable(TABLENAME, HConstants.CATALOG_FAMILY); TEST_UTIL.createTable(TableName.valueOf(TABLENAME), HConstants.CATALOG_FAMILY);
} }
@AfterClass @AfterClass
@ -61,7 +61,7 @@ public class TestHTablePool {
public void testTableWithStringName() throws Exception { public void testTableWithStringName() throws Exception {
HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(),
Integer.MAX_VALUE, getPoolType()); Integer.MAX_VALUE, getPoolType());
String tableName = Bytes.toString(TABLENAME); String tableName = TABLENAME;
// Request a table from an empty pool // Request a table from an empty pool
Table table = pool.getTable(tableName); Table table = pool.getTable(tableName);
@ -130,7 +130,7 @@ public class TestHTablePool {
public void testProxyImplementationReturned() { public void testProxyImplementationReturned() {
HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(),
Integer.MAX_VALUE); Integer.MAX_VALUE);
String tableName = Bytes.toString(TABLENAME);// Request a table from String tableName = TABLENAME;// Request a table from
// an // an
// empty pool // empty pool
Table table = pool.getTable(tableName); Table table = pool.getTable(tableName);
@ -143,7 +143,7 @@ public class TestHTablePool {
public void testDeprecatedUsagePattern() throws IOException { public void testDeprecatedUsagePattern() throws IOException {
HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(),
Integer.MAX_VALUE); Integer.MAX_VALUE);
String tableName = Bytes.toString(TABLENAME);// Request a table from String tableName = TABLENAME;// Request a table from
// an // an
// empty pool // empty pool
@ -165,14 +165,14 @@ public class TestHTablePool {
public void testReturnDifferentTable() throws IOException { public void testReturnDifferentTable() throws IOException {
HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(),
Integer.MAX_VALUE); Integer.MAX_VALUE);
String tableName = Bytes.toString(TABLENAME);// Request a table from String tableName = TABLENAME;// Request a table from
// an // an
// empty pool // empty pool
// get table will return proxy implementation // get table will return proxy implementation
final Table table = pool.getTable(tableName); final Table table = pool.getTable(tableName);
HTableInterface alienTable = new HTable(TEST_UTIL.getConfiguration(), HTableInterface alienTable = new HTable(TEST_UTIL.getConfiguration(),
TABLENAME) { TableName.valueOf(TABLENAME)) {
// implementation doesn't matter as long the table is not from // implementation doesn't matter as long the table is not from
// pool // pool
}; };
@ -189,7 +189,7 @@ public class TestHTablePool {
public void testHTablePoolCloseTwice() throws Exception { public void testHTablePoolCloseTwice() throws Exception {
HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(), HTablePool pool = new HTablePool(TEST_UTIL.getConfiguration(),
Integer.MAX_VALUE, getPoolType()); Integer.MAX_VALUE, getPoolType());
String tableName = Bytes.toString(TABLENAME); String tableName = TABLENAME;
// Request a table from an empty pool // Request a table from an empty pool
Table table = pool.getTable(tableName); Table table = pool.getTable(tableName);
@ -280,12 +280,12 @@ public class TestHTablePool {
} }
Assert.assertEquals(4, Assert.assertEquals(4,
pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); pool.getCurrentPoolSize(TABLENAME));
pool.closeTablePool(TABLENAME); pool.closeTablePool(TABLENAME);
Assert.assertEquals(0, Assert.assertEquals(0,
pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); pool.getCurrentPoolSize(TABLENAME));
} }
} }
@ -356,12 +356,12 @@ public class TestHTablePool {
} }
Assert.assertEquals(1, Assert.assertEquals(1,
pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); pool.getCurrentPoolSize(TABLENAME));
pool.closeTablePool(TABLENAME); pool.closeTablePool(TABLENAME);
Assert.assertEquals(0, Assert.assertEquals(0,
pool.getCurrentPoolSize(Bytes.toString(TABLENAME))); pool.getCurrentPoolSize(TABLENAME));
} }
} }

View File

@ -81,7 +81,7 @@ public class TestMultiParallel {
UTIL.startMiniCluster(slaves); UTIL.startMiniCluster(slaves);
HTable t = UTIL.createTable(TEST_TABLE, Bytes.toBytes(FAMILY)); HTable t = UTIL.createTable(TEST_TABLE, Bytes.toBytes(FAMILY));
UTIL.createMultiRegions(t, Bytes.toBytes(FAMILY)); UTIL.createMultiRegions(t, Bytes.toBytes(FAMILY));
UTIL.waitTableEnabled(TEST_TABLE.getName()); UTIL.waitTableEnabled(TEST_TABLE);
t.close(); t.close();
} }

View File

@ -532,7 +532,7 @@ public class TestClassLoading {
private void waitForTable(TableName name) throws InterruptedException, IOException { private void waitForTable(TableName name) throws InterruptedException, IOException {
// First wait until all regions are online // 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 // Now wait a bit longer for the coprocessor hosts to load the CPs
Thread.sleep(1000); Thread.sleep(1000);
} }

View File

@ -70,7 +70,7 @@ public class TestFilterWithScanLimits {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static Configuration conf = null; private static Configuration conf = null;
private static HBaseAdmin admin = null; private static HBaseAdmin admin = null;
private static byte[] name = Bytes.toBytes("test"); private static TableName name = TableName.valueOf("test");
@Test @Test
public void testScanWithLimit() { public void testScanWithLimit() {
@ -140,7 +140,7 @@ public class TestFilterWithScanLimits {
assertNotNull("HBaseAdmin is not initialized successfully.", admin); assertNotNull("HBaseAdmin is not initialized successfully.", admin);
if (admin != null) { if (admin != null) {
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name)); HTableDescriptor desc = new HTableDescriptor(name);
HColumnDescriptor coldef = new HColumnDescriptor(Bytes.toBytes("f1")); HColumnDescriptor coldef = new HColumnDescriptor(Bytes.toBytes("f1"));
desc.addFamily(coldef); desc.addFamily(coldef);

View File

@ -64,7 +64,7 @@ public class TestFilterWrapper {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static Configuration conf = null; private static Configuration conf = null;
private static HBaseAdmin admin = null; private static HBaseAdmin admin = null;
private static byte[] name = Bytes.toBytes("test"); private static TableName name = TableName.valueOf("test");
@Test @Test
public void testFilterWrapper() { public void testFilterWrapper() {
@ -143,7 +143,7 @@ public class TestFilterWrapper {
assertNotNull("HBaseAdmin is not initialized successfully.", admin); assertNotNull("HBaseAdmin is not initialized successfully.", admin);
if (admin != null) { if (admin != null) {
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name)); HTableDescriptor desc = new HTableDescriptor(name);
HColumnDescriptor coldef = new HColumnDescriptor(Bytes.toBytes("f1")); HColumnDescriptor coldef = new HColumnDescriptor(Bytes.toBytes("f1"));
desc.addFamily(coldef); desc.addFamily(coldef);

View File

@ -448,7 +448,7 @@ public class TestHFileOutputFormat {
LOG.info("Waiting for table to disable"); LOG.info("Waiting for table to disable");
} }
admin.enableTable(TABLE_NAME); admin.enableTable(TABLE_NAME);
util.waitTableAvailable(TABLE_NAME.getName()); util.waitTableAvailable(TABLE_NAME);
assertEquals("Data should remain after reopening of regions", assertEquals("Data should remain after reopening of regions",
tableDigestBefore, util.checksumRows(table)); tableDigestBefore, util.checksumRows(table));
} finally { } finally {
@ -1048,7 +1048,7 @@ public class TestHFileOutputFormat {
Configuration conf = HBaseConfiguration.create(); Configuration conf = HBaseConfiguration.create();
util = new HBaseTestingUtility(conf); util = new HBaseTestingUtility(conf);
if ("newtable".equals(args[0])) { if ("newtable".equals(args[0])) {
byte[] tname = args[1].getBytes(); TableName tname = TableName.valueOf(args[1]);
HTable table = util.createTable(tname, FAMILIES); HTable table = util.createTable(tname, FAMILIES);
HBaseAdmin admin = new HBaseAdmin(conf); HBaseAdmin admin = new HBaseAdmin(conf);
admin.disableTable(tname); admin.disableTable(tname);
@ -1056,7 +1056,7 @@ public class TestHFileOutputFormat {
util.createMultiRegions(conf, table, FAMILIES[0], startKeys); util.createMultiRegions(conf, table, FAMILIES[0], startKeys);
admin.enableTable(tname); admin.enableTable(tname);
} else if ("incremental".equals(args[0])) { } else if ("incremental".equals(args[0])) {
byte[] tname = args[1].getBytes(); TableName tname = TableName.valueOf(args[1]);
HTable table = new HTable(conf, tname); HTable table = new HTable(conf, tname);
Path outDir = new Path("incremental-out"); Path outDir = new Path("incremental-out");
runIncrementalPELoad(conf, table, outDir); runIncrementalPELoad(conf, table, outDir);

View File

@ -447,7 +447,7 @@ public class TestHFileOutputFormat2 {
LOG.info("Waiting for table to disable"); LOG.info("Waiting for table to disable");
} }
admin.enableTable(TABLE_NAME); admin.enableTable(TABLE_NAME);
util.waitTableAvailable(TABLE_NAME.getName()); util.waitTableAvailable(TABLE_NAME);
assertEquals("Data should remain after reopening of regions", assertEquals("Data should remain after reopening of regions",
tableDigestBefore, util.checksumRows(table)); tableDigestBefore, util.checksumRows(table));
} finally { } finally {
@ -1056,7 +1056,7 @@ public class TestHFileOutputFormat2 {
util.createMultiRegions(conf, table, FAMILIES[0], startKeys); util.createMultiRegions(conf, table, FAMILIES[0], startKeys);
admin.enableTable(tname); admin.enableTable(tname);
} else if ("incremental".equals(args[0])) { } else if ("incremental".equals(args[0])) {
byte[] tname = args[1].getBytes(); TableName tname = TableName.valueOf(args[1]);
HTable table = new HTable(conf, tname); HTable table = new HTable(conf, tname);
Path outDir = new Path("incremental-out"); Path outDir = new Path("incremental-out");
runIncrementalPELoad(conf, table, outDir); runIncrementalPELoad(conf, table, outDir);

View File

@ -55,7 +55,7 @@ public class TestSecureLoadIncrementalHFiles extends TestLoadIncrementalHFiles{
util.startMiniCluster(); util.startMiniCluster();
// Wait for the ACL table to become available // Wait for the ACL table to become available
util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); util.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
setupNamespace(); setupNamespace();
} }

View File

@ -57,7 +57,7 @@ public class TestSecureLoadIncrementalHFilesSplitRecovery extends TestLoadIncrem
util.startMiniCluster(); util.startMiniCluster();
// Wait for the ACL table to become available // 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 //Disabling this test as it does not work in secure mode

View File

@ -54,7 +54,7 @@ import org.junit.Test;
public abstract class TestTableMapReduceBase { public abstract class TestTableMapReduceBase {
protected static final HBaseTestingUtility UTIL = new HBaseTestingUtility(); 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[] INPUT_FAMILY = Bytes.toBytes("contents");
protected static final byte[] OUTPUT_FAMILY = Bytes.toBytes("text"); protected static final byte[] OUTPUT_FAMILY = Bytes.toBytes("text");

View File

@ -76,7 +76,7 @@ public class TestTimeRangeMapRed {
static final long MINSTAMP = 1245620005; static final long MINSTAMP = 1245620005;
static final long MAXSTAMP = 1245620100 + 1; // maxStamp itself is excluded. so increment it. 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[] FAMILY_NAME = Bytes.toBytes("text");
static final byte[] COLUMN_NAME = Bytes.toBytes("input"); static final byte[] COLUMN_NAME = Bytes.toBytes("input");
@ -144,7 +144,7 @@ public class TestTimeRangeMapRed {
@Test @Test
public void testTimeRangeMapRed() public void testTimeRangeMapRed()
throws IOException, InterruptedException, ClassNotFoundException { 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); final HColumnDescriptor col = new HColumnDescriptor(FAMILY_NAME);
col.setMaxVersions(Integer.MAX_VALUE); col.setMaxVersions(Integer.MAX_VALUE);
desc.addFamily(col); desc.addFamily(col);
@ -177,7 +177,7 @@ public class TestTimeRangeMapRed {
scan.addColumn(FAMILY_NAME, COLUMN_NAME); scan.addColumn(FAMILY_NAME, COLUMN_NAME);
scan.setTimeRange(MINSTAMP, MAXSTAMP); scan.setTimeRange(MINSTAMP, MAXSTAMP);
scan.setMaxVersions(); scan.setMaxVersions();
TableMapReduceUtil.initTableMapperJob(Bytes.toString(TABLE_NAME), TableMapReduceUtil.initTableMapperJob(TABLE_NAME,
scan, ProcessTimeRangeMapper.class, Text.class, Text.class, job); scan, ProcessTimeRangeMapper.class, Text.class, Text.class, job);
job.waitForCompletion(true); job.waitForCompletion(true);
} catch (IOException e) { } catch (IOException e) {

View File

@ -112,7 +112,7 @@ public class TestMasterOperationsForRegionReplicas {
desc.setRegionReplication(numReplica); desc.setRegionReplication(numReplica);
desc.addFamily(new HColumnDescriptor("family")); desc.addFamily(new HColumnDescriptor("family"));
admin.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), numRegions); admin.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), numRegions);
TEST_UTIL.waitTableEnabled(table.getName()); TEST_UTIL.waitTableEnabled(table);
validateNumberOfRowsInMeta(table, numRegions, admin.getConnection()); validateNumberOfRowsInMeta(table, numRegions, admin.getConnection());
List<HRegionInfo> hris = MetaTableAccessor.getTableRegions(TEST_UTIL.getZooKeeperWatcher(), List<HRegionInfo> hris = MetaTableAccessor.getTableRegions(TEST_UTIL.getZooKeeperWatcher(),
@ -169,7 +169,7 @@ public class TestMasterOperationsForRegionReplicas {
TEST_UTIL.getConfiguration().setBoolean("hbase.master.startup.retainassign", true); TEST_UTIL.getConfiguration().setBoolean("hbase.master.startup.retainassign", true);
TEST_UTIL.shutdownMiniHBaseCluster(); TEST_UTIL.shutdownMiniHBaseCluster();
TEST_UTIL.startMiniHBaseCluster(1, numSlaves); TEST_UTIL.startMiniHBaseCluster(1, numSlaves);
TEST_UTIL.waitTableEnabled(table.getName()); TEST_UTIL.waitTableEnabled(table);
admin.close(); admin.close();
admin = new HBaseAdmin(conf); admin = new HBaseAdmin(conf);
validateFromSnapshotFromMeta(TEST_UTIL, table, numRegions, numReplica, validateFromSnapshotFromMeta(TEST_UTIL, table, numRegions, numReplica,
@ -179,7 +179,7 @@ public class TestMasterOperationsForRegionReplicas {
// one server running // one server running
TEST_UTIL.shutdownMiniHBaseCluster(); TEST_UTIL.shutdownMiniHBaseCluster();
TEST_UTIL.startMiniHBaseCluster(1, 1); TEST_UTIL.startMiniHBaseCluster(1, 1);
TEST_UTIL.waitTableEnabled(table.getName()); TEST_UTIL.waitTableEnabled(table);
admin.close(); admin.close();
admin = new HBaseAdmin(conf); admin = new HBaseAdmin(conf);
validateSingleRegionServerAssignment(admin.getConnection(), numRegions, numReplica); validateSingleRegionServerAssignment(admin.getConnection(), numRegions, numReplica);
@ -243,7 +243,7 @@ public class TestMasterOperationsForRegionReplicas {
desc.setRegionReplication(numReplica); desc.setRegionReplication(numReplica);
desc.addFamily(new HColumnDescriptor("family")); desc.addFamily(new HColumnDescriptor("family"));
admin.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), numRegions); admin.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), numRegions);
TEST_UTIL.waitTableEnabled(table.getName()); TEST_UTIL.waitTableEnabled(table);
Set<byte[]> tableRows = new HashSet<byte[]>(); Set<byte[]> tableRows = new HashSet<byte[]>();
List<HRegionInfo> hris = MetaTableAccessor.getTableRegions(TEST_UTIL.getZooKeeperWatcher(), List<HRegionInfo> hris = MetaTableAccessor.getTableRegions(TEST_UTIL.getZooKeeperWatcher(),
admin.getConnection(), table); admin.getConnection(), table);

View File

@ -212,7 +212,7 @@ public class TestRegionPlacement {
@Test @Test
public void testRegionPlacement() throws Exception { public void testRegionPlacement() throws Exception {
String tableStr = "testRegionAssignment"; String tableStr = "testRegionAssignment";
byte[] table = Bytes.toBytes(tableStr); TableName table = TableName.valueOf(tableStr);
// Create a table with REGION_NUM regions. // Create a table with REGION_NUM regions.
createTable(table, REGION_NUM); createTable(table, REGION_NUM);
@ -667,7 +667,7 @@ public class TestRegionPlacement {
* @return * @return
* @throws IOException * @throws IOException
*/ */
private static void createTable(byte[] tableName, int regionNum) private static void createTable(TableName tableName, int regionNum)
throws IOException { throws IOException {
int expectedRegions = regionNum; int expectedRegions = regionNum;
byte[][] splitKeys = new byte[expectedRegions - 1][]; byte[][] splitKeys = new byte[expectedRegions - 1][];
@ -676,7 +676,7 @@ public class TestRegionPlacement {
splitKeys[i - 1] = new byte[] { splitKey, splitKey, splitKey }; 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)); desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
admin.createTable(desc, splitKeys); admin.createTable(desc, splitKeys);

View File

@ -99,7 +99,7 @@ public class TestRestartCluster {
UTIL.createTable(TABLE, FAMILY); UTIL.createTable(TABLE, FAMILY);
} }
for(TableName TABLE : TABLES) { for(TableName TABLE : TABLES) {
UTIL.waitTableEnabled(TABLE.getName()); UTIL.waitTableEnabled(TABLE);
} }
List<HRegionInfo> allRegions = List<HRegionInfo> allRegions =
@ -128,7 +128,7 @@ public class TestRestartCluster {
} catch(TableExistsException tee) { } catch(TableExistsException tee) {
LOG.info("Table already exists as expected"); 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); UTIL.createTable(TABLE, FAMILY);
} }
for(TableName TABLE : TABLES) { for(TableName TABLE : TABLES) {
UTIL.waitTableEnabled(TABLE.getName()); UTIL.waitTableEnabled(TABLE);
} }
HMaster master = UTIL.getMiniHBaseCluster().getMaster(); HMaster master = UTIL.getMiniHBaseCluster().getMaster();

View File

@ -392,6 +392,7 @@ public class TestTableLockManager {
alterThread.start(); alterThread.start();
splitThread.start(); splitThread.start();
TEST_UTIL.waitTableEnabled(tableName);
while (true) { while (true) {
List<HRegionInfo> regions = admin.getTableRegions(tableName); List<HRegionInfo> regions = admin.getTableRegions(tableName);
LOG.info(String.format("Table #regions: %d regions: %s:", regions.size(), regions)); LOG.info(String.format("Table #regions: %d regions: %s:", regions.size(), regions));

View File

@ -207,7 +207,7 @@ public class TestEncryptionKeyRotation {
TEST_UTIL.getHBaseAdmin().createTable(htd); TEST_UTIL.getHBaseAdmin().createTable(htd);
TEST_UTIL.waitTableAvailable(htd.getName(), 5000); TEST_UTIL.waitTableAvailable(htd.getName(), 5000);
// Create a store file // Create a store file
Table table = new HTable(conf, htd.getName()); Table table = new HTable(conf, htd.getTableName());
try { try {
table.put(new Put(Bytes.toBytes("testrow")) table.put(new Put(Bytes.toBytes("testrow"))
.add(hcd.getName(), Bytes.toBytes("q"), Bytes.toBytes("value"))); .add(hcd.getName(), Bytes.toBytes("q"), Bytes.toBytes("value")));

View File

@ -186,11 +186,11 @@ public class TestFSErrorsExposed {
util.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 3); util.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 3);
util.startMiniCluster(1); util.startMiniCluster(1);
byte[] tableName = Bytes.toBytes("table"); TableName tableName = TableName.valueOf("table");
byte[] fam = Bytes.toBytes("fam"); byte[] fam = Bytes.toBytes("fam");
Admin admin = new HBaseAdmin(util.getConfiguration()); Admin admin = new HBaseAdmin(util.getConfiguration());
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); HTableDescriptor desc = new HTableDescriptor(tableName);
desc.addFamily(new HColumnDescriptor(fam) desc.addFamily(new HColumnDescriptor(fam)
.setMaxVersions(1) .setMaxVersions(1)
.setBlockCacheEnabled(false) .setBlockCacheEnabled(false)

View File

@ -93,8 +93,8 @@ public class TestJoinedScanners {
cluster = htu.startMiniCluster(1, regionServersCount, dataNodeHosts); cluster = htu.startMiniCluster(1, regionServersCount, dataNodeHosts);
byte [][] families = {cf_essential, cf_joined}; byte [][] families = {cf_essential, cf_joined};
byte[] tableName = Bytes.toBytes(this.getClass().getSimpleName()); TableName tableName = TableName.valueOf(this.getClass().getSimpleName());
HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName)); HTableDescriptor desc = new HTableDescriptor(tableName);
for(byte[] family : families) { for(byte[] family : families) {
HColumnDescriptor hcd = new HColumnDescriptor(family); HColumnDescriptor hcd = new HColumnDescriptor(family);
hcd.setDataBlockEncoding(blockEncoding); hcd.setDataBlockEncoding(blockEncoding);

View File

@ -74,7 +74,7 @@ public class TestMasterReplication {
private static final long SLEEP_TIME = 500; private static final long SLEEP_TIME = 500;
private static final int NB_RETRIES = 10; 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[] famName = Bytes.toBytes("f");
private static final byte[] row = Bytes.toBytes("row"); private static final byte[] row = Bytes.toBytes("row");
private static final byte[] row1 = Bytes.toBytes("row1"); private static final byte[] row1 = Bytes.toBytes("row1");
@ -107,7 +107,7 @@ public class TestMasterReplication {
CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY, CoprocessorHost.USER_REGION_COPROCESSOR_CONF_KEY,
CoprocessorCounter.class.getName()); CoprocessorCounter.class.getName());
table = new HTableDescriptor(TableName.valueOf(tableName)); table = new HTableDescriptor(tableName);
HColumnDescriptor fam = new HColumnDescriptor(famName); HColumnDescriptor fam = new HColumnDescriptor(famName);
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
table.addFamily(fam); table.addFamily(fam);
@ -345,7 +345,7 @@ public class TestMasterReplication {
} }
@SuppressWarnings("resource") @SuppressWarnings("resource")
private Table[] getHTablesOnClusters(byte[] tableName) throws Exception { private Table[] getHTablesOnClusters(TableName tableName) throws Exception {
int numClusters = utilities.length; int numClusters = utilities.length;
Table[] htables = new Table[numClusters]; Table[] htables = new Table[numClusters];
for (int i = 0; i < numClusters; i++) { for (int i = 0; i < numClusters; i++) {

View File

@ -60,7 +60,7 @@ public class TestMultiSlaveReplication {
private static final long SLEEP_TIME = 500; private static final long SLEEP_TIME = 500;
private static final int NB_RETRIES = 100; 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[] famName = Bytes.toBytes("f");
private static final byte[] row = Bytes.toBytes("row"); private static final byte[] row = Bytes.toBytes("row");
private static final byte[] row1 = Bytes.toBytes("row1"); private static final byte[] row1 = Bytes.toBytes("row1");
@ -106,7 +106,7 @@ public class TestMultiSlaveReplication {
utility3.setZkCluster(miniZK); utility3.setZkCluster(miniZK);
new ZooKeeperWatcher(conf3, "cluster3", null, true); new ZooKeeperWatcher(conf3, "cluster3", null, true);
table = new HTableDescriptor(TableName.valueOf(tableName)); table = new HTableDescriptor(tableName);
HColumnDescriptor fam = new HColumnDescriptor(famName); HColumnDescriptor fam = new HColumnDescriptor(famName);
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
table.addFamily(fam); table.addFamily(fam);

View File

@ -65,10 +65,10 @@ public class TestPerTableCFReplication {
private static final long SLEEP_TIME = 500; private static final long SLEEP_TIME = 500;
private static final int NB_RETRIES = 100; 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[] tabAName = Bytes.toBytes("TA"); private static final TableName tabAName = TableName.valueOf("TA");
private static final byte[] tabBName = Bytes.toBytes("TB"); private static final TableName tabBName = TableName.valueOf("TB");
private static final byte[] tabCName = Bytes.toBytes("TC"); private static final TableName tabCName = TableName.valueOf("TC");
private static final byte[] famName = Bytes.toBytes("f"); private static final byte[] famName = Bytes.toBytes("f");
private static final byte[] f1Name = Bytes.toBytes("f1"); private static final byte[] f1Name = Bytes.toBytes("f1");
private static final byte[] f2Name = Bytes.toBytes("f2"); private static final byte[] f2Name = Bytes.toBytes("f2");
@ -119,7 +119,7 @@ public class TestPerTableCFReplication {
utility3.setZkCluster(miniZK); utility3.setZkCluster(miniZK);
new ZooKeeperWatcher(conf3, "cluster3", null, true); new ZooKeeperWatcher(conf3, "cluster3", null, true);
table = new HTableDescriptor(TableName.valueOf(tableName)); table = new HTableDescriptor(tableName);
HColumnDescriptor fam = new HColumnDescriptor(famName); HColumnDescriptor fam = new HColumnDescriptor(famName);
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
table.addFamily(fam); table.addFamily(fam);

View File

@ -75,7 +75,7 @@ public class TestReplicationBase {
protected static final long SLEEP_TIME = 500; protected static final long SLEEP_TIME = 500;
protected static final int NB_RETRIES = 10; 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[] famName = Bytes.toBytes("f");
protected static final byte[] row = Bytes.toBytes("row"); protected static final byte[] row = Bytes.toBytes("row");
protected static final byte[] noRepfamName = Bytes.toBytes("norep"); protected static final byte[] noRepfamName = Bytes.toBytes("norep");
@ -129,7 +129,7 @@ public class TestReplicationBase {
utility1.startMiniCluster(2); utility1.startMiniCluster(2);
utility2.startMiniCluster(2); utility2.startMiniCluster(2);
HTableDescriptor table = new HTableDescriptor(TableName.valueOf(tableName)); HTableDescriptor table = new HTableDescriptor(tableName);
HColumnDescriptor fam = new HColumnDescriptor(famName); HColumnDescriptor fam = new HColumnDescriptor(famName);
fam.setMaxVersions(3); fam.setMaxVersions(3);
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);

View File

@ -445,7 +445,7 @@ public class TestReplicationSmallTests extends TestReplicationBase {
// identical since it does the check // identical since it does the check
testSmallBatch(); testSmallBatch();
String[] args = new String[] {"2", Bytes.toString(tableName)}; String[] args = new String[] {"2", tableName.getNameAsString()};
Job job = VerifyReplication.createSubmittableJob(CONF_WITH_LOCALFS, args); Job job = VerifyReplication.createSubmittableJob(CONF_WITH_LOCALFS, args);
if (job == null) { if (job == null) {
fail("Job wasn't created, see the log"); fail("Job wasn't created, see the log");

View File

@ -43,8 +43,8 @@ public class TestReplicationSyncUpTool extends TestReplicationBase {
private static final Log LOG = LogFactory.getLog(TestReplicationSyncUpTool.class); private static final Log LOG = LogFactory.getLog(TestReplicationSyncUpTool.class);
private static final byte[] t1_su = Bytes.toBytes("t1_syncup"); private static final TableName t1_su = TableName.valueOf("t1_syncup");
private static final byte[] t2_su = Bytes.toBytes("t2_syncup"); private static final TableName t2_su = TableName.valueOf("t2_syncup");
private static final byte[] famName = Bytes.toBytes("cf1"); private static final byte[] famName = Bytes.toBytes("cf1");
private static final byte[] qualName = Bytes.toBytes("q1"); private static final byte[] qualName = Bytes.toBytes("q1");
@ -61,27 +61,27 @@ public class TestReplicationSyncUpTool extends TestReplicationBase {
HColumnDescriptor fam; HColumnDescriptor fam;
t1_syncupSource = new HTableDescriptor(TableName.valueOf(t1_su)); t1_syncupSource = new HTableDescriptor(t1_su);
fam = new HColumnDescriptor(famName); fam = new HColumnDescriptor(famName);
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
t1_syncupSource.addFamily(fam); t1_syncupSource.addFamily(fam);
fam = new HColumnDescriptor(noRepfamName); fam = new HColumnDescriptor(noRepfamName);
t1_syncupSource.addFamily(fam); t1_syncupSource.addFamily(fam);
t1_syncupTarget = new HTableDescriptor(TableName.valueOf(t1_su)); t1_syncupTarget = new HTableDescriptor(t1_su);
fam = new HColumnDescriptor(famName); fam = new HColumnDescriptor(famName);
t1_syncupTarget.addFamily(fam); t1_syncupTarget.addFamily(fam);
fam = new HColumnDescriptor(noRepfamName); fam = new HColumnDescriptor(noRepfamName);
t1_syncupTarget.addFamily(fam); t1_syncupTarget.addFamily(fam);
t2_syncupSource = new HTableDescriptor(TableName.valueOf(t2_su)); t2_syncupSource = new HTableDescriptor(t2_su);
fam = new HColumnDescriptor(famName); fam = new HColumnDescriptor(famName);
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
t2_syncupSource.addFamily(fam); t2_syncupSource.addFamily(fam);
fam = new HColumnDescriptor(noRepfamName); fam = new HColumnDescriptor(noRepfamName);
t2_syncupSource.addFamily(fam); t2_syncupSource.addFamily(fam);
t2_syncupTarget = new HTableDescriptor(TableName.valueOf(t2_su)); t2_syncupTarget = new HTableDescriptor(t2_su);
fam = new HColumnDescriptor(famName); fam = new HColumnDescriptor(famName);
t2_syncupTarget.addFamily(fam); t2_syncupTarget.addFamily(fam);
fam = new HColumnDescriptor(noRepfamName); fam = new HColumnDescriptor(noRepfamName);

View File

@ -80,7 +80,7 @@ public class TestReplicationWithTags {
private static final long SLEEP_TIME = 500; private static final long SLEEP_TIME = 500;
private static final int NB_RETRIES = 10; 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[] FAMILY = Bytes.toBytes("f");
private static final byte[] ROW = Bytes.toBytes("row"); private static final byte[] ROW = Bytes.toBytes("row");
@ -131,7 +131,7 @@ public class TestReplicationWithTags {
utility1.startMiniCluster(2); utility1.startMiniCluster(2);
utility2.startMiniCluster(2); utility2.startMiniCluster(2);
HTableDescriptor table = new HTableDescriptor(TableName.valueOf(TABLE_NAME)); HTableDescriptor table = new HTableDescriptor(TABLE_NAME);
HColumnDescriptor fam = new HColumnDescriptor(FAMILY); HColumnDescriptor fam = new HColumnDescriptor(FAMILY);
fam.setMaxVersions(3); fam.setMaxVersions(3);
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL); fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);

View File

@ -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.Action... actions) throws IOException {
Permission[] perms = new Permission[actions.length]; Permission[] perms = new Permission[actions.length];
for (int i = 0; i < actions.length; i++) { 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); 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(); CheckPermissionsRequest.Builder request = CheckPermissionsRequest.newBuilder();
for (Permission p : perms) { for (Permission p : perms) {
request.addPermission(ProtobufUtil.toPermission(p)); request.addPermission(ProtobufUtil.toPermission(p));

View File

@ -191,7 +191,7 @@ public class TestAccessController extends SecureTestUtil {
Coprocessor.PRIORITY_HIGHEST, 1, conf); Coprocessor.PRIORITY_HIGHEST, 1, conf);
// Wait for the ACL table to become available // 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 // create a set of test users
SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" }); SUPERUSER = User.createUserForTesting(conf, "admin", new String[] { "supergroup" });
@ -218,7 +218,7 @@ public class TestAccessController extends SecureTestUtil {
htd.addFamily(hcd); htd.addFamily(hcd);
htd.setOwner(USER_OWNER); htd.setOwner(USER_OWNER);
admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); 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); HRegion region = TEST_UTIL.getHBaseCluster().getRegions(TEST_TABLE.getTableName()).get(0);
RegionCoprocessorHost rcpHost = region.getCoprocessorHost(); RegionCoprocessorHost rcpHost = region.getCoprocessorHost();

View File

@ -56,7 +56,7 @@ public class TestAccessController2 extends SecureTestUtil {
verifyConfiguration(conf); verifyConfiguration(conf);
TEST_UTIL.startMiniCluster(); TEST_UTIL.startMiniCluster();
// Wait for the ACL table to become available // Wait for the ACL table to become available
TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
} }
@AfterClass @AfterClass
@ -85,7 +85,7 @@ public class TestAccessController2 extends SecureTestUtil {
return null; return null;
} }
}, testUser); }, 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 // Verify that owner permissions have been granted to the test user on the
// table just created // table just created
List<TablePermission> perms = AccessControlLists.getTablePermissions(conf, TEST_TABLE.getTableName()) List<TablePermission> perms = AccessControlLists.getTablePermissions(conf, TEST_TABLE.getTableName())

View File

@ -108,7 +108,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
// Wait for the ACL table to become available // 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 // create a set of test users
USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
@ -135,7 +135,7 @@ public class TestCellACLWithMultipleVersions extends SecureTestUtil {
htd.setOwner(USER_OWNER); htd.setOwner(USER_OWNER);
htd.addFamily(hcd); htd.addFamily(hcd);
admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName());
} }
@Test @Test

View File

@ -110,7 +110,7 @@ public class TestCellACLs extends SecureTestUtil {
rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
// Wait for the ACL table to become available // 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 // create a set of test users
USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
@ -132,7 +132,7 @@ public class TestCellACLs extends SecureTestUtil {
htd.setOwner(USER_OWNER); htd.setOwner(USER_OWNER);
htd.addFamily(hcd); htd.addFamily(hcd);
admin.createTable(htd, new byte[][] { Bytes.toBytes("s") }); admin.createTable(htd, new byte[][] { Bytes.toBytes("s") });
TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName());
} }
@Test @Test

View File

@ -98,7 +98,7 @@ public class TestScanEarlyTermination extends SecureTestUtil {
rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); rsHost.createEnvironment(AccessController.class, ac, Coprocessor.PRIORITY_HIGHEST, 1, conf);
// Wait for the ACL table to become available // 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 // create a set of test users
USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]);
@ -128,7 +128,7 @@ public class TestScanEarlyTermination extends SecureTestUtil {
admin.createTable(htd); admin.createTable(htd);
TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName().getName()); TEST_UTIL.waitTableEnabled(TEST_TABLE.getTableName());
} }
@After @After

View File

@ -98,7 +98,7 @@ public class TestTablePermissions {
UTIL.startMiniCluster(); UTIL.startMiniCluster();
// Wait for the ACL table to become available // 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(), ZKW = new ZooKeeperWatcher(UTIL.getConfiguration(),
"TestTablePermissions", ABORTABLE); "TestTablePermissions", ABORTABLE);

View File

@ -123,7 +123,7 @@ public class TestVisibilityLabelsWithACL {
public Void run() throws Exception { public Void run() throws Exception {
Scan s = new Scan(); Scan s = new Scan();
s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
Table t = new HTable(conf, table.getTableName()); Table t = new HTable(conf, table.getName());
try { try {
ResultScanner scanner = t.getScanner(s); ResultScanner scanner = t.getScanner(s);
Result result = scanner.next(); Result result = scanner.next();
@ -152,7 +152,7 @@ public class TestVisibilityLabelsWithACL {
public Void run() throws Exception { public Void run() throws Exception {
Scan s = new Scan(); Scan s = new Scan();
s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); s.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
Table t = new HTable(conf, table.getTableName()); Table t = new HTable(conf, table.getName());
try { try {
ResultScanner scanner = t.getScanner(s); ResultScanner scanner = t.getScanner(s);
Result[] result = scanner.next(5); Result[] result = scanner.next(5);
@ -178,7 +178,7 @@ public class TestVisibilityLabelsWithACL {
public Void run() throws Exception { public Void run() throws Exception {
Get g = new Get(row1); Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
Table t = new HTable(conf, table.getTableName()); Table t = new HTable(conf, table.getName());
try { try {
Result result = t.get(g); Result result = t.get(g);
assertTrue(!result.isEmpty()); assertTrue(!result.isEmpty());
@ -207,7 +207,7 @@ public class TestVisibilityLabelsWithACL {
public Void run() throws Exception { public Void run() throws Exception {
Get g = new Get(row1); Get g = new Get(row1);
g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL)); g.setAuthorizations(new Authorizations(SECRET, CONFIDENTIAL));
Table t = new HTable(conf, table.getTableName()); Table t = new HTable(conf, table.getName());
try { try {
Result result = t.get(g); Result result = t.get(g);
assertTrue(result.isEmpty()); assertTrue(result.isEmpty());

View File

@ -144,7 +144,7 @@ public class TestVisibilityLabelsWithDefaultVisLabelService extends TestVisibili
// Scan the visibility label // Scan the visibility label
Scan s = new Scan(); Scan s = new Scan();
s.setAuthorizations(new Authorizations(VisibilityUtils.SYSTEM_LABEL)); 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; int i = 0;
try { try {
ResultScanner scanner = ht.getScanner(s); ResultScanner scanner = ht.getScanner(s);

View File

@ -48,6 +48,6 @@ public class TestSecureExportSnapshot extends TestExportSnapshot {
TEST_UTIL.startMiniMapReduceCluster(); TEST_UTIL.startMiniMapReduceCluster();
// Wait for the ACL table to become available // Wait for the ACL table to become available
TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME.getName()); TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME);
} }
} }

View File

@ -61,7 +61,7 @@ public class TestProcessBasedCluster {
HTestConst.DEFAULT_CF_STR_SET, HTestConst.DEFAULT_CF_STR_SET,
HColumnDescriptor.DEFAULT_VERSIONS, COLS_PER_ROW, FLUSHES, NUM_REGIONS, HColumnDescriptor.DEFAULT_VERSIONS, COLS_PER_ROW, FLUSHES, NUM_REGIONS,
ROWS_PER_FLUSH); 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); ResultScanner scanner = table.getScanner(HTestConst.DEFAULT_CF_BYTES);
Result result; Result result;
int rows = 0; int rows = 0;

View File

@ -279,8 +279,7 @@ public class TestRegionSplitter {
final Configuration conf = UTIL.getConfiguration(); final Configuration conf = UTIL.getConfiguration();
conf.setInt("split.count", numRegions); conf.setInt("split.count", numRegions);
SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass); SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass);
RegionSplitter.createPresplitTable(tableName.getNameAsString(), splitAlgo, RegionSplitter.createPresplitTable(tableName, splitAlgo, new String[] {CF_NAME}, conf);
new String[] {CF_NAME}, conf);
verifyBounds(expectedBounds, tableName); verifyBounds(expectedBounds, tableName);
} }
@ -300,7 +299,7 @@ public class TestRegionSplitter {
// Set this larger than the number of splits so RegionSplitter won't block // Set this larger than the number of splits so RegionSplitter won't block
conf.setInt("split.outstanding", 5); conf.setInt("split.outstanding", 5);
SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass); SplitAlgorithm splitAlgo = RegionSplitter.newSplitAlgoInstance(conf, splitClass);
RegionSplitter.rollingSplit(tableName.getNameAsString(), splitAlgo, conf); RegionSplitter.rollingSplit(tableName, splitAlgo, conf);
verifyBounds(expectedBounds, tableName); verifyBounds(expectedBounds, tableName);
} }
@ -327,6 +326,7 @@ public class TestRegionSplitter {
startBoundaryIndex+1); startBoundaryIndex+1);
assertEquals(0, Bytes.compareTo(regionEnd, expectedRegionEnd)); assertEquals(0, Bytes.compareTo(regionEnd, expectedRegionEnd));
} }
hTable.close();
} }
/** /**