You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2020/03/03 14:13:29 UTC
[hbase] branch master updated: HBASE-23912 Resolve the TODO of
FSTableDescriptor's construct method (#1225)
This is an automated email from the ASF dual-hosted git repository.
zghao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new 5dcbe68 HBASE-23912 Resolve the TODO of FSTableDescriptor's construct method (#1225)
5dcbe68 is described below
commit 5dcbe687aee4c65eefe39b7648874fb96efaa9a9
Author: Guanghao Zhang <zg...@apache.org>
AuthorDate: Tue Mar 3 22:13:16 2020 +0800
HBASE-23912 Resolve the TODO of FSTableDescriptor's construct method (#1225)
Signed-off-by: Duo Zhang <zh...@apache.org>
---
.../hadoop/hbase/backup/util/BackupUtils.java | 3 +-
.../org/apache/hadoop/hbase/master/HMaster.java | 5 --
.../hadoop/hbase/master/MasterFileSystem.java | 3 +-
.../hadoop/hbase/regionserver/HRegionServer.java | 20 ++----
.../hadoop/hbase/util/FSTableDescriptors.java | 83 ++++++++++------------
.../hbase/TestFSTableDescriptorForceCreation.java | 6 +-
.../coprocessor/TestCoreMasterCoprocessor.java | 1 -
.../hbase/regionserver/TestDefaultMemStore.java | 1 +
.../regionserver/TestGetClosestAtOrBefore.java | 1 +
.../hadoop/hbase/regionserver/TestHRegionInfo.java | 1 +
.../hbase/regionserver/TestRegionInfoBuilder.java | 1 +
.../regionserver/wal/TestLogRollingNoCluster.java | 5 +-
.../hadoop/hbase/util/TestFSTableDescriptors.java | 46 ++++++------
13 files changed, 77 insertions(+), 99 deletions(-)
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
index 6c13cc8..970725e 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/util/BackupUtils.java
@@ -138,8 +138,7 @@ public final class BackupUtils {
// write a copy of descriptor to the target directory
Path target = new Path(backupInfo.getTableBackupDir(table));
FileSystem targetFs = target.getFileSystem(conf);
- FSTableDescriptors descriptors =
- new FSTableDescriptors(conf, targetFs, FSUtils.getRootDir(conf));
+ FSTableDescriptors descriptors = new FSTableDescriptors(targetFs, FSUtils.getRootDir(conf));
descriptors.createTableDescriptorForTableDirectory(target, orig, false);
LOG.debug("Attempting to copy table info for:" + table + " target: " + target
+ " descriptor: " + orig);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index a4aef98..15563d0 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -49,7 +49,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.servlet.ServletException;
@@ -695,10 +694,6 @@ public class HMaster extends HRegionServer implements MasterServices {
return connector.getLocalPort();
}
- @Override
- protected Function<TableDescriptorBuilder, TableDescriptorBuilder> getMetaTableObserver() {
- return builder -> builder.setRegionReplication(conf.getInt(HConstants.META_REPLICAS_NUM, HConstants.DEFAULT_META_REPLICA_NUM));
- }
/**
* For compatibility, if failed with regionserver credentials, try the master one
*/
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
index d36e525..288684c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
@@ -297,7 +297,7 @@ public class MasterFileSystem {
// assume, created table descriptor is for enabling table
// meta table is a system table, so descriptors are predefined,
// we should get them from registry.
- FSTableDescriptors fsd = new FSTableDescriptors(c, fs, rd);
+ FSTableDescriptors fsd = new FSTableDescriptors(fs, rd);
fsd.createTableDescriptor(fsd.get(TableName.META_TABLE_NAME));
return rd;
@@ -403,6 +403,7 @@ public class MasterFileSystem {
// created here in bootstrap and it'll need to be cleaned up. Better to
// not make it in first place. Turn off block caching for bootstrap.
// Enable after.
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(c);
TableDescriptor metaDescriptor = new FSTableDescriptors(c).get(TableName.META_TABLE_NAME);
HRegion meta = HRegion.createHRegion(RegionInfoBuilder.FIRST_META_REGIONINFO, rd,
c, setInfoFamilyCachingForMeta(metaDescriptor, false), null);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 27bec3c..6983009 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -53,7 +53,6 @@ import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.function.Function;
import javax.management.MalformedObjectNameException;
import javax.servlet.http.HttpServlet;
import org.apache.commons.lang3.RandomUtils;
@@ -91,7 +90,6 @@ import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.ConnectionUtils;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
-import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
import org.apache.hadoop.hbase.client.locking.EntityLock;
import org.apache.hadoop.hbase.client.locking.LockServiceClient;
import org.apache.hadoop.hbase.conf.ConfigurationManager;
@@ -717,16 +715,13 @@ public class HRegionServer extends HasThread implements
FSUtils.setFsDefault(this.conf, FSUtils.getRootDir(this.conf));
this.dataFs = new HFileSystem(this.conf, useHBaseChecksum);
this.dataRootDir = FSUtils.getRootDir(this.conf);
- this.tableDescriptors = getFsTableDescriptors();
- }
-
- private TableDescriptors getFsTableDescriptors() throws IOException {
- return new FSTableDescriptors(this.conf,
- this.dataFs, this.dataRootDir, !canUpdateTableDescriptor(), false, getMetaTableObserver());
- }
-
- protected Function<TableDescriptorBuilder, TableDescriptorBuilder> getMetaTableObserver() {
- return null;
+ this.tableDescriptors =
+ new FSTableDescriptors(this.dataFs, this.dataRootDir, !canUpdateTableDescriptor(), false);
+ if (this instanceof HMaster) {
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(this.conf, this.dataFs, this.dataRootDir,
+ builder -> builder.setRegionReplication(
+ conf.getInt(HConstants.META_REPLICAS_NUM, HConstants.DEFAULT_META_REPLICA_NUM)));
+ }
}
protected void login(UserProvider user, String host) throws IOException {
@@ -734,7 +729,6 @@ public class HRegionServer extends HasThread implements
SecurityConstants.REGIONSERVER_KRB_PRINCIPAL, host);
}
-
/**
* Wait for an active Master.
* See override in Master superclass for how it is used.
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
index 52d546a..a973153 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSTableDescriptors.java
@@ -100,56 +100,49 @@ public class FSTableDescriptors implements TableDescriptors {
private final Map<TableName, TableDescriptor> cache = new ConcurrentHashMap<>();
/**
- * Construct a FSTableDescriptors instance using the hbase root dir of the given
- * conf and the filesystem where that root dir lives.
- * This instance can do write operations (is not read only).
+ * Construct a FSTableDescriptors instance using the hbase root dir of the given conf and the
+ * filesystem where that root dir lives. This instance can do write operations (is not read only).
*/
public FSTableDescriptors(final Configuration conf) throws IOException {
- this(conf, FSUtils.getCurrentFileSystem(conf), FSUtils.getRootDir(conf));
+ this(FSUtils.getCurrentFileSystem(conf), FSUtils.getRootDir(conf));
}
- public FSTableDescriptors(final Configuration conf, final FileSystem fs, final Path rootdir)
- throws IOException {
- this(conf, fs, rootdir, false, true);
+ public FSTableDescriptors(final FileSystem fs, final Path rootdir) {
+ this(fs, rootdir, false, true);
}
- /**
- * @param fsreadonly True if we are read-only when it comes to filesystem
- * operations; i.e. on remove, we do not do delete in fs.
- */
- @VisibleForTesting
- public FSTableDescriptors(final Configuration conf, final FileSystem fs,
- final Path rootdir, final boolean fsreadonly, final boolean usecache) throws IOException {
- this(conf, fs, rootdir, fsreadonly, usecache, null);
- }
-
- /**
- * @param fsreadonly True if we are read-only when it comes to filesystem
- * operations; i.e. on remove, we do not do delete in fs.
- * @param metaObserver Used by HMaster. It need to modify the META_REPLICAS_NUM for meta table descriptor.
- * see HMaster#finishActiveMasterInitialization
- * TODO: This is a workaround. Should remove this ugly code...
- */
- public FSTableDescriptors(final Configuration conf, final FileSystem fs, final Path rootdir,
- final boolean fsreadonly, final boolean usecache,
- Function<TableDescriptorBuilder, TableDescriptorBuilder> metaObserver) throws IOException {
+ public FSTableDescriptors(final FileSystem fs, final Path rootdir, final boolean fsreadonly,
+ final boolean usecache) {
this.fs = fs;
this.rootdir = rootdir;
this.fsreadonly = fsreadonly;
this.usecache = usecache;
- if (!fsreadonly) {
- // see if we already have meta descriptor on fs. Write one if not.
- try {
- getTableDescriptorFromFs(fs, rootdir, TableName.META_TABLE_NAME);
- } catch (TableInfoMissingException e) {
- TableDescriptorBuilder builder = createMetaTableDescriptorBuilder(conf);
- if (metaObserver != null) {
- builder = metaObserver.apply(builder);
- }
- TableDescriptor td = builder.build();
- LOG.info("Creating new hbase:meta table default descriptor/schema {}", td);
- updateTableDescriptor(td);
+ }
+
+ public static void tryUpdateMetaTableDescriptor(Configuration conf) throws IOException {
+ tryUpdateMetaTableDescriptor(conf, FSUtils.getCurrentFileSystem(conf), FSUtils.getRootDir(conf),
+ null);
+ }
+
+ public static void tryUpdateMetaTableDescriptor(Configuration conf, FileSystem fs, Path rootdir,
+ Function<TableDescriptorBuilder, TableDescriptorBuilder> metaObserver) throws IOException {
+ // see if we already have meta descriptor on fs. Write one if not.
+ try {
+ getTableDescriptorFromFs(fs, rootdir, TableName.META_TABLE_NAME);
+ } catch (TableInfoMissingException e) {
+ TableDescriptorBuilder builder = createMetaTableDescriptorBuilder(conf);
+ if (metaObserver != null) {
+ builder = metaObserver.apply(builder);
}
+ TableDescriptor td = builder.build();
+ LOG.info("Creating new hbase:meta table descriptor {}", td);
+ TableName tableName = td.getTableName();
+ Path tableDir = FSUtils.getTableDir(rootdir, tableName);
+ Path p = writeTableDescriptor(fs, td, tableDir, getTableInfoPath(fs, tableDir, true));
+ if (p == null) {
+ throw new IOException("Failed update hbase:meta table descriptor");
+ }
+ LOG.info("Updated hbase:meta table descriptor to {}", p);
}
}
@@ -333,8 +326,7 @@ public class FSTableDescriptors implements TableDescriptors {
* from the FileSystem.
*/
@Override
- public TableDescriptor remove(final TableName tablename)
- throws IOException {
+ public TableDescriptor remove(final TableName tablename) throws IOException {
if (fsreadonly) {
throw new NotImplementedException("Cannot remove a table descriptor - in read only mode");
}
@@ -348,8 +340,7 @@ public class FSTableDescriptors implements TableDescriptors {
return descriptor;
}
- private FileStatus getTableInfoPath(Path tableDir)
- throws IOException {
+ private FileStatus getTableInfoPath(Path tableDir) throws IOException {
return getTableInfoPath(fs, tableDir, !fsreadonly);
}
@@ -381,7 +372,7 @@ public class FSTableDescriptors implements TableDescriptors {
* @return The file status of the current table info file or null if none exist
*/
private static FileStatus getTableInfoPath(FileSystem fs, Path tableDir, boolean removeOldFiles)
- throws IOException {
+ throws IOException {
Path tableInfoDir = new Path(tableDir, TABLEINFO_DIR);
return getCurrentTableInfoStatus(fs, tableInfoDir, removeOldFiles);
}
@@ -720,8 +711,8 @@ public class FSTableDescriptors implements TableDescriptors {
* already exists and we weren't forcing the descriptor creation.
* @throws IOException if a filesystem error occurs
*/
- public static boolean createTableDescriptorForTableDirectory(FileSystem fs,
- Path tableDir, TableDescriptor htd, boolean forceCreation) throws IOException {
+ public static boolean createTableDescriptorForTableDirectory(FileSystem fs, Path tableDir,
+ TableDescriptor htd, boolean forceCreation) throws IOException {
FileStatus status = getTableInfoPath(fs, tableDir);
if (status != null) {
LOG.debug("Current path=" + status.getPath());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestFSTableDescriptorForceCreation.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestFSTableDescriptorForceCreation.java
index 57da486..d627244 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestFSTableDescriptorForceCreation.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestFSTableDescriptorForceCreation.java
@@ -52,7 +52,7 @@ public class TestFSTableDescriptorForceCreation {
final String name = this.name.getMethodName();
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir);
assertTrue("Should create new table descriptor",
fstd.createTableDescriptor(TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build(), false));
@@ -65,7 +65,7 @@ public class TestFSTableDescriptorForceCreation {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any detritus laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir);
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
fstd.update(htd);
assertFalse("Should not create new table descriptor", fstd.createTableDescriptor(htd, false));
@@ -77,7 +77,7 @@ public class TestFSTableDescriptorForceCreation {
final String name = this.name.getMethodName();
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir);
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
fstd.createTableDescriptor(htd, false);
assertTrue("Should create new table descriptor",
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoreMasterCoprocessor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoreMasterCoprocessor.java
index dcf1ad3..e0975fa 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoreMasterCoprocessor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestCoreMasterCoprocessor.java
@@ -43,7 +43,6 @@ import org.junit.rules.TestName;
*/
@Category({CoprocessorTests.class, SmallTests.class})
public class TestCoreMasterCoprocessor {
-
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCoreMasterCoprocessor.class);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java
index 9e7c038..27b301f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java
@@ -950,6 +950,7 @@ public class TestDefaultMemStore {
edge.setCurrentTimeMillis(1234);
WALFactory wFactory = new WALFactory(conf, "1234");
TableDescriptors tds = new FSTableDescriptors(conf);
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(conf);
HRegion meta = HRegion.createHRegion(RegionInfoBuilder.FIRST_META_REGIONINFO, testDir,
conf, tds.get(TableName.META_TABLE_NAME),
wFactory.getWAL(RegionInfoBuilder.FIRST_META_REGIONINFO));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java
index ecd614c..fdc0247 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestGetClosestAtOrBefore.java
@@ -91,6 +91,7 @@ public class TestGetClosestAtOrBefore {
Path rootdir = UTIL.getDataTestDirOnTestFS();
// Up flush size else we bind up when we use default catalog flush of 16k.
TableDescriptors tds = new FSTableDescriptors(UTIL.getConfiguration());
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(UTIL.getConfiguration());
TableDescriptor td = tds.get(TableName.META_TABLE_NAME);
td = TableDescriptorBuilder.newBuilder(td).setMemStoreFlushSize(64 * 1024 * 1024).build();
HRegion mr = HBaseTestingUtility.createRegionAndWAL(HRegionInfo.FIRST_META_REGIONINFO,
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java
index ff95f59..f9e2d5a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java
@@ -146,6 +146,7 @@ public class TestHRegionInfo {
Path basedir = htu.getDataTestDir();
// Create a region. That'll write the .regioninfo file.
FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(htu.getConfiguration());
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(htu.getConfiguration());
HRegion r = HBaseTestingUtility.createRegionAndWAL(hri, basedir, htu.getConfiguration(),
fsTableDescriptors.get(TableName.META_TABLE_NAME));
// Get modtime on the file.
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionInfoBuilder.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionInfoBuilder.java
index 3f778c2..90bab5c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionInfoBuilder.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionInfoBuilder.java
@@ -103,6 +103,7 @@ public class TestRegionInfoBuilder {
Path basedir = htu.getDataTestDir();
// Create a region. That'll write the .regioninfo file.
FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(htu.getConfiguration());
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(htu.getConfiguration());
HRegion r = HBaseTestingUtility.createRegionAndWAL(convert(ri), basedir, htu.getConfiguration(),
fsTableDescriptors.get(TableName.META_TABLE_NAME));
// Get modtime on the file.
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java
index 6366718..e963182 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/TestLogRollingNoCluster.java
@@ -92,8 +92,8 @@ public class TestLogRollingNoCluster {
final Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
conf.set(WALFactory.WAL_PROVIDER, "filesystem");
FSUtils.setRootDir(conf, dir);
- FSTableDescriptors fsTableDescriptors =
- new FSTableDescriptors(TEST_UTIL.getConfiguration());
+ FSTableDescriptors fsTableDescriptors = new FSTableDescriptors(TEST_UTIL.getConfiguration());
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(TEST_UTIL.getConfiguration());
TableDescriptor metaTableDescriptor = fsTableDescriptors.get(TableName.META_TABLE_NAME);
conf.set("hbase.regionserver.hlog.writer.impl", HighLatencySyncWriter.class.getName());
final WALFactory wals = new WALFactory(conf, TestLogRollingNoCluster.class.getName());
@@ -159,6 +159,7 @@ public class TestLogRollingNoCluster {
final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl();
try {
TableDescriptors tds = new FSTableDescriptors(TEST_UTIL.getConfiguration());
+ FSTableDescriptors.tryUpdateMetaTableDescriptor(TEST_UTIL.getConfiguration());
TableDescriptor htd = tds.get(TableName.META_TABLE_NAME);
for (int i = 0; i < this.count; i++) {
long now = System.currentTimeMillis();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
index 718cec3..3b451e3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestFSTableDescriptors.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
-import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
@@ -87,7 +86,7 @@ public class TestFSTableDescriptors {
Path testdir = UTIL.getDataTestDir(name.getMethodName());
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build();
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, testdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, testdir);
assertTrue(fstd.createTableDescriptor(htd));
assertFalse(fstd.createTableDescriptor(htd));
FileStatus [] statuses = fs.listStatus(testdir);
@@ -107,7 +106,7 @@ public class TestFSTableDescriptors {
Path testdir = UTIL.getDataTestDir(name.getMethodName());
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build();
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, testdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, testdir);
Path p0 = fstd.updateTableDescriptor(htd);
int i0 = FSTableDescriptors.getTableInfoSequenceId(p0);
Path p1 = fstd.updateTableDescriptor(htd);
@@ -167,7 +166,7 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any detrius laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- TableDescriptors htds = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
htds.update(htd);
assertNotNull(htds.remove(htd.getTableName()));
@@ -179,7 +178,7 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
Path rootdir = UTIL.getDataTestDir(name);
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir);
fstd.createTableDescriptor(htd);
TableDescriptor td2 =
FSTableDescriptors.getTableDescriptorFromFs(fs, rootdir, htd.getTableName());
@@ -190,13 +189,13 @@ public class TestFSTableDescriptors {
final String name = this.name.getMethodName();
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
Path rootdir = UTIL.getDataTestDir(name);
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir);
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
Path descriptorFile = fstd.updateTableDescriptor(htd);
try (FSDataOutputStream out = fs.create(descriptorFile, true)) {
out.write(TableDescriptorBuilder.toByteArray(htd));
}
- FSTableDescriptors fstd2 = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ FSTableDescriptors fstd2 = new FSTableDescriptors(fs, rootdir);
TableDescriptor td2 = fstd2.get(htd.getTableName());
assertEquals(htd, td2);
FileStatus descriptorFile2 =
@@ -215,7 +214,7 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any debris laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors htds = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir) {
+ FSTableDescriptors htds = new FSTableDescriptors(fs, rootdir) {
@Override
public TableDescriptor get(TableName tablename)
throws TableExistsException, FileNotFoundException, IOException {
@@ -261,8 +260,7 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any debris laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors htds = new FSTableDescriptorsTest(UTIL.getConfiguration(), fs, rootdir,
- false, false);
+ FSTableDescriptors htds = new FSTableDescriptorsTest(fs, rootdir, false);
final int count = 10;
// Write out table infos.
for (int i = 0; i < count; i++) {
@@ -294,7 +292,7 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any debris laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors htds = new FSTableDescriptorsTest(UTIL.getConfiguration(), fs, rootdir);
+ FSTableDescriptors htds = new FSTableDescriptorsTest(fs, rootdir);
final int count = 4;
// Write out table infos.
for (int i = 0; i < count; i++) {
@@ -313,7 +311,7 @@ public class TestFSTableDescriptors {
final String name = "testGetAllOrdering";
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
Path rootDir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors tds = new FSTableDescriptorsTest(UTIL.getConfiguration(), fs, rootDir);
+ FSTableDescriptors tds = new FSTableDescriptorsTest(fs, rootDir);
String[] tableNames = new String[] { "foo", "bar", "foo:bar", "bar:foo" };
for (String tableName : tableNames) {
@@ -347,9 +345,8 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any debris laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- FSTableDescriptors chtds = new FSTableDescriptorsTest(UTIL.getConfiguration(), fs, rootdir);
- FSTableDescriptors nonchtds = new FSTableDescriptorsTest(UTIL.getConfiguration(), fs,
- rootdir, false, false);
+ FSTableDescriptors chtds = new FSTableDescriptorsTest(fs, rootdir);
+ FSTableDescriptors nonchtds = new FSTableDescriptorsTest(fs, rootdir, false);
final int count = 10;
// Write out table infos via non-cached FSTableDescriptors
@@ -387,7 +384,7 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any detrius laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- TableDescriptors htds = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
assertNull("There shouldn't be any HTD for this table",
htds.get(TableName.valueOf("NoSuchTable")));
}
@@ -398,7 +395,7 @@ public class TestFSTableDescriptors {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any detrius laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
- TableDescriptors htds = new FSTableDescriptors(UTIL.getConfiguration(), fs, rootdir);
+ TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build();
htds.update(htd);
htds.update(htd);
@@ -435,8 +432,7 @@ public class TestFSTableDescriptors {
public void testReadingInvalidDirectoryFromFS() throws IOException {
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
try {
- new FSTableDescriptors(UTIL.getConfiguration(), fs,
- FSUtils.getRootDir(UTIL.getConfiguration()))
+ new FSTableDescriptors(fs, FSUtils.getRootDir(UTIL.getConfiguration()))
.get(TableName.valueOf(HConstants.HBASE_TEMP_DIRECTORY));
fail("Shouldn't be able to read a table descriptor for the archive directory.");
} catch (Exception e) {
@@ -450,7 +446,7 @@ public class TestFSTableDescriptors {
Path testdir = UTIL.getDataTestDir(name.getMethodName());
TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build();
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
- FSTableDescriptors fstd = new FSTableDescriptors(UTIL.getConfiguration(), fs, testdir);
+ FSTableDescriptors fstd = new FSTableDescriptors(fs, testdir);
assertTrue(fstd.createTableDescriptor(htd));
assertFalse(fstd.createTableDescriptor(htd));
htd = TableDescriptorBuilder.newBuilder(htd)
@@ -467,14 +463,12 @@ public class TestFSTableDescriptors {
private static class FSTableDescriptorsTest extends FSTableDescriptors {
- public FSTableDescriptorsTest(Configuration conf, FileSystem fs, Path rootdir)
- throws IOException {
- this(conf, fs, rootdir, false, true);
+ public FSTableDescriptorsTest(FileSystem fs, Path rootdir) {
+ this(fs, rootdir, true);
}
- public FSTableDescriptorsTest(Configuration conf, FileSystem fs, Path rootdir,
- boolean fsreadonly, boolean usecache) throws IOException {
- super(conf, fs, rootdir, fsreadonly, usecache);
+ public FSTableDescriptorsTest(FileSystem fs, Path rootdir, boolean usecache) {
+ super(fs, rootdir, false, usecache);
}
@Override