HBASE-22095 Taking a snapshot fails in local mode
Signed-off-by: Zach York <zyork@apache.org>
This commit is contained in:
parent
21cb00eef6
commit
94c18f0653
|
@ -277,6 +277,7 @@ public abstract class TakeSnapshotHandler extends EventHandler implements Snapsh
|
||||||
URI workingURI = workingDirFs.getUri();
|
URI workingURI = workingDirFs.getUri();
|
||||||
URI rootURI = fs.getUri();
|
URI rootURI = fs.getUri();
|
||||||
if ((!workingURI.getScheme().equals(rootURI.getScheme()) ||
|
if ((!workingURI.getScheme().equals(rootURI.getScheme()) ||
|
||||||
|
workingURI.getAuthority() == null ||
|
||||||
!workingURI.getAuthority().equals(rootURI.getAuthority()) ||
|
!workingURI.getAuthority().equals(rootURI.getAuthority()) ||
|
||||||
workingURI.getUserInfo() == null ||
|
workingURI.getUserInfo() == null ||
|
||||||
!workingURI.getUserInfo().equals(rootURI.getUserInfo()) ||
|
!workingURI.getUserInfo().equals(rootURI.getUserInfo()) ||
|
||||||
|
@ -365,5 +366,4 @@ public abstract class TakeSnapshotHandler extends EventHandler implements Snapsh
|
||||||
public ForeignException getException() {
|
public ForeignException getException() {
|
||||||
return monitor.getException();
|
return monitor.getException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,9 +271,11 @@ public final class SnapshotDescriptionUtils {
|
||||||
* @param conf configuration for the HBase cluster
|
* @param conf configuration for the HBase cluster
|
||||||
* @return true if the given workingDir is a subdirectory of the default working directory for
|
* @return true if the given workingDir is a subdirectory of the default working directory for
|
||||||
* snapshots, false otherwise
|
* snapshots, false otherwise
|
||||||
|
* @throws IOException if we can't get the root dir
|
||||||
*/
|
*/
|
||||||
public static boolean isWithinDefaultWorkingDir(final Path workingDir, Configuration conf) {
|
public static boolean isWithinDefaultWorkingDir(final Path workingDir, Configuration conf)
|
||||||
Path defaultWorkingDir = getDefaultWorkingSnapshotDir(new Path(conf.get(HConstants.HBASE_DIR)));
|
throws IOException {
|
||||||
|
Path defaultWorkingDir = getDefaultWorkingSnapshotDir(FSUtils.getRootDir(conf));
|
||||||
return workingDir.equals(defaultWorkingDir) || isSubDirectoryOf(workingDir, defaultWorkingDir);
|
return workingDir.equals(defaultWorkingDir) || isSubDirectoryOf(workingDir, defaultWorkingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
import org.apache.hadoop.hbase.HBaseClassTestRule;
|
||||||
|
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
import org.apache.hadoop.hbase.testclassification.MediumTests;
|
||||||
|
@ -136,30 +137,53 @@ public class TestSnapshotDescriptionUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsWithinWorkingDir() {
|
public void testIsWithinWorkingDir() throws IOException {
|
||||||
Configuration conf = new Configuration();
|
Configuration conf = new Configuration();
|
||||||
conf.set(HConstants.HBASE_DIR, "hdfs://root/");
|
conf.set(HConstants.HBASE_DIR, "hdfs://localhost/root/");
|
||||||
|
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("hdfs://root/"), conf));
|
new Path("hdfs://localhost/root/"), conf));
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("hdfs://root/.hbase-snapshotdir"), conf));
|
new Path("hdfs://localhost/root/.hbase-snapshotdir"), conf));
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("hdfs://root/.hbase-snapshot"), conf));
|
new Path("hdfs://localhost/root/.hbase-snapshot"), conf));
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("hdfs://.hbase-snapshot"), conf));
|
new Path("hdfs://localhost/.hbase-snapshot"), conf));
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("hdfs://.hbase-snapshot/.tmp"), conf));
|
new Path("hdfs://localhost/.hbase-snapshot/.tmp"), conf));
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("hdfs://root"), conf));
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("hdfs://localhost/root"), conf));
|
||||||
assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("hdfs://root/.hbase-snapshot/.tmp"), conf));
|
new Path("hdfs://localhost/root/.hbase-snapshot/.tmp"), conf));
|
||||||
assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("hdfs://root/.hbase-snapshot/.tmp/snapshot"), conf));
|
new Path("hdfs://localhost/root/.hbase-snapshot/.tmp/snapshot"), conf));
|
||||||
|
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("s3://root/.hbase-snapshot/"), conf));
|
new Path("s3://localhost/root/.hbase-snapshot/"), conf));
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("s3://root"), conf));
|
|
||||||
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
new Path("s3://root/.hbase-snapshot/.tmp/snapshot"), conf));
|
new Path("s3://localhost/root"), conf));
|
||||||
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("s3://localhost/root/.hbase-snapshot/.tmp/snapshot"), conf));
|
||||||
|
|
||||||
|
// for local mode
|
||||||
|
conf = HBaseConfiguration.create();
|
||||||
|
String hbsaeDir = conf.get(HConstants.HBASE_DIR);
|
||||||
|
|
||||||
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:" + hbsaeDir + "/"), conf));
|
||||||
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:" + hbsaeDir + "/.hbase-snapshotdir"), conf));
|
||||||
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:" + hbsaeDir + "/.hbase-snapshot"), conf));
|
||||||
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:/.hbase-snapshot"), conf));
|
||||||
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:/.hbase-snapshot/.tmp"), conf));
|
||||||
|
assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:" + hbsaeDir), conf));
|
||||||
|
assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:" + hbsaeDir + "/.hbase-snapshot/.tmp"), conf));
|
||||||
|
assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
|
||||||
|
new Path("file:" + hbsaeDir + "/.hbase-snapshot/.tmp/snapshot"), conf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue