You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2013/08/08 08:08:31 UTC
svn commit: r1511591 [19/23] - in /hbase/branches/0.95:
hbase-client/src/main/java/org/apache/hadoop/hbase/
hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/
hbase-client/src/main/java/org/apache/hadoop/hbase/client/
hbase-client/src/main/jav...
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRestartCluster.java Thu Aug 8 06:08:23 2013
@@ -102,7 +102,7 @@ public class TestRestartCluster {
List<HRegionInfo> allRegions =
MetaScanner.listAllRegions(UTIL.getConfiguration(), true);
- assertEquals(3, allRegions.size());
+ assertEquals(4, allRegions.size());
LOG.info("\n\nShutting down cluster");
UTIL.shutdownMiniHBaseCluster();
@@ -116,10 +116,8 @@ public class TestRestartCluster {
// Need to use a new 'Configuration' so we make a new HConnection.
// Otherwise we're reusing an HConnection that has gone stale because
// the shutdown of the cluster also called shut of the connection.
- allRegions = MetaScanner.
- listAllRegions(new Configuration(UTIL.getConfiguration()), true);
- assertEquals(3, allRegions.size());
-
+ allRegions = MetaScanner.listAllRegions(new Configuration(UTIL.getConfiguration()), true);
+ assertEquals(4, allRegions.size());
LOG.info("\n\nWaiting for tables to be available");
for(byte [] TABLE: TABLES) {
try {
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java Thu Aug 8 06:08:23 2013
@@ -87,11 +87,11 @@ public class TestRollingRestart {
log("Waiting for no more RIT\n");
blockUntilNoRIT(zkw, master);
NavigableSet<String> regions = getAllOnlineRegions(cluster);
- log("Verifying only catalog regions are assigned\n");
- if (regions.size() != 1) {
+ log("Verifying only catalog and namespace regions are assigned\n");
+ if (regions.size() != 2) {
for (String oregion : regions) log("Region still online: " + oregion);
}
- assertEquals(1, regions.size());
+ assertEquals(2, regions.size());
log("Enabling table\n");
TEST_UTIL.getHBaseAdmin().enableTable(table);
log("Waiting for no more RIT\n");
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java Thu Aug 8 06:08:23 2013
@@ -38,6 +38,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Chore;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -72,7 +73,8 @@ public class TestTableLockManager {
private static final Log LOG =
LogFactory.getLog(TestTableLockManager.class);
- private static final byte[] TABLE_NAME = Bytes.toBytes("TestTableLevelLocks");
+ private static final TableName TABLE_NAME =
+ TableName.valueOf("TestTableLevelLocks");
private static final byte[] FAMILY = Bytes.toBytes("f1");
@@ -133,18 +135,18 @@ public class TestTableLockManager {
public static class TestLockTimeoutExceptionMasterObserver extends BaseMasterObserver {
@Override
public void preDeleteColumnHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
- byte[] tableName, byte[] c) throws IOException {
+ TableName tableName, byte[] c) throws IOException {
deleteColumn.countDown();
}
@Override
public void postDeleteColumnHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
- byte[] tableName, byte[] c) throws IOException {
+ TableName tableName, byte[] c) throws IOException {
Threads.sleep(10000);
}
@Override
public void preAddColumnHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
- byte[] tableName, HColumnDescriptor column) throws IOException {
+ TableName tableName, HColumnDescriptor column) throws IOException {
fail("Add column should have timeouted out for acquiring the table lock");
}
}
@@ -198,14 +200,14 @@ public class TestTableLockManager {
public static class TestAlterAndDisableMasterObserver extends BaseMasterObserver {
@Override
public void preAddColumnHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
- byte[] tableName, HColumnDescriptor column) throws IOException {
+ TableName tableName, HColumnDescriptor column) throws IOException {
LOG.debug("addColumn called");
addColumn.countDown();
}
@Override
public void postAddColumnHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
- byte[] tableName, HColumnDescriptor column) throws IOException {
+ TableName tableName, HColumnDescriptor column) throws IOException {
Threads.sleep(6000);
try {
ctx.getEnvironment().getMasterServices().checkTableModifiable(tableName);
@@ -219,7 +221,7 @@ public class TestTableLockManager {
@Override
public void preDisableTable(ObserverContext<MasterCoprocessorEnvironment> ctx,
- byte[] tableName) throws IOException {
+ TableName tableName) throws IOException {
try {
LOG.debug("Waiting for addColumn to be processed first");
//wait for addColumn to be processed first
@@ -232,7 +234,7 @@ public class TestTableLockManager {
@Override
public void postDisableTableHandler(ObserverContext<MasterCoprocessorEnvironment> ctx,
- byte[] tableName) throws IOException {
+ TableName tableName) throws IOException {
Threads.sleep(3000);
}
}
@@ -247,7 +249,7 @@ public class TestTableLockManager {
//ensure that znode for the table node has been deleted
final ZooKeeperWatcher zkWatcher = TEST_UTIL.getZooKeeperWatcher();
- final String znode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, Bytes.toString(TABLE_NAME));
+ final String znode = ZKUtil.joinZNode(zkWatcher.tableLockZNode, TABLE_NAME.getNameAsString());
TEST_UTIL.waitFor(5000, new Waiter.Predicate<Exception>() {
@Override
@@ -257,7 +259,7 @@ public class TestTableLockManager {
}
});
int ver = ZKUtil.checkExists(zkWatcher,
- ZKUtil.joinZNode(zkWatcher.tableLockZNode, Bytes.toString(TABLE_NAME)));
+ ZKUtil.joinZNode(zkWatcher.tableLockZNode, TABLE_NAME.getNameAsString()));
assertTrue("Unexpected znode version " + ver, ver < 0);
}
@@ -285,7 +287,8 @@ public class TestTableLockManager {
@Override
public Void call() throws Exception {
writeLocksAttempted.countDown();
- lockManager.writeLock(Bytes.toBytes(table), "testReapAllTableLocks").acquire();
+ lockManager.writeLock(TableName.valueOf(table),
+ "testReapAllTableLocks").acquire();
writeLocksObtained.countDown();
return null;
}
@@ -304,7 +307,9 @@ public class TestTableLockManager {
TEST_UTIL.getConfiguration(), TEST_UTIL.getZooKeeperWatcher(), serverName);
//should not throw table lock timeout exception
- zeroTimeoutLockManager.writeLock(Bytes.toBytes(tables[tables.length -1]), "zero timeout")
+ zeroTimeoutLockManager.writeLock(
+ TableName.valueOf(tables[tables.length - 1]),
+ "zero timeout")
.acquire();
executor.shutdownNow();
@@ -321,7 +326,7 @@ public class TestTableLockManager {
LoadTestTool loadTool = new LoadTestTool();
loadTool.setConf(TEST_UTIL.getConfiguration());
int numKeys = 10000;
- final byte[] tableName = Bytes.toBytes("testTableReadLock");
+ final TableName tableName = TableName.valueOf("testTableReadLock");
final HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
final HTableDescriptor desc = new HTableDescriptor(tableName);
final byte[] family = Bytes.toBytes("test_cf");
@@ -329,7 +334,7 @@ public class TestTableLockManager {
admin.createTable(desc); // create with one region
// write some data, not much
- int ret = loadTool.run(new String[] { "-tn", Bytes.toString(tableName), "-write",
+ int ret = loadTool.run(new String[] { "-tn", tableName.getNameAsString(), "-write",
String.format("%d:%d:%d", 1, 10, 10), "-num_keys", String.valueOf(numKeys), "-skip_init" });
if (0 != ret) {
String errorMsg = "Load failed with error code " + ret;
@@ -406,7 +411,7 @@ public class TestTableLockManager {
assertTrue(newFamilyValues > familyValues); // at least one alter went
// through
- ret = loadTool.run(new String[] { "-tn", Bytes.toString(tableName), "-read", "100:10",
+ ret = loadTool.run(new String[] { "-tn", tableName.getNameAsString(), "-read", "100:10",
"-num_keys", String.valueOf(numKeys), "-skip_init" });
if (0 != ret) {
String errorMsg = "Verify failed with error code " + ret;
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java Thu Aug 8 06:08:23 2013
@@ -30,6 +30,7 @@ import java.util.Collection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -62,7 +63,8 @@ import org.mockito.internal.util.reflect
public class TestZKBasedOpenCloseRegion {
private static final Log LOG = LogFactory.getLog(TestZKBasedOpenCloseRegion.class);
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- private static final String TABLENAME = "TestZKBasedOpenCloseRegion";
+ private static final TableName TABLENAME =
+ TableName.valueOf("TestZKBasedOpenCloseRegion");
private static final byte [][] FAMILIES = new byte [][] {Bytes.toBytes("a"),
Bytes.toBytes("b"), Bytes.toBytes("c")};
private static int countOfRegions;
@@ -72,7 +74,7 @@ public class TestZKBasedOpenCloseRegion
c.setBoolean("dfs.support.append", true);
c.setInt("hbase.regionserver.info.port", 0);
TEST_UTIL.startMiniCluster(2);
- TEST_UTIL.createTable(Bytes.toBytes(TABLENAME), FAMILIES);
+ TEST_UTIL.createTable(TABLENAME, FAMILIES);
HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
countOfRegions = TEST_UTIL.createMultiRegions(t, getTestFamily());
waitUntilAllRegionsAssigned();
@@ -219,13 +221,13 @@ public class TestZKBasedOpenCloseRegion
*/
@Test
public void testRegionOpenFailsDueToIOException() throws Exception {
- HRegionInfo REGIONINFO = new HRegionInfo(Bytes.toBytes("t"),
+ HRegionInfo REGIONINFO = new HRegionInfo(TableName.valueOf("t"),
HConstants.EMPTY_START_ROW, HConstants.EMPTY_START_ROW);
HRegionServer regionServer = TEST_UTIL.getHBaseCluster().getRegionServer(0);
TableDescriptors htd = Mockito.mock(TableDescriptors.class);
Object orizinalState = Whitebox.getInternalState(regionServer,"tableDescriptors");
Whitebox.setInternalState(regionServer, "tableDescriptors", htd);
- Mockito.doThrow(new IOException()).when(htd).get((byte[]) Mockito.any());
+ Mockito.doThrow(new IOException()).when(htd).get((TableName) Mockito.any());
try {
ProtobufUtil.openRegion(regionServer, REGIONINFO);
fail("It should throw IOException ");
@@ -238,7 +240,7 @@ public class TestZKBasedOpenCloseRegion
private static void waitUntilAllRegionsAssigned()
throws IOException {
- HTable meta = new HTable(TEST_UTIL.getConfiguration(), HConstants.META_TABLE_NAME);
+ HTable meta = new HTable(TEST_UTIL.getConfiguration(), TableName.META_TABLE_NAME);
while (true) {
int rows = 0;
Scan scan = new Scan();
@@ -273,7 +275,7 @@ public class TestZKBasedOpenCloseRegion
private static int addToEachStartKey(final int expected) throws IOException {
HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
HTable meta = new HTable(TEST_UTIL.getConfiguration(),
- HConstants.META_TABLE_NAME);
+ TableName.META_TABLE_NAME);
int rows = 0;
Scan scan = new Scan();
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
@@ -281,7 +283,9 @@ public class TestZKBasedOpenCloseRegion
for (Result r = null; (r = s.next()) != null;) {
HRegionInfo hri = HRegionInfo.getHRegionInfo(r);
if (hri == null) break;
-
+ if(!hri.getTableName().equals(TABLENAME)) {
+ continue;
+ }
// If start key, add 'aaa'.
byte [] row = getStartKey(hri);
Put p = new Put(row);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/BalancerTestBase.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/BalancerTestBase.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/BalancerTestBase.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/BalancerTestBase.java Thu Aug 8 06:08:23 2013
@@ -30,6 +30,7 @@ import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.master.RegionPlan;
@@ -197,7 +198,8 @@ public class BalancerTestBase {
}
Bytes.putInt(start, 0, numRegions << 1);
Bytes.putInt(end, 0, (numRegions << 1) + 1);
- byte[] tableName = Bytes.toBytes("table" + (numTables > 0 ? rand.nextInt(numTables) : i));
+ TableName tableName =
+ TableName.valueOf("table" + (numTables > 0 ? rand.nextInt(numTables) : i));
HRegionInfo hri = new HRegionInfo(tableName, start, end, false, regionId++);
regions.add(hri);
}
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeAssignmentHelper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeAssignmentHelper.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeAssignmentHelper.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestFavoredNodeAssignmentHelper.java Thu Aug 8 06:08:23 2013
@@ -28,6 +28,7 @@ import java.util.SortedMap;
import java.util.TreeMap;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.SmallTests;
import org.apache.hadoop.hbase.ServerName;
@@ -271,7 +272,7 @@ public class TestFavoredNodeAssignmentHe
// create regions
List<HRegionInfo> regions = new ArrayList<HRegionInfo>(regionCount);
for (int i = 0; i < regionCount; i++) {
- HRegionInfo region = new HRegionInfo(("foobar"+i).getBytes());
+ HRegionInfo region = new HRegionInfo(TableName.valueOf("foobar" + i));
regions.add(region);
}
// place the regions
@@ -299,7 +300,7 @@ public class TestFavoredNodeAssignmentHe
// create some regions
List<HRegionInfo> regions = new ArrayList<HRegionInfo>(regionCount);
for (int i = 0; i < regionCount; i++) {
- HRegionInfo region = new HRegionInfo(("foobar" + i).getBytes());
+ HRegionInfo region = new HRegionInfo(TableName.valueOf("foobar" + i));
regions.add(region);
}
// place those regions in primary RSs
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java Thu Aug 8 06:08:23 2013
@@ -27,16 +27,14 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.Server;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.SmallTests;
-import org.apache.hadoop.hbase.backup.HFileArchiver;
import org.apache.hadoop.hbase.catalog.CatalogTracker;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.io.HFileLink;
-import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
@@ -60,13 +58,13 @@ public class TestHFileLinkCleaner {
Path rootDir = FSUtils.getRootDir(conf);
FileSystem fs = FileSystem.get(conf);
- final String tableName = "test-table";
- final String tableLinkName = "test-link";
+ final TableName tableName = TableName.valueOf("test-table");
+ final TableName tableLinkName = TableName.valueOf("test-link");
final String hfileName = "1234567890";
final String familyName = "cf";
- HRegionInfo hri = new HRegionInfo(Bytes.toBytes(tableName));
- HRegionInfo hriLink = new HRegionInfo(Bytes.toBytes(tableLinkName));
+ HRegionInfo hri = new HRegionInfo(tableName);
+ HRegionInfo hriLink = new HRegionInfo(tableLinkName);
Path archiveDir = HFileArchiveUtil.getArchivePath(conf);
Path archiveStoreDir = HFileArchiveUtil.getStoreArchivePath(conf,
@@ -103,7 +101,8 @@ public class TestHFileLinkCleaner {
assertTrue(fs.exists(hfilePath));
// Link backref can be removed
- fs.rename(new Path(rootDir, tableLinkName), new Path(archiveDir, tableLinkName));
+ fs.rename(FSUtils.getTableDir(rootDir, tableLinkName),
+ FSUtils.getTableDir(archiveDir, tableLinkName));
cleaner.chore();
assertFalse("Link should be deleted", fs.exists(linkBackRef));
@@ -117,15 +116,15 @@ public class TestHFileLinkCleaner {
Thread.sleep(ttl * 2);
cleaner.chore();
}
- assertFalse("HFile should be deleted", fs.exists(new Path(archiveDir, tableName)));
- assertFalse("Link should be deleted", fs.exists(new Path(archiveDir, tableLinkName)));
+ assertFalse("HFile should be deleted", fs.exists(FSUtils.getTableDir(archiveDir, tableName)));
+ assertFalse("Link should be deleted", fs.exists(FSUtils.getTableDir(archiveDir, tableLinkName)));
cleaner.interrupt();
}
- private static Path getFamilyDirPath (final Path rootDir, final String table,
+ private static Path getFamilyDirPath (final Path rootDir, final TableName table,
final String region, final String family) {
- return new Path(new Path(new Path(rootDir, table), region), family);
+ return new Path(new Path(FSUtils.getTableDir(rootDir, table), region), family);
}
static class DummyServer implements Server {
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java Thu Aug 8 06:08:23 2013
@@ -33,6 +33,7 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MediumTests;
@@ -42,6 +43,7 @@ import org.apache.hadoop.hbase.master.HM
import org.apache.hadoop.hbase.master.snapshot.DisabledTableSnapshotHandler;
import org.apache.hadoop.hbase.master.snapshot.SnapshotHFileCleaner;
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.DeleteSnapshotRequest;
import org.apache.hadoop.hbase.protobuf.generated.MasterAdminProtos.IsSnapshotDoneRequest;
@@ -83,9 +85,9 @@ public class TestSnapshotFromMaster {
// for hfile archiving test.
private static Path archiveDir;
- private static final String STRING_TABLE_NAME = "test";
private static final byte[] TEST_FAM = Bytes.toBytes("fam");
- private static final byte[] TABLE_NAME = Bytes.toBytes(STRING_TABLE_NAME);
+ private static final TableName TABLE_NAME =
+ TableName.valueOf("test");
// refresh the cache every 1/2 second
private static final long cacheRefreshPeriod = 500;
@@ -128,7 +130,7 @@ public class TestSnapshotFromMaster {
@Before
public void setup() throws Exception {
UTIL.createTable(TABLE_NAME, TEST_FAM);
- master.getSnapshotManagerForTesting().setSnapshotHandlerForTesting(STRING_TABLE_NAME, null);
+ master.getSnapshotManagerForTesting().setSnapshotHandlerForTesting(TABLE_NAME, null);
}
@After
@@ -160,6 +162,7 @@ public class TestSnapshotFromMaster {
public void testIsDoneContract() throws Exception {
IsSnapshotDoneRequest.Builder builder = IsSnapshotDoneRequest.newBuilder();
+
String snapshotName = "asyncExpectedFailureTest";
// check that we get an exception when looking up snapshot where one hasn't happened
@@ -168,7 +171,7 @@ public class TestSnapshotFromMaster {
// and that we get the same issue, even if we specify a name
SnapshotDescription desc = SnapshotDescription.newBuilder()
- .setName(snapshotName).setTable(STRING_TABLE_NAME).build();
+ .setName(snapshotName).setTable(TABLE_NAME.getNameAsString()).build();
builder.setSnapshot(desc);
SnapshotTestingUtils.expectSnapshotDoneException(master, builder.build(),
UnknownSnapshotException.class);
@@ -182,7 +185,7 @@ public class TestSnapshotFromMaster {
.thenReturn(EnvironmentEdgeManager.currentTimeMillis());
master.getSnapshotManagerForTesting()
- .setSnapshotHandlerForTesting(STRING_TABLE_NAME, mockHandler);
+ .setSnapshotHandlerForTesting(TABLE_NAME, mockHandler);
// if we do a lookup without a snapshot name, we should fail - you should always know your name
builder = IsSnapshotDoneRequest.newBuilder();
@@ -322,7 +325,7 @@ public class TestSnapshotFromMaster {
LOG.debug(file.getPath());
}
// get the archived files for the table
- Collection<String> files = getArchivedHFiles(archiveDir, rootDir, fs, STRING_TABLE_NAME);
+ Collection<String> files = getArchivedHFiles(archiveDir, rootDir, fs, TABLE_NAME);
// and make sure that there is a proper subset
for (FileStatus file : snapshotHFiles) {
@@ -349,7 +352,7 @@ public class TestSnapshotFromMaster {
LOG.info("After delete snapshot cleaners run File-System state");
FSUtils.logFileSystemState(fs, rootDir, LOG);
- files = getArchivedHFiles(archiveDir, rootDir, fs, STRING_TABLE_NAME);
+ files = getArchivedHFiles(archiveDir, rootDir, fs, TABLE_NAME);
assertEquals("Still have some hfiles in the archive, when their snapshot has been deleted.", 0,
files.size());
}
@@ -359,8 +362,8 @@ public class TestSnapshotFromMaster {
* @throws IOException on expected failure
*/
private final Collection<String> getArchivedHFiles(Path archiveDir, Path rootDir,
- FileSystem fs, String tableName) throws IOException {
- Path tableArchive = new Path(archiveDir, tableName);
+ FileSystem fs, TableName tableName) throws IOException {
+ Path tableArchive = FSUtils.getTableDir(archiveDir, tableName);
FileStatus[] archivedHFiles = SnapshotTestingUtils.listHFiles(fs, tableArchive);
List<String> files = new ArrayList<String>(archivedHFiles.length);
LOG.debug("Have archived hfiles: " + tableArchive);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestCreateTableHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestCreateTableHandler.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestCreateTableHandler.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestCreateTableHandler.java Thu Aug 8 06:08:23 2013
@@ -27,6 +27,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -67,9 +68,9 @@ public class TestCreateTableHandler {
public void testCreateTableHandlerIfCalledTwoTimesAndFirstOneIsUnderProgress() throws Exception {
final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
final HMaster m = cluster.getMaster();
- final HTableDescriptor desc = new HTableDescriptor(TABLENAME);
+ final HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(TABLENAME));
desc.addFamily(new HColumnDescriptor(FAMILYNAME));
- final HRegionInfo[] hRegionInfos = new HRegionInfo[] { new HRegionInfo(desc.getName(), null,
+ final HRegionInfo[] hRegionInfos = new HRegionInfo[] { new HRegionInfo(desc.getTableName(), null,
null) };
CustomCreateTableHandler handler = new CustomCreateTableHandler(m, m.getMasterFileSystem(),
desc, cluster.getConfiguration(), hRegionInfos, m);
@@ -89,15 +90,14 @@ public class TestCreateTableHandler {
assertTrue(TEST_UTIL.getHBaseAdmin().isTableEnabled(TABLENAME));
}
-
@Test (timeout=60000)
public void testMasterRestartAfterEnablingNodeIsCreated() throws Exception {
byte[] tableName = Bytes.toBytes("testMasterRestartAfterEnablingNodeIsCreated");
final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
final HMaster m = cluster.getMaster();
- final HTableDescriptor desc = new HTableDescriptor(tableName);
+ final HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
desc.addFamily(new HColumnDescriptor(FAMILYNAME));
- final HRegionInfo[] hRegionInfos = new HRegionInfo[] { new HRegionInfo(desc.getName(), null,
+ final HRegionInfo[] hRegionInfos = new HRegionInfo[] { new HRegionInfo(desc.getTableName(), null,
null) };
CustomCreateTableHandler handler = new CustomCreateTableHandler(m, m.getMasterFileSystem(),
desc, cluster.getConfiguration(), hRegionInfos, m);
@@ -126,12 +126,12 @@ public class TestCreateTableHandler {
}
@Override
- protected List<HRegionInfo> handleCreateHdfsRegions(Path tableRootDir, String tableName)
- throws IOException {
+ protected List<HRegionInfo> handleCreateHdfsRegions(Path tableRootDir,
+ TableName tableName) throws IOException {
if (throwException) {
throw new IOException("Test throws exceptions.");
}
return super.handleCreateHdfsRegions(tableRootDir, tableName);
}
}
-}
\ No newline at end of file
+}
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDeleteFamilyHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDeleteFamilyHandler.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDeleteFamilyHandler.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDeleteFamilyHandler.java Thu Aug 8 06:08:23 2013
@@ -28,6 +28,7 @@ import java.io.IOException;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -35,6 +36,7 @@ import org.apache.hadoop.hbase.LargeTest
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.FSUtils;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -45,7 +47,8 @@ import org.junit.experimental.categories
public class TestTableDeleteFamilyHandler {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- private static final String TABLENAME = "column_family_handlers";
+ private static final TableName TABLENAME =
+ TableName.valueOf("column_family_handlers");
private static final byte[][] FAMILIES = new byte[][] { Bytes.toBytes("cf1"),
Bytes.toBytes("cf2"), Bytes.toBytes("cf3") };
@@ -61,12 +64,17 @@ public class TestTableDeleteFamilyHandle
TEST_UTIL.startMiniCluster(2);
// Create a table of three families. This will assign a region.
- TEST_UTIL.createTable(Bytes.toBytes(TABLENAME), FAMILIES);
+ TEST_UTIL.createTable(TABLENAME, FAMILIES);
HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
-
+ while(TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
+ .getRegionStates().getRegionsInTransition().size() > 0) {
+ Thread.sleep(100);
+ }
// Create multiple regions in all the three column families
- TEST_UTIL.createMultiRegions(t, FAMILIES[0]);
-
+ while(TEST_UTIL.getMiniHBaseCluster().getMaster().getAssignmentManager()
+ .getRegionStates().getRegionsInTransition().size() > 0) {
+ Thread.sleep(100);
+ }
// Load the table with data for all families
TEST_UTIL.loadTable(t, FAMILIES);
@@ -77,7 +85,7 @@ public class TestTableDeleteFamilyHandle
@AfterClass
public static void afterAllTests() throws Exception {
- TEST_UTIL.deleteTable(Bytes.toBytes(TABLENAME));
+ TEST_UTIL.deleteTable(TABLENAME);
TEST_UTIL.shutdownMiniCluster();
}
@@ -90,8 +98,7 @@ public class TestTableDeleteFamilyHandle
public void deleteColumnFamilyWithMultipleRegions() throws Exception {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
- HTableDescriptor beforehtd = admin.getTableDescriptor(Bytes
- .toBytes(TABLENAME));
+ HTableDescriptor beforehtd = admin.getTableDescriptor(TABLENAME);
FileSystem fs = TEST_UTIL.getDFSCluster().getFileSystem();
@@ -107,8 +114,7 @@ public class TestTableDeleteFamilyHandle
}
// 3 - Check if table exists in FS
- Path tableDir = new Path(TEST_UTIL.getDefaultRootDirPath().toString() + "/"
- + TABLENAME);
+ Path tableDir = FSUtils.getTableDir(TEST_UTIL.getDefaultRootDirPath(), TABLENAME);
assertTrue(fs.exists(tableDir));
// 4 - Check if all the 3 column families exist in FS
@@ -120,7 +126,7 @@ public class TestTableDeleteFamilyHandle
for (int j = 0; j < cf.length; j++) {
if (cf[j].isDir() == true
&& cf[j].getPath().getName().startsWith(".") == false) {
- assertTrue(cf[j].getPath().getName().equals("cf" + k));
+ assertEquals(cf[j].getPath().getName(), "cf" + k);
k++;
}
}
@@ -129,11 +135,10 @@ public class TestTableDeleteFamilyHandle
// TEST - Disable and delete the column family
admin.disableTable(TABLENAME);
- admin.deleteColumn(TABLENAME, "cf2");
+ admin.deleteColumn(TABLENAME.getName(), "cf2");
// 5 - Check if only 2 column families exist in the descriptor
- HTableDescriptor afterhtd = admin.getTableDescriptor(Bytes
- .toBytes(TABLENAME));
+ HTableDescriptor afterhtd = admin.getTableDescriptor(TABLENAME);
assertEquals(2, afterhtd.getColumnFamilies().length);
HColumnDescriptor[] newFamilies = afterhtd.getColumnFamilies();
assertTrue(newFamilies[0].getNameAsString().equals("cf1"));
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDescriptorModification.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDescriptorModification.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDescriptorModification.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/handler/TestTableDescriptorModification.java Thu Aug 8 06:08:23 2013
@@ -26,9 +26,8 @@ import static org.junit.Assert.assertTru
import java.io.IOException;
import java.util.Set;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
@@ -37,6 +36,7 @@ import org.apache.hadoop.hbase.client.HB
import org.apache.hadoop.hbase.master.MasterFileSystem;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FSTableDescriptors;
+import org.apache.hadoop.hbase.util.FSUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -50,7 +50,8 @@ import org.junit.experimental.categories
public class TestTableDescriptorModification {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
- private static final byte[] TABLE_NAME = Bytes.toBytes("table");
+ private static final TableName TABLE_NAME =
+ TableName.valueOf("table");
private static final byte[] FAMILY_0 = Bytes.toBytes("cf0");
private static final byte[] FAMILY_1 = Bytes.toBytes("cf1");
@@ -133,8 +134,8 @@ public class TestTableDescriptorModifica
}
}
- private void verifyTableDescriptor(final byte[] tableName, final byte[]... families)
- throws IOException {
+ private void verifyTableDescriptor(final TableName tableName,
+ final byte[]... families) throws IOException {
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
// Verify descriptor from master
@@ -143,15 +144,15 @@ public class TestTableDescriptorModifica
// Verify descriptor from HDFS
MasterFileSystem mfs = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterFileSystem();
- Path tableDir = HTableDescriptor.getTableDir(mfs.getRootDir(), tableName);
+ Path tableDir = FSUtils.getTableDir(mfs.getRootDir(), tableName);
htd = FSTableDescriptors.getTableDescriptorFromFs(mfs.getFileSystem(), tableDir);
verifyTableDescriptor(htd, tableName, families);
}
private void verifyTableDescriptor(final HTableDescriptor htd,
- final byte[] tableName, final byte[]... families) {
+ final TableName tableName, final byte[]... families) {
Set<byte[]> htdFamilies = htd.getFamiliesKeys();
- assertTrue(Bytes.equals(tableName, htd.getName()));
+ assertEquals(tableName, htd.getTableName());
assertEquals(families.length, htdFamilies.size());
for (byte[] familyName: families) {
assertTrue("Expected family " + Bytes.toString(familyName), htdFamilies.contains(familyName));
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotHFileCleaner.java Thu Aug 8 06:08:23 2013
@@ -24,6 +24,7 @@ import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -66,8 +67,7 @@ public class TestSnapshotHFileCleaner {
// write an hfile to the snapshot directory
String snapshotName = "snapshot";
byte[] snapshot = Bytes.toBytes(snapshotName);
- String table = "table";
- byte[] tableName = Bytes.toBytes(table);
+ TableName tableName = TableName.valueOf("table");
Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
HRegionInfo mockRegion = new HRegionInfo(tableName);
Path regionSnapshotDir = new Path(snapshotDir, mockRegion.getEncodedName());
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotManager.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotManager.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/master/snapshot/TestSnapshotManager.java Thu Aug 8 06:08:23 2013
@@ -26,6 +26,7 @@ import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.SmallTests;
@@ -79,7 +80,7 @@ public class TestSnapshotManager {
@Test
public void testInProcess() throws KeeperException, IOException {
- String tableName = "testTable";
+ TableName tableName = TableName.valueOf("testTable");
SnapshotManager manager = getNewManager();
TakeSnapshotHandler handler = Mockito.mock(TakeSnapshotHandler.class);
assertFalse("Manager is in process when there is no current handler",
Added: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java?rev=1511591&view=auto
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java (added)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/migration/TestNamespaceUpgrade.java Thu Aug 8 06:08:23 2013
@@ -0,0 +1,230 @@
+/**
+ * Copyright The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.migration;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.FsShell;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.MediumTests;
+import org.apache.hadoop.hbase.NamespaceDescriptor;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.Waiter;
+import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.util.ToolRunner;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Test upgrade from no namespace in 0.94 to namespace directory structure.
+ * Mainly tests that tables are migrated and consistent. Also verifies
+ * that snapshots have been migrated correctly.
+ *
+ * Uses a tarball which is an image of an 0.94 hbase.rootdir.
+ *
+ * Contains tables with currentKeys as the stored keys:
+ * foo, ns1.foo, ns2.foo
+ *
+ * Contains snapshots with snapshot{num}Keys as the contents:
+ * snapshot1Keys, snapshot2Keys
+ *
+ */
+@Category(MediumTests.class)
+public class TestNamespaceUpgrade {
+ static final Log LOG = LogFactory.getLog(TestNamespaceUpgrade.class);
+ private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
+ private final static String snapshot1Keys[] =
+ {"1","10","2","3","4","5","6","7","8","9"};
+ private final static String snapshot2Keys[] =
+ {"1","2","3","4","5","6","7","8","9"};
+ private final static String currentKeys[] =
+ {"1","2","3","4","5","6","7","8","9","A"};
+ private final static String tables[] = {"foo", "ns1.foo","ns.two.foo"};
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ // Start up our mini cluster on top of an 0.94 root.dir that has data from
+ // a 0.94 hbase run and see if we can migrate to 0.96
+ TEST_UTIL.startMiniZKCluster();
+ TEST_UTIL.startMiniDFSCluster(1);
+ Path testdir = TEST_UTIL.getDataTestDir("TestNamespaceUpgrade");
+ // Untar our test dir.
+ File untar = untar(new File(testdir.toString()));
+ // Now copy the untar up into hdfs so when we start hbase, we'll run from it.
+ Configuration conf = TEST_UTIL.getConfiguration();
+ FsShell shell = new FsShell(conf);
+ FileSystem fs = FileSystem.get(conf);
+ // find where hbase will root itself, so we can copy filesystem there
+ Path hbaseRootDir = TEST_UTIL.getDefaultRootDirPath();
+ if (!fs.isDirectory(hbaseRootDir.getParent())) {
+ // mkdir at first
+ fs.mkdirs(hbaseRootDir.getParent());
+ }
+ doFsCommand(shell,
+ new String [] {"-put", untar.toURI().toString(), hbaseRootDir.toString()});
+ // See whats in minihdfs.
+ doFsCommand(shell, new String [] {"-lsr", "/"});
+ Configuration toolConf = TEST_UTIL.getConfiguration();
+ conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDefaultRootDirPath().toString());
+ ToolRunner.run(toolConf, new NamespaceUpgrade(), new String[]{"--upgrade"});
+
+ assertTrue(FSUtils.getVersion(fs, hbaseRootDir).equals(HConstants.FILE_SYSTEM_VERSION));
+ TEST_UTIL.startMiniHBaseCluster(1, 1);
+
+ for(String table: tables) {
+ int count = 0;
+ for(Result res: new HTable(TEST_UTIL.getConfiguration(), table).getScanner(new Scan())) {
+ assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
+ }
+ Assert.assertEquals(currentKeys.length, count);
+ }
+ assertEquals(2, TEST_UTIL.getHBaseAdmin().listNamespaceDescriptors().length);
+ }
+
+ private static File untar(final File testdir) throws IOException {
+ // Find the src data under src/test/data
+ final String datafile = "TestNamespaceUpgrade";
+ File srcTarFile = new File(
+ System.getProperty("project.build.testSourceDirectory", "src/test") +
+ File.separator + "data" + File.separator + datafile + ".tgz");
+ File homedir = new File(testdir.toString());
+ File tgtUntarDir = new File(homedir, "hbase");
+ if (tgtUntarDir.exists()) {
+ if (!FileUtil.fullyDelete(tgtUntarDir)) {
+ throw new IOException("Failed delete of " + tgtUntarDir.toString());
+ }
+ }
+ if (!srcTarFile.exists()) {
+ throw new IOException(srcTarFile+" does not exist");
+ }
+ LOG.info("Untarring " + srcTarFile + " into " + homedir.toString());
+ FileUtil.unTar(srcTarFile, homedir);
+ Assert.assertTrue(tgtUntarDir.exists());
+ return tgtUntarDir;
+ }
+
+ private static void doFsCommand(final FsShell shell, final String [] args)
+ throws Exception {
+ // Run the 'put' command.
+ int errcode = shell.run(args);
+ if (errcode != 0) throw new IOException("Failed put; errcode=" + errcode);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ TEST_UTIL.shutdownMiniCluster();
+ }
+
+ @Test
+ public void testSnapshots() throws IOException, InterruptedException {
+ String snapshots[][] = {snapshot1Keys, snapshot2Keys};
+ for(int i=1; i<=snapshots.length; i++) {
+ for(String table: tables) {
+ TEST_UTIL.getHBaseAdmin().cloneSnapshot(table+"_snapshot"+i, table+"_clone"+i);
+ FSUtils.logFileSystemState(FileSystem.get(TEST_UTIL.getConfiguration()),
+ FSUtils.getRootDir(TEST_UTIL.getConfiguration()),
+ LOG);
+ int count = 0;
+ for(Result res: new HTable(TEST_UTIL.getConfiguration(), table+"_clone"+i).getScanner(new
+ Scan())) {
+ assertEquals(snapshots[i-1][count++], Bytes.toString(res.getRow()));
+ }
+ Assert.assertEquals(table+"_snapshot"+i, snapshots[i-1].length, count);
+ }
+ }
+ }
+
+ @Test
+ public void testRenameUsingSnapshots() throws IOException, InterruptedException {
+ String newNS = "newNS";
+ TEST_UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(newNS).build());
+ for(String table: tables) {
+ int count = 0;
+ for(Result res: new HTable(TEST_UTIL.getConfiguration(), table).getScanner(new
+ Scan())) {
+ assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
+ }
+ TEST_UTIL.getHBaseAdmin().snapshot(table+"_snapshot3", table);
+ final String newTableName =
+ newNS+ TableName.NAMESPACE_DELIM+table+"_clone3";
+ TEST_UTIL.getHBaseAdmin().cloneSnapshot(table+"_snapshot3", newTableName);
+ Thread.sleep(1000);
+ count = 0;
+ for(Result res: new HTable(TEST_UTIL.getConfiguration(), newTableName).getScanner(new
+ Scan())) {
+ assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
+ }
+ FSUtils.logFileSystemState(TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath()
+ , LOG);
+ Assert.assertEquals(newTableName, currentKeys.length, count);
+ TEST_UTIL.getHBaseAdmin().flush(newTableName);
+ TEST_UTIL.getHBaseAdmin().majorCompact(newTableName);
+ TEST_UTIL.waitFor(2000, new Waiter.Predicate<IOException>() {
+ @Override
+ public boolean evaluate() throws IOException {
+ try {
+ return TEST_UTIL.getHBaseAdmin().getCompactionState(newTableName) ==
+ AdminProtos.GetRegionInfoResponse.CompactionState.NONE;
+ } catch (InterruptedException e) {
+ throw new IOException(e);
+ }
+ }
+ });
+ }
+
+ String nextNS = "nextNS";
+ TEST_UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(nextNS).build());
+ for(String table: tables) {
+ String srcTable = newNS+TableName.NAMESPACE_DELIM+table+"_clone3";
+ TEST_UTIL.getHBaseAdmin().snapshot(table+"_snapshot4", srcTable);
+ String newTableName = nextNS+TableName.NAMESPACE_DELIM+table+"_clone4";
+ TEST_UTIL.getHBaseAdmin().cloneSnapshot(table+"_snapshot4", newTableName);
+ FSUtils.logFileSystemState(TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath()
+ , LOG);
+ int count = 0;
+ for(Result res: new HTable(TEST_UTIL.getConfiguration(), newTableName).getScanner(new
+ Scan())) {
+ assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
+ }
+ Assert.assertEquals(newTableName, currentKeys.length, count);
+ }
+
+ }
+}
+
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/HFileReadWriteTest.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/HFileReadWriteTest.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/HFileReadWriteTest.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/HFileReadWriteTest.java Thu Aug 8 06:08:23 2013
@@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.HColumnDe
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
@@ -343,7 +344,7 @@ public class HFileReadWriteTest {
columnDescriptor.setCompressionType(compression);
columnDescriptor.setDataBlockEncoding(dataBlockEncoding);
HRegionInfo regionInfo = new HRegionInfo();
- HTableDescriptor htd = new HTableDescriptor(TABLE_NAME);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
HRegion region = new HRegion(outputDir, null, fs, conf, regionInfo, htd, null);
HStore store = new HStore(region, columnDescriptor, conf);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestAtomicOperation.java Thu Aug 8 06:08:23 2013
@@ -44,6 +44,7 @@ import org.apache.hadoop.hbase.MediumTes
import org.apache.hadoop.hbase.MultithreadedTestUtil;
import org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext;
import org.apache.hadoop.hbase.MultithreadedTestUtil.TestThread;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
@@ -192,14 +193,14 @@ public class TestAtomicOperation extends
private void initHRegion (byte [] tableName, String callingMethod, int [] maxVersions,
byte[] ... families)
throws IOException {
- HTableDescriptor htd = new HTableDescriptor(tableName);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
int i=0;
for(byte [] family : families) {
HColumnDescriptor hcd = new HColumnDescriptor(family);
hcd.setMaxVersions(maxVersions != null ? maxVersions[i++] : 1);
htd.addFamily(hcd);
}
- HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
Path path = new Path(DIR + callingMethod);
if (fs.exists(path)) {
if (!fs.delete(path, true)) {
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksRead.java Thu Aug 8 06:08:23 2013
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.HRegionIn
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MediumTests;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
@@ -95,7 +96,7 @@ public class TestBlocksRead extends HBas
*/
private HRegion initHRegion(byte[] tableName, String callingMethod,
HBaseConfiguration conf, String family) throws IOException {
- HTableDescriptor htd = new HTableDescriptor(tableName);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
HColumnDescriptor familyDesc;
for (int i = 0; i < BLOOM_TYPE.length; i++) {
BloomType bloomType = BLOOM_TYPE[i];
@@ -105,7 +106,7 @@ public class TestBlocksRead extends HBas
htd.addFamily(familyDesc);
}
- HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
Path path = new Path(DIR + callingMethod);
HRegion r = HRegion.createHRegion(info, path, conf, htd);
blockCache = new CacheConfig(conf).getBlockCache();
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java Thu Aug 8 06:08:23 2013
@@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.HColumnDe
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.SmallTests;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.util.Bytes;
@@ -51,7 +52,7 @@ public class TestBlocksScanned extends H
super.setUp();
TEST_UTIL = new HBaseTestingUtility();
- TESTTABLEDESC = new HTableDescriptor(TABLE);
+ TESTTABLEDESC = new HTableDescriptor(TableName.valueOf(TABLE));
TESTTABLEDESC.addFamily(
new HColumnDescriptor(FAMILY)
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCacheOnWriteInSchema.java Thu Aug 8 06:08:23 2013
@@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.HRegionIn
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MediumTests;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.fs.HFileSystem;
import org.apache.hadoop.hbase.io.hfile.BlockCache;
import org.apache.hadoop.hbase.io.hfile.BlockCacheKey;
@@ -152,7 +153,7 @@ public class TestCacheOnWriteInSchema {
HColumnDescriptor hcd = new HColumnDescriptor(family);
hcd.setBloomFilterType(BloomType.ROWCOL);
cowType.modifyFamilySchema(hcd);
- HTableDescriptor htd = new HTableDescriptor(table);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(table));
htd.addFamily(hcd);
// Create a store based on the schema
@@ -161,7 +162,7 @@ public class TestCacheOnWriteInSchema {
Path logdir = new Path(DIR, logName);
fs.delete(logdir, true);
- HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
hlog = HLogFactory.createHLog(fs, basedir, logName, conf);
region = new HRegion(basedir, hlog, fs, conf, info, htd, null);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestColumnSeeking.java Thu Aug 8 06:08:23 2013
@@ -52,14 +52,14 @@ public class TestColumnSeeking {
public void testDuplicateVersions() throws IOException {
String family = "Family";
byte[] familyBytes = Bytes.toBytes("Family");
- String table = "TestDuplicateVersions";
+ TableName table = TableName.valueOf("TestDuplicateVersions");
HColumnDescriptor hcd =
new HColumnDescriptor(familyBytes).setMaxVersions(1000);
hcd.setMaxVersions(3);
HTableDescriptor htd = new HTableDescriptor(table);
htd.addFamily(hcd);
- HRegionInfo info = new HRegionInfo(Bytes.toBytes(table), null, null, false);
+ HRegionInfo info = new HRegionInfo(table, null, null, false);
HRegion region =
HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), TEST_UTIL
.getConfiguration(), htd);
@@ -166,14 +166,15 @@ public class TestColumnSeeking {
public void testReseeking() throws IOException {
String family = "Family";
byte[] familyBytes = Bytes.toBytes("Family");
- String table = "TestSingleVersions";
+ TableName table =
+ TableName.valueOf("TestSingleVersions");
HTableDescriptor htd = new HTableDescriptor(table);
HColumnDescriptor hcd = new HColumnDescriptor(family);
hcd.setMaxVersions(3);
htd.addFamily(hcd);
- HRegionInfo info = new HRegionInfo(Bytes.toBytes(table), null, null, false);
+ HRegionInfo info = new HRegionInfo(table, null, null, false);
HRegion region =
HRegion.createHRegion(info, TEST_UTIL.getDataTestDir(), TEST_UTIL
.getConfiguration(), htd);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCompactionState.java Thu Aug 8 06:08:23 2013
@@ -28,13 +28,13 @@ import java.util.Random;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.LargeTests;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState;
-import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -123,7 +123,8 @@ public class TestCompactionState {
final CompactionState expectedState, boolean singleFamily)
throws IOException, InterruptedException {
// Create a table with regions
- byte [] table = Bytes.toBytes(tableName);
+ TableName table =
+ TableName.valueOf(tableName);
byte [] family = Bytes.toBytes("family");
byte [][] families =
{family, Bytes.add(family, Bytes.toBytes("2")), Bytes.add(family, Bytes.toBytes("3"))};
@@ -139,24 +140,24 @@ public class TestCompactionState {
HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
if (expectedState == CompactionState.MINOR) {
if (singleFamily) {
- admin.compact(table, family);
+ admin.compact(table.getName(), family);
} else {
- admin.compact(table);
+ admin.compact(table.getName());
}
} else {
if (singleFamily) {
- admin.majorCompact(table, family);
+ admin.majorCompact(table.getName(), family);
} else {
- admin.majorCompact(table);
+ admin.majorCompact(table.getName());
}
}
long curt = System.currentTimeMillis();
long waitTime = 5000;
long endt = curt + waitTime;
- CompactionState state = admin.getCompactionState(table);
+ CompactionState state = admin.getCompactionState(table.getName());
while (state == CompactionState.NONE && curt < endt) {
Thread.sleep(10);
- state = admin.getCompactionState(table);
+ state = admin.getCompactionState(table.getName());
curt = System.currentTimeMillis();
}
// Now, should have the right compaction state,
@@ -168,10 +169,10 @@ public class TestCompactionState {
}
} else {
// Wait until the compaction is done
- state = admin.getCompactionState(table);
+ state = admin.getCompactionState(table.getName());
while (state != CompactionState.NONE && curt < endt) {
Thread.sleep(10);
- state = admin.getCompactionState(table);
+ state = admin.getCompactionState(table.getName());
}
// Now, compaction should be done.
assertEquals(CompactionState.NONE, state);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java Thu Aug 8 06:08:23 2013
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.HConstant
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.SmallTests;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.io.hfile.NoOpDataBlockEncoder;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
@@ -42,6 +43,7 @@ import org.apache.hadoop.hbase.regionser
import org.apache.hadoop.hbase.regionserver.wal.HLog;
import org.apache.hadoop.hbase.regionserver.wal.HLogFactory;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.FSUtils;
import org.junit.After;
import org.junit.experimental.categories.Category;
@@ -87,14 +89,14 @@ public class TestDefaultCompactSelection
fs.delete(logdir, true);
- HTableDescriptor htd = new HTableDescriptor(Bytes.toBytes("table"));
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(Bytes.toBytes("table")));
htd.addFamily(hcd);
- HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
hlog = HLogFactory.createHLog(fs, basedir, logName, conf);
region = HRegion.createHRegion(info, basedir, conf, htd);
HRegion.closeHRegion(region);
- Path tableDir = new Path(basedir, Bytes.toString(htd.getName()));
+ Path tableDir = FSUtils.getTableDir(basedir, htd.getTableName());
region = new HRegion(tableDir, hlog, fs, conf, info, htd, null);
store = new HStore(region, hcd, conf);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestEndToEndSplitTransaction.java Thu Aug 8 06:08:23 2013
@@ -34,6 +34,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Chore;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -87,7 +88,8 @@ public class TestEndToEndSplitTransactio
@Test
public void testMasterOpsWhileSplitting() throws Exception {
- byte[] tableName = Bytes.toBytes("TestSplit");
+ TableName tableName =
+ TableName.valueOf("TestSplit");
byte[] familyName = Bytes.toBytes("fam");
HTable ht = TEST_UTIL.createTable(tableName, familyName);
TEST_UTIL.loadTable(ht, familyName);
@@ -146,7 +148,7 @@ public class TestEndToEndSplitTransactio
* attempt to locate the region and perform a get and scan
* @return True if successful, False otherwise.
*/
- private boolean test(HConnection con, byte[] tableName, byte[] row,
+ private boolean test(HConnection con, TableName tableName, byte[] row,
HRegionServer server) {
// not using HTable to avoid timeouts and retries
try {
@@ -173,7 +175,8 @@ public class TestEndToEndSplitTransactio
@Test
public void testFromClientSideWhileSplitting() throws Throwable {
LOG.info("Starting testFromClientSideWhileSplitting");
- final byte[] TABLENAME = Bytes.toBytes("testFromClientSideWhileSplitting");
+ final TableName TABLENAME =
+ TableName.valueOf("testFromClientSideWhileSplitting");
final byte[] FAMILY = Bytes.toBytes("family");
//SplitTransaction will update the meta table by offlining the parent region, and adding info
@@ -206,13 +209,14 @@ public class TestEndToEndSplitTransactio
static class RegionSplitter extends Thread {
Throwable ex;
HTable table;
- byte[] tableName, family;
+ TableName tableName;
+ byte[] family;
HBaseAdmin admin;
HRegionServer rs;
RegionSplitter(HTable table) throws IOException {
this.table = table;
- this.tableName = table.getTableName();
+ this.tableName = table.getName();
this.family = table.getTableDescriptor().getFamiliesKeys().iterator().next();
admin = TEST_UTIL.getHBaseAdmin();
rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
@@ -281,10 +285,10 @@ public class TestEndToEndSplitTransactio
*/
static class RegionChecker extends Chore {
Configuration conf;
- byte[] tableName;
+ TableName tableName;
Throwable ex;
- RegionChecker(Configuration conf, Stoppable stopper, byte[] tableName) {
+ RegionChecker(Configuration conf, Stoppable stopper, TableName tableName) {
super("RegionChecker", 10, stopper);
this.conf = conf;
this.tableName = tableName;
@@ -411,7 +415,7 @@ public class TestEndToEndSplitTransactio
long start = System.currentTimeMillis();
log("blocking until region is split:" + Bytes.toStringBinary(regionName));
HRegionInfo daughterA = null, daughterB = null;
- HTable metaTable = new HTable(conf, HConstants.META_TABLE_NAME);
+ HTable metaTable = new HTable(conf, TableName.META_TABLE_NAME);
try {
while (System.currentTimeMillis() - start < timeout) {
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java Thu Aug 8 06:08:23 2013
@@ -180,7 +180,7 @@ public class TestFSErrorsExposed {
byte[] fam = Bytes.toBytes("fam");
HBaseAdmin admin = new HBaseAdmin(util.getConfiguration());
- HTableDescriptor desc = new HTableDescriptor(tableName);
+ HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(tableName));
desc.addFamily(new HColumnDescriptor(fam)
.setMaxVersions(1)
.setBlockCacheEnabled(false)
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java Thu Aug 8 06:08:23 2013
@@ -26,6 +26,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseTestCase;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionInfo;
@@ -72,11 +73,11 @@ public class TestGetClosestAtOrBefore ex
try {
// Write rows for three tables 'A', 'B', and 'C'.
for (char c = 'A'; c < 'D'; c++) {
- HTableDescriptor htd = new HTableDescriptor("" + c);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("" + c));
final int last = 128;
final int interval = 2;
for (int i = 0; i <= last; i += interval) {
- HRegionInfo hri = new HRegionInfo(htd.getName(),
+ HRegionInfo hri = new HRegionInfo(htd.getTableName(),
i == 0? HConstants.EMPTY_BYTE_ARRAY: Bytes.toBytes((byte)i),
i == last? HConstants.EMPTY_BYTE_ARRAY: Bytes.toBytes((byte)i + interval));
@@ -105,8 +106,9 @@ public class TestGetClosestAtOrBefore ex
findRow(mr, 'C', 46, 46);
findRow(mr, 'C', 43, 42);
// Now delete 'C' and make sure I don't get entries from 'B'.
- byte [] firstRowInC = HRegionInfo.createRegionName(Bytes.toBytes("" + 'C'),
- HConstants.EMPTY_BYTE_ARRAY, HConstants.ZEROES, false);
+ byte [] firstRowInC = HRegionInfo.createRegionName(
+ TableName.valueOf("" + 'C'),
+ HConstants.EMPTY_BYTE_ARRAY, HConstants.ZEROES, false);
Scan scan = new Scan(firstRowInC);
s = mr.getScanner(scan);
try {
@@ -151,10 +153,11 @@ public class TestGetClosestAtOrBefore ex
private byte [] findRow(final HRegion mr, final char table,
final int rowToFind, final int answer)
throws IOException {
- byte [] tableb = Bytes.toBytes("" + table);
+ TableName tableb = TableName.valueOf("" + table);
// Find the row.
byte [] tofindBytes = Bytes.toBytes((short)rowToFind);
- byte [] metaKey = HRegionInfo.createRegionName(tableb, tofindBytes,
+ byte [] metaKey = HRegionInfo.createRegionName(
+ tableb, tofindBytes,
HConstants.NINES, false);
LOG.info("find=" + new String(metaKey));
Result r = mr.getClosestRowBefore(metaKey);
Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=1511591&r1=1511590&r2=1511591&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java Thu Aug 8 06:08:23 2013
@@ -50,6 +50,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
+import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestCase;
import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -253,7 +254,8 @@ public class TestHRegion extends HBaseTe
public void testSkipRecoveredEditsReplay() throws Exception {
String method = "testSkipRecoveredEditsReplay";
- byte[] tableName = Bytes.toBytes(method);
+ TableName tableName =
+ TableName.valueOf(method);
byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, conf, family);
try {
@@ -303,7 +305,8 @@ public class TestHRegion extends HBaseTe
public void testSkipRecoveredEditsReplaySomeIgnored() throws Exception {
String method = "testSkipRecoveredEditsReplaySomeIgnored";
- byte[] tableName = Bytes.toBytes(method);
+ TableName tableName =
+ TableName.valueOf(method);
byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, conf, family);
try {
@@ -396,7 +399,8 @@ public class TestHRegion extends HBaseTe
@Test
public void testRecoveredEditsReplayCompaction() throws Exception {
String method = "testRecoveredEditsReplayCompaction";
- byte[] tableName = Bytes.toBytes(method);
+ TableName tableName =
+ TableName.valueOf(method);
byte[] family = Bytes.toBytes("family");
this.region = initHRegion(tableName, method, conf, family);
try {
@@ -462,7 +466,7 @@ public class TestHRegion extends HBaseTe
HTableDescriptor htd = region.getTableDesc();
HRegionInfo info = region.getRegionInfo();
region.close();
- region = HRegion.openHRegion(conf, fs, regiondir.getParent().getParent(), info, htd, null);
+ region = HRegion.openHRegion(conf, fs, new Path(DIR+method),info, htd, null);
//now check whether we have only one store file, the compacted one
Collection<StoreFile> sfs = region.getStore(family).getStorefiles();
@@ -1698,7 +1702,7 @@ public class TestHRegion extends HBaseTe
public void stestGet_Root() throws IOException {
//Setting up region
String method = this.getName();
- this.region = initHRegion(HConstants.ROOT_TABLE_NAME,
+ this.region = initHRegion(TableName.ROOT_TABLE_NAME,
method, conf, HConstants.CATALOG_FAMILY);
try {
//Add to memstore
@@ -3319,9 +3323,9 @@ public class TestHRegion extends HBaseTe
.setMaxVersions(Integer.MAX_VALUE)
.setBloomFilterType(BloomType.ROWCOL);
- HTableDescriptor htd = new HTableDescriptor(tableName);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
htd.addFamily(hcd);
- HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
Path path = new Path(DIR + "testBloomFilterSize");
this.region = HRegion.createHRegion(info, path, conf, htd);
try {
@@ -3378,9 +3382,9 @@ public class TestHRegion extends HBaseTe
HColumnDescriptor hcd = new HColumnDescriptor(FAMILY)
.setMaxVersions(Integer.MAX_VALUE)
.setBloomFilterType(BloomType.ROWCOL);
- HTableDescriptor htd = new HTableDescriptor(TABLE);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE));
htd.addFamily(hcd);
- HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
Path path = new Path(DIR + "testAllColumnsWithBloomFilter");
this.region = HRegion.createHRegion(info, path, conf, htd);
try {
@@ -3428,9 +3432,9 @@ public class TestHRegion extends HBaseTe
.setMaxVersions(Integer.MAX_VALUE)
.setBloomFilterType(BloomType.ROWCOL);
- HTableDescriptor htd = new HTableDescriptor(tableName);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
htd.addFamily(hcd);
- HRegionInfo info = new HRegionInfo(htd.getName(), null, null, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
Path path = new Path(DIR + "TestDeleteRowWithBloomFilter");
this.region = HRegion.createHRegion(info, path, conf, htd);
try {
@@ -3486,7 +3490,7 @@ public class TestHRegion extends HBaseTe
ht.put(put);
HRegion firstRegion = htu.getHBaseCluster().
- getRegions(Bytes.toBytes(this.getName())).get(0);
+ getRegions(TableName.valueOf(this.getName())).get(0);
firstRegion.flushcache();
HDFSBlocksDistribution blocksDistribution1 =
firstRegion.getHDFSBlocksDistribution();
@@ -3532,9 +3536,9 @@ public class TestHRegion extends HBaseTe
try {
FileSystem fs = Mockito.mock(FileSystem.class);
Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
- HTableDescriptor htd = new HTableDescriptor(tableName);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
htd.addFamily(new HColumnDescriptor("cf"));
- info = new HRegionInfo(htd.getName(), HConstants.EMPTY_BYTE_ARRAY,
+ info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY,
HConstants.EMPTY_BYTE_ARRAY, false);
Path path = new Path(DIR + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
region = HRegion.newHRegion(path, null, fs, conf, info, htd, null);
@@ -3564,10 +3568,10 @@ public class TestHRegion extends HBaseTe
Path rootDir = new Path(DIR + "testRegionInfoFileCreation");
Configuration conf = HBaseConfiguration.create(this.conf);
- HTableDescriptor htd = new HTableDescriptor("testtb");
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("testtb"));
htd.addFamily(new HColumnDescriptor("cf"));
- HRegionInfo hri = new HRegionInfo(htd.getName());
+ HRegionInfo hri = new HRegionInfo(htd.getTableName());
// Create a region and skip the initialization (like CreateTableHandler)
HRegion region = HRegion.createHRegion(hri, rootDir, conf, htd, null, false, true);
@@ -3909,12 +3913,12 @@ public class TestHRegion extends HBaseTe
Durability mutationDurability, long timeout, boolean expectAppend,
final boolean expectSync, final boolean expectSyncFromLogSyncer) throws Exception {
method = method + "_" + tableDurability.name() + "_" + mutationDurability.name();
- byte[] tableName = Bytes.toBytes(method);
+ TableName tableName = TableName.valueOf(method);
byte[] family = Bytes.toBytes("family");
Path logDir = new Path(new Path(DIR + method), "log");
HLog hlog = HLogFactory.createHLog(fs, logDir, UUID.randomUUID().toString(), conf);
final HLog log = spy(hlog);
- this.region = initHRegion(tableName, HConstants.EMPTY_START_ROW,
+ this.region = initHRegion(tableName.getName(), HConstants.EMPTY_START_ROW,
HConstants.EMPTY_END_ROW, method, conf, false,
tableDurability, log, new byte[][] {family});
@@ -4060,6 +4064,20 @@ public class TestHRegion extends HBaseTe
* @throws IOException
* @return A region on which you must call {@link HRegion#closeHRegion(HRegion)} when done.
*/
+ public static HRegion initHRegion (TableName tableName, String callingMethod,
+ Configuration conf, byte [] ... families)
+ throws IOException{
+ return initHRegion(tableName.getName(), null, null, callingMethod, conf, false, families);
+ }
+
+ /**
+ * @param tableName
+ * @param callingMethod
+ * @param conf
+ * @param families
+ * @throws IOException
+ * @return A region on which you must call {@link HRegion#closeHRegion(HRegion)} when done.
+ */
public static HRegion initHRegion (byte [] tableName, String callingMethod,
Configuration conf, byte [] ... families)
throws IOException{
@@ -4103,7 +4121,7 @@ public class TestHRegion extends HBaseTe
String callingMethod, Configuration conf, boolean isReadOnly, Durability durability,
HLog hlog, byte[]... families)
throws IOException {
- HTableDescriptor htd = new HTableDescriptor(tableName);
+ HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
htd.setReadOnly(isReadOnly);
for(byte [] family : families) {
HColumnDescriptor hcd = new HColumnDescriptor(family);
@@ -4112,7 +4130,7 @@ public class TestHRegion extends HBaseTe
htd.addFamily(hcd);
}
htd.setDurability(durability);
- HRegionInfo info = new HRegionInfo(htd.getName(), startKey, stopKey, false);
+ HRegionInfo info = new HRegionInfo(htd.getTableName(), startKey, stopKey, false);
Path path = new Path(DIR + callingMethod);
FileSystem fs = FileSystem.get(conf);
if (fs.exists(path)) {