/** * @param conf must not be null * @return Returns the filesystem of the hbase rootdir. * @throws IOException from underlying FileSystem */ public static FileSystem getCurrentFileSystem(Configuration conf) throws IOException { return getRootDir(conf).getFileSystem(conf); }
public static FileSystem getRootDirFileSystem(final Configuration c) throws IOException { Path p = getRootDir(c); return p.getFileSystem(c); }
private static boolean isValidWALRootDir(Path walDir, final Configuration c) throws IOException { Path rootDir = getRootDir(c); FileSystem fs = walDir.getFileSystem(c); Path qualifiedWalDir = walDir.makeQualified(fs.getUri(), fs.getWorkingDirectory()); if (!qualifiedWalDir.equals(rootDir)) { if (qualifiedWalDir.toString().startsWith(rootDir.toString() + "/")) { throw new IllegalStateException("Illegal WAL directory specified. " + "WAL directories are not permitted to be under the root directory if set."); } } return true; }
/** * @param c configuration * @return {@link Path} to hbase log root directory: e.g. {@value HBASE_WAL_DIR} from * configuration as a qualified Path. Defaults to HBase root dir. * @throws IOException e */ public static Path getWALRootDir(final Configuration c) throws IOException { Path p = new Path(c.get(HBASE_WAL_DIR, c.get(HConstants.HBASE_DIR))); if (!isValidWALRootDir(p, c)) { return getRootDir(c); } FileSystem fs = p.getFileSystem(c); return p.makeQualified(fs.getUri(), fs.getWorkingDirectory()); }
@Test public void testRemoveWALRootPath() throws Exception { CommonFSUtils.setRootDir(conf, new Path("file:///user/hbase")); Path testFile = new Path(CommonFSUtils.getRootDir(conf), "test/testfile"); Path tmpFile = new Path("file:///test/testfile"); assertEquals("test/testfile", CommonFSUtils.removeWALRootPath(testFile, conf)); assertEquals(tmpFile.toString(), CommonFSUtils.removeWALRootPath(tmpFile, conf)); CommonFSUtils.setWALRootDir(conf, new Path("file:///user/hbaseLogDir")); assertEquals(testFile.toString(), CommonFSUtils.removeWALRootPath(testFile, conf)); Path logFile = new Path(CommonFSUtils.getWALRootDir(conf), "test/testlog"); assertEquals("test/testlog", CommonFSUtils.removeWALRootPath(logFile, conf)); }
@Test public void testGetWALRootDir() throws IOException { Path root = new Path("file:///hbase/root"); Path walRoot = new Path("file:///hbase/logroot"); CommonFSUtils.setRootDir(conf, root); assertEquals(root, CommonFSUtils.getRootDir(conf)); assertEquals(root, CommonFSUtils.getWALRootDir(conf)); CommonFSUtils.setWALRootDir(conf, walRoot); assertEquals(walRoot, CommonFSUtils.getWALRootDir(conf)); }
public static FileSystem getRootDirFileSystem(final Configuration c) throws IOException { Path p = getRootDir(c); return p.getFileSystem(c); }
/** * @param conf must not be null * @return Returns the filesystem of the hbase rootdir. * @throws IOException from underlying FileSystem */ public static FileSystem getCurrentFileSystem(Configuration conf) throws IOException { return getRootDir(conf).getFileSystem(conf); }
/** * @param conf must not be null * @return Returns the filesystem of the hbase rootdir. * @throws IOException from underlying FileSystem */ public static FileSystem getCurrentFileSystem(Configuration conf) throws IOException { return getRootDir(conf).getFileSystem(conf); }
public static FileSystem getRootDirFileSystem(final Configuration c) throws IOException { Path p = getRootDir(c); return p.getFileSystem(c); }
public WALProcedureStore(final Configuration conf, final LeaseRecovery leaseRecovery) throws IOException { this(conf, new Path(CommonFSUtils.getWALRootDir(conf), MASTER_PROCEDURE_LOGDIR), new Path(CommonFSUtils.getRootDir(conf), HConstants.HREGION_OLDLOGDIR_NAME), leaseRecovery); }
private static boolean isValidWALRootDir(Path walDir, final Configuration c) throws IOException { Path rootDir = getRootDir(c); FileSystem fs = walDir.getFileSystem(c); Path qualifiedWalDir = walDir.makeQualified(fs.getUri(), fs.getWorkingDirectory()); if (!qualifiedWalDir.equals(rootDir)) { if (qualifiedWalDir.toString().startsWith(rootDir.toString() + "/")) { throw new IllegalStateException("Illegal WAL directory specified. " + "WAL directories are not permitted to be under the root directory if set."); } } return true; }
private static boolean isValidWALRootDir(Path walDir, final Configuration c) throws IOException { Path rootDir = getRootDir(c); FileSystem fs = walDir.getFileSystem(c); Path qualifiedWalDir = walDir.makeQualified(fs.getUri(), fs.getWorkingDirectory()); if (!qualifiedWalDir.equals(rootDir)) { if (qualifiedWalDir.toString().startsWith(rootDir.toString() + "/")) { throw new IllegalStateException("Illegal WAL directory specified. " + "WAL directories are not permitted to be under the root directory if set."); } } return true; }
/** * @param c configuration * @return {@link Path} to hbase log root directory: e.g. {@value HBASE_WAL_DIR} from * configuration as a qualified Path. Defaults to HBase root dir. * @throws IOException e */ public static Path getWALRootDir(final Configuration c) throws IOException { Path p = new Path(c.get(HBASE_WAL_DIR, c.get(HConstants.HBASE_DIR))); if (!isValidWALRootDir(p, c)) { return getRootDir(c); } FileSystem fs = p.getFileSystem(c); return p.makeQualified(fs.getUri(), fs.getWorkingDirectory()); }
/** * @param c configuration * @return {@link Path} to hbase log root directory: e.g. {@value HBASE_WAL_DIR} from * configuration as a qualified Path. Defaults to HBase root dir. * @throws IOException e */ public static Path getWALRootDir(final Configuration c) throws IOException { Path p = new Path(c.get(HBASE_WAL_DIR, c.get(HConstants.HBASE_DIR))); if (!isValidWALRootDir(p, c)) { return getRootDir(c); } FileSystem fs = p.getFileSystem(c); return p.makeQualified(fs.getUri(), fs.getWorkingDirectory()); }
@Test public void testRemoveWALRootPath() throws Exception { CommonFSUtils.setRootDir(conf, new Path("file:///user/hbase")); Path testFile = new Path(CommonFSUtils.getRootDir(conf), "test/testfile"); Path tmpFile = new Path("file:///test/testfile"); assertEquals("test/testfile", CommonFSUtils.removeWALRootPath(testFile, conf)); assertEquals(tmpFile.toString(), CommonFSUtils.removeWALRootPath(tmpFile, conf)); CommonFSUtils.setWALRootDir(conf, new Path("file:///user/hbaseLogDir")); assertEquals(testFile.toString(), CommonFSUtils.removeWALRootPath(testFile, conf)); Path logFile = new Path(CommonFSUtils.getWALRootDir(conf), "test/testlog"); assertEquals("test/testlog", CommonFSUtils.removeWALRootPath(logFile, conf)); }
@Test public void testRemoveWALRootPath() throws Exception { CommonFSUtils.setRootDir(conf, new Path("file:///user/hbase")); Path testFile = new Path(CommonFSUtils.getRootDir(conf), "test/testfile"); Path tmpFile = new Path("file:///test/testfile"); assertEquals("test/testfile", CommonFSUtils.removeWALRootPath(testFile, conf)); assertEquals(tmpFile.toString(), CommonFSUtils.removeWALRootPath(tmpFile, conf)); CommonFSUtils.setWALRootDir(conf, new Path("file:///user/hbaseLogDir")); assertEquals(testFile.toString(), CommonFSUtils.removeWALRootPath(testFile, conf)); Path logFile = new Path(CommonFSUtils.getWALRootDir(conf), "test/testlog"); assertEquals("test/testlog", CommonFSUtils.removeWALRootPath(logFile, conf)); }
@Test public void testGetWALRootDir() throws IOException { Path root = new Path("file:///hbase/root"); Path walRoot = new Path("file:///hbase/logroot"); CommonFSUtils.setRootDir(conf, root); assertEquals(root, CommonFSUtils.getRootDir(conf)); assertEquals(root, CommonFSUtils.getWALRootDir(conf)); CommonFSUtils.setWALRootDir(conf, walRoot); assertEquals(walRoot, CommonFSUtils.getWALRootDir(conf)); }
@Test public void testGetWALRootDir() throws IOException { Path root = new Path("file:///hbase/root"); Path walRoot = new Path("file:///hbase/logroot"); CommonFSUtils.setRootDir(conf, root); assertEquals(root, CommonFSUtils.getRootDir(conf)); assertEquals(root, CommonFSUtils.getWALRootDir(conf)); CommonFSUtils.setWALRootDir(conf, walRoot); assertEquals(walRoot, CommonFSUtils.getWALRootDir(conf)); }