-
Notifications
You must be signed in to change notification settings - Fork 151
HBASE-25921 Fix Wrong FileSystem when running filesystem on non-HDFS storage
#88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
baaf17e
HBASE-25921 Fix Wrong FileSystem when running `filesystem` on non-HDF…
aa797e2
copied code from CommonFSUtils to HBCKFsUtils and add unit tests
133e5d5
cut down the changes of HBCKFsUtils
0991bfd
rename getCurrentFileSystem to getRootDirFileSystem
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
hbase-hbck2/src/test/java/org/apache/hbase/hbck1/TestHBaseFsck.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| /* | ||
| * 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.hbase.hbck1; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertNotEquals; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import java.io.IOException; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.hadoop.fs.LocalFileSystem; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
| import org.apache.hadoop.hbase.HBaseTestingUtility; | ||
| import org.apache.hadoop.hbase.HConstants; | ||
| import org.apache.hadoop.hbase.testclassification.MiscTests; | ||
| import org.apache.hadoop.hbase.testclassification.SmallTests; | ||
| import org.apache.hbase.HBCKFsUtils; | ||
| import org.junit.AfterClass; | ||
| import org.junit.Before; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.experimental.categories.Category; | ||
| import org.junit.rules.TestName; | ||
|
|
||
| @Category({MiscTests.class, SmallTests.class}) | ||
| public class TestHBaseFsck { | ||
| @ClassRule | ||
| public static final HBaseClassTestRule CLASS_RULE = | ||
| HBaseClassTestRule.forClass(TestHBaseFsck.class); | ||
|
|
||
| private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); | ||
|
|
||
| private String defaultRootDir; | ||
| private String nonDefaultRootDir; | ||
| private FileSystem testFileSystem; | ||
| private LocalFileSystem localFileSystem; | ||
| private Configuration conf; | ||
|
|
||
| @Rule | ||
| public TestName testName = new TestName(); | ||
|
|
||
| @BeforeClass | ||
| public static void beforeClass() throws Exception { | ||
| TEST_UTIL.startMiniCluster(3); | ||
| } | ||
|
|
||
| @AfterClass | ||
| public static void afterClass() throws Exception { | ||
| TEST_UTIL.shutdownMiniCluster(); | ||
| } | ||
|
|
||
| @Before | ||
| public void setup() throws IOException { | ||
| conf = TEST_UTIL.getConfiguration(); | ||
| // the default is a hdfs directory | ||
| defaultRootDir = TEST_UTIL.getDataTestDirOnTestFS().toString(); | ||
| localFileSystem = new LocalFileSystem(); | ||
| testFileSystem = TEST_UTIL.getTestFileSystem(); | ||
| nonDefaultRootDir = | ||
| TEST_UTIL.getRandomDir().makeQualified(localFileSystem.getUri(), | ||
| localFileSystem.getWorkingDirectory()).toString(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testHBaseRootDirWithSameFileSystemScheme() throws IOException, | ||
| ClassNotFoundException { | ||
| checkFileSystemScheme(defaultRootDir, testFileSystem.getUri().getScheme()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testHBaseRootDirWithDifferentFileSystemScheme() throws IOException, | ||
| ClassNotFoundException { | ||
| checkFileSystemScheme(nonDefaultRootDir, localFileSystem.getUri().getScheme()); | ||
| } | ||
|
|
||
| private void checkFileSystemScheme(String hbaseRootDir, String expectedFsScheme) | ||
| throws IOException, ClassNotFoundException { | ||
| conf.set(HConstants.HBASE_DIR, hbaseRootDir); | ||
| HBaseFsck fsck = new HBaseFsck(conf); | ||
| String actualFsScheme = fsck.getRootFs().getScheme(); | ||
| assertEquals(expectedFsScheme, actualFsScheme); | ||
| } | ||
|
|
||
| @Test | ||
| public void testFileLockCallableWithSetHBaseRootDir() throws IOException { | ||
| FileSystem fs = new Path(nonDefaultRootDir).getFileSystem(conf); | ||
| try { | ||
| assertNotEquals(TEST_UTIL.getTestFileSystem().getUri().getScheme(), | ||
| fs.getScheme()); | ||
|
|
||
| conf.set(HConstants.HBASE_DIR, nonDefaultRootDir); | ||
| Path expectedLockFilePath = new Path(HBaseFsck.getTmpDir(conf), HBaseFsck.HBCK2_LOCK_FILE); | ||
| HBaseFsck.FileLockCallable fileLockCallable = new HBaseFsck.FileLockCallable(conf, | ||
| HBaseFsck.createLockRetryCounterFactory(conf).create()); | ||
|
|
||
| assertTrue(!fs.exists(expectedLockFilePath)); | ||
| // make a call and generate the hbck2 lock file to the non default file system | ||
| fileLockCallable.call(); | ||
| assertTrue(fs.exists(expectedLockFilePath)); | ||
| } finally { | ||
| HBCKFsUtils.delete(fs, new Path(nonDefaultRootDir), true); | ||
| } | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not on this patch. But here is an issue. The actual delete() call happening within a Log statement. If INFO level not enabled, the delete wont get called. Can we fix that also here pls?