You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zy...@apache.org on 2019/04/22 22:56:42 UTC
[hbase] branch branch-2.0 updated: HBASE-22200 -
WALSplitter.hasRecoveredEdits should use same FS instance from WAL region
dir
This is an automated email from the ASF dual-hosted git repository.
zyork pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new c3f9264 HBASE-22200 - WALSplitter.hasRecoveredEdits should use same FS instance from WAL region dir
c3f9264 is described below
commit c3f926419d3815a58912c570bb63d4e261a5ae34
Author: Wellington Chevreuil <we...@gmail.com>
AuthorDate: Thu Apr 11 09:27:24 2019 +0100
HBASE-22200 - WALSplitter.hasRecoveredEdits should use same FS instance from WAL region dir
Signed-off-by: Zach York <zy...@apache.org>
---
.../assignment/SplitTableRegionProcedure.java | 3 +-
.../org/apache/hadoop/hbase/wal/WALSplitter.java | 7 ++--
.../org/apache/hadoop/hbase/wal/TestWALSplit.java | 48 ++++++++++++----------
3 files changed, 31 insertions(+), 27 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java
index 3b81d7a..493e42e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/SplitTableRegionProcedure.java
@@ -148,8 +148,7 @@ public class SplitTableRegionProcedure
* @throws IOException IOException
*/
static boolean hasRecoveredEdits(MasterProcedureEnv env, RegionInfo ri) throws IOException {
- return WALSplitter.hasRecoveredEdits(env.getMasterServices().getFileSystem(),
- env.getMasterConfiguration(), ri);
+ return WALSplitter.hasRecoveredEdits(env.getMasterConfiguration(), ri);
}
/**
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java
index d936561..8a245cd 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/WALSplitter.java
@@ -538,14 +538,13 @@ public class WALSplitter {
/**
* Check whether there is recovered.edits in the region dir
- * @param walFS FileSystem
* @param conf conf
* @param regionInfo the region to check
* @throws IOException IOException
* @return true if recovered.edits exist in the region dir
*/
- public static boolean hasRecoveredEdits(final FileSystem walFS,
- final Configuration conf, final RegionInfo regionInfo) throws IOException {
+ public static boolean hasRecoveredEdits(final Configuration conf,
+ final RegionInfo regionInfo) throws IOException {
// No recovered.edits for non default replica regions
if (regionInfo.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) {
return false;
@@ -554,7 +553,7 @@ public class WALSplitter {
//directly without converting it to default replica's regioninfo.
Path regionDir = FSUtils.getWALRegionDir(conf, regionInfo.getTable(),
regionInfo.getEncodedName());
- NavigableSet<Path> files = getSplitEditFilesSorted(walFS, regionDir);
+ NavigableSet<Path> files = getSplitEditFilesSorted(FSUtils.getWALFileSystem(conf), regionDir);
return files != null && !files.isEmpty();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java
index 2036027..e975237 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALSplit.java
@@ -380,18 +380,7 @@ public class TestWALSplit {
*/
@Test
public void testRecoveredEditsPathForMeta() throws IOException {
- byte[] encoded = RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes();
- Path tdir = FSUtils.getTableDir(HBASEDIR, TableName.META_TABLE_NAME);
- Path regiondir = new Path(tdir,
- RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedName());
- fs.mkdirs(regiondir);
- long now = System.currentTimeMillis();
- Entry entry =
- new Entry(new WALKeyImpl(encoded,
- TableName.META_TABLE_NAME, 1, now, HConstants.DEFAULT_CLUSTER_ID),
- new WALEdit());
- Path p = WALSplitter.getRegionSplitEditsPath(entry,
- FILENAME_BEING_SPLIT, conf);
+ Path p = createRecoveredEditsPathForRegion();
String parentOfParent = p.getParent().getParent().getName();
assertEquals(parentOfParent, RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedName());
}
@@ -402,27 +391,44 @@ public class TestWALSplit {
*/
@Test
public void testOldRecoveredEditsFileSidelined() throws IOException {
- byte [] encoded = RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes();
+ Path p = createRecoveredEditsPathForRegion();
Path tdir = FSUtils.getTableDir(HBASEDIR, TableName.META_TABLE_NAME);
Path regiondir = new Path(tdir,
RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedName());
fs.mkdirs(regiondir);
- long now = System.currentTimeMillis();
- Entry entry =
- new Entry(new WALKeyImpl(encoded,
- TableName.META_TABLE_NAME, 1, now, HConstants.DEFAULT_CLUSTER_ID),
- new WALEdit());
Path parent = WALSplitter.getRegionDirRecoveredEditsDir(regiondir);
assertEquals(HConstants.RECOVERED_EDITS_DIR, parent.getName());
fs.createNewFile(parent); // create a recovered.edits file
-
- Path p = WALSplitter.getRegionSplitEditsPath(entry,
- FILENAME_BEING_SPLIT, conf);
String parentOfParent = p.getParent().getParent().getName();
assertEquals(parentOfParent, RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedName());
WALFactory.createRecoveredEditsWriter(fs, p, conf).close();
}
+ private Path createRecoveredEditsPathForRegion() throws IOException{
+ byte[] encoded = RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes();
+ long now = System.currentTimeMillis();
+ Entry entry =
+ new Entry(new WALKeyImpl(encoded,
+ TableName.META_TABLE_NAME, 1, now, HConstants.DEFAULT_CLUSTER_ID),
+ new WALEdit());
+ Path p = WALSplitter.getRegionSplitEditsPath(entry,
+ FILENAME_BEING_SPLIT, conf);
+ return p;
+ }
+
+ /**
+ * Test hasRecoveredEdits correctly identifies proper recovered edits file on related dir.
+ * @throws IOException on any issues found while creating test required files/directories.
+ */
+ @Test
+ public void testHasRecoveredEdits() throws IOException {
+ Path p = createRecoveredEditsPathForRegion();
+ assertFalse(WALSplitter.hasRecoveredEdits(conf, RegionInfoBuilder.FIRST_META_REGIONINFO));
+ String renamedEdit = p.getName().split("-")[0];
+ fs.createNewFile(new Path(p.getParent(), renamedEdit));
+ assertTrue(WALSplitter.hasRecoveredEdits(conf, RegionInfoBuilder.FIRST_META_REGIONINFO));
+ }
+
private void useDifferentDFSClient() throws IOException {
// make fs act as a different client now
// initialize will create a new DFSClient with a new client ID