-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-23622 Reduced the number of Checkstyle violations in hbase-common #1034
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,8 +137,7 @@ public static boolean isMatchingTail(final Path pathToSearch, final Path pathTai | |
| * @return True if deleted <code>dir</code> | ||
| * @throws IOException e | ||
| */ | ||
| public static boolean deleteDirectory(final FileSystem fs, final Path dir) | ||
| throws IOException { | ||
| public static boolean deleteDirectory(final FileSystem fs, final Path dir) throws IOException { | ||
| return fs.exists(dir) && fs.delete(dir, true); | ||
| } | ||
|
|
||
|
|
@@ -157,7 +156,7 @@ public static long getDefaultBlockSize(final FileSystem fs, final Path path) thr | |
| Method m = null; | ||
| Class<? extends FileSystem> cls = fs.getClass(); | ||
| try { | ||
| m = cls.getMethod("getDefaultBlockSize", new Class<?>[] { Path.class }); | ||
| m = cls.getMethod("getDefaultBlockSize", Path.class); | ||
|
busbey marked this conversation as resolved.
Outdated
|
||
| } catch (NoSuchMethodException e) { | ||
| LOG.info("FileSystem doesn't support getDefaultBlockSize"); | ||
| } catch (SecurityException e) { | ||
|
|
@@ -192,7 +191,7 @@ public static short getDefaultReplication(final FileSystem fs, final Path path) | |
| Method m = null; | ||
| Class<? extends FileSystem> cls = fs.getClass(); | ||
| try { | ||
| m = cls.getMethod("getDefaultReplication", new Class<?>[] { Path.class }); | ||
| m = cls.getMethod("getDefaultReplication", Path.class); | ||
|
busbey marked this conversation as resolved.
Outdated
|
||
| } catch (NoSuchMethodException e) { | ||
| LOG.info("FileSystem doesn't support getDefaultReplication"); | ||
| } catch (SecurityException e) { | ||
|
|
@@ -358,11 +357,11 @@ public static Path getRootDir(final Configuration c) throws IOException { | |
| return p.makeQualified(fs); | ||
| } | ||
|
|
||
| public static void setRootDir(final Configuration c, final Path root) throws IOException { | ||
| public static void setRootDir(final Configuration c, final Path root) { | ||
| c.set(HConstants.HBASE_DIR, root.toString()); | ||
| } | ||
|
|
||
| public static void setFsDefault(final Configuration c, final Path root) throws IOException { | ||
| public static void setFsDefault(final Configuration c, final Path root) { | ||
| c.set("fs.defaultFS", root.toString()); // for hadoop 0.21+ | ||
| } | ||
|
|
||
|
|
@@ -387,7 +386,7 @@ public static Path getWALRootDir(final Configuration c) throws IOException { | |
| } | ||
|
|
||
| @VisibleForTesting | ||
| public static void setWALRootDir(final Configuration c, final Path root) throws IOException { | ||
| public static void setWALRootDir(final Configuration c, final Path root) { | ||
| c.set(HBASE_WAL_DIR, root.toString()); | ||
| } | ||
|
|
||
|
|
@@ -481,8 +480,7 @@ public static void setStoragePolicy(final FileSystem fs, final Configuration con | |
| setStoragePolicy(fs, path, storagePolicy); | ||
| } | ||
|
|
||
| private static final Map<FileSystem, Boolean> warningMap = | ||
| new ConcurrentHashMap<FileSystem, Boolean>(); | ||
| private static final Map<FileSystem, Boolean> warningMap = new ConcurrentHashMap<>(); | ||
|
|
||
| /** | ||
| * Sets storage policy for given path. | ||
|
|
@@ -560,8 +558,7 @@ private static void invokeSetStoragePolicy(final FileSystem fs, final Path path, | |
| Method m = null; | ||
| Exception toThrow = null; | ||
| try { | ||
| m = fs.getClass().getDeclaredMethod("setStoragePolicy", | ||
| new Class<?>[] { Path.class, String.class }); | ||
| m = fs.getClass().getDeclaredMethod("setStoragePolicy", Path.class, String.class); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. branch-1's minimum hadoop version is 2.8.5, so for that branch we can remove this reflection as well. Note to potential further backporters: the method is not in Hadoop 2.7, we'll need this reflection in branch-1.4 and branch-1.3.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the reflection part. Will create additional backports for branch-1.4 and branch-1.3. |
||
| m.setAccessible(true); | ||
| } catch (NoSuchMethodException e) { | ||
| toThrow = e; | ||
|
|
@@ -621,7 +618,6 @@ private static void invokeSetStoragePolicy(final FileSystem fs, final Path path, | |
| } | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * @param conf must not be null | ||
| * @return True if this filesystem whose scheme is 'hdfs'. | ||
|
|
@@ -647,8 +643,7 @@ public static boolean isRecoveredEdits(Path path) { | |
| * @return Returns the filesystem of the hbase rootdir. | ||
| * @throws IOException from underlying FileSystem | ||
| */ | ||
| public static FileSystem getCurrentFileSystem(Configuration conf) | ||
| throws IOException { | ||
| public static FileSystem getCurrentFileSystem(Configuration conf) throws IOException { | ||
| return getRootDir(conf).getFileSystem(conf); | ||
| } | ||
|
|
||
|
|
@@ -666,7 +661,7 @@ public static FileSystem getCurrentFileSystem(Configuration conf) | |
| * @param filter path filter | ||
| * @return null if dir is empty or doesn't exist, otherwise FileStatus array | ||
| */ | ||
| public static FileStatus [] listStatus(final FileSystem fs, | ||
| public static FileStatus[] listStatus(final FileSystem fs, | ||
| final Path dir, final PathFilter filter) throws IOException { | ||
| FileStatus [] status = null; | ||
| try { | ||
|
|
@@ -753,21 +748,21 @@ public static boolean isExists(final FileSystem fs, final Path path) throws IOEx | |
| * Log the current state of the filesystem from a certain root directory | ||
| * @param fs filesystem to investigate | ||
| * @param root root file/directory to start logging from | ||
| * @param LOG log to output information | ||
| * @param log log to output information | ||
| * @throws IOException if an unexpected exception occurs | ||
| */ | ||
| public static void logFileSystemState(final FileSystem fs, final Path root, Log LOG) | ||
| public static void logFileSystemState(final FileSystem fs, final Path root, Log log) | ||
| throws IOException { | ||
| LOG.debug("Current file system:"); | ||
| logFSTree(LOG, fs, root, "|-"); | ||
| log.debug("Current file system:"); | ||
| logFSTree(log, fs, root, "|-"); | ||
| } | ||
|
|
||
| /** | ||
| * Recursive helper to log the state of the FS | ||
| * | ||
| * @see #logFileSystemState(FileSystem, Path, Log) | ||
| */ | ||
| private static void logFSTree(Log LOG, final FileSystem fs, final Path root, String prefix) | ||
| private static void logFSTree(Log log, final FileSystem fs, final Path root, String prefix) | ||
| throws IOException { | ||
| FileStatus[] files = listStatus(fs, root, null); | ||
| if (files == null) { | ||
|
|
@@ -776,10 +771,10 @@ private static void logFSTree(Log LOG, final FileSystem fs, final Path root, Str | |
|
|
||
| for (FileStatus file : files) { | ||
| if (file.isDirectory()) { | ||
| LOG.debug(prefix + file.getPath().getName() + "/"); | ||
| logFSTree(LOG, fs, file.getPath(), prefix + "---"); | ||
| log.debug(prefix + file.getPath().getName() + "/"); | ||
| logFSTree(log, fs, file.getPath(), prefix + "---"); | ||
| } else { | ||
| LOG.debug(prefix + file.getPath().getName()); | ||
| log.debug(prefix + file.getPath().getName()); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -791,25 +786,6 @@ public static boolean renameAndSetModifyTime(final FileSystem fs, final Path src | |
| return fs.rename(src, dest); | ||
| } | ||
|
|
||
| /** | ||
| * Do our short circuit read setup. | ||
| * Checks buffer size to use and whether to do checksumming in hbase or hdfs. | ||
| * @param conf must not be null | ||
| */ | ||
| public static void setupShortCircuitRead(final Configuration conf) { | ||
| // Check that the user has not set the "dfs.client.read.shortcircuit.skip.checksum" property. | ||
| boolean shortCircuitSkipChecksum = | ||
| conf.getBoolean("dfs.client.read.shortcircuit.skip.checksum", false); | ||
| boolean useHBaseChecksum = conf.getBoolean(HConstants.HBASE_CHECKSUM_VERIFICATION, true); | ||
| if (shortCircuitSkipChecksum) { | ||
| LOG.warn("Configuration \"dfs.client.read.shortcircuit.skip.checksum\" should not " + | ||
| "be set to true." + (useHBaseChecksum ? " HBase checksum doesn't require " + | ||
| "it, see https://issues.apache.org/jira/browse/HBASE-6868." : "")); | ||
| assert !shortCircuitSkipChecksum; //this will fail if assertions are on | ||
| } | ||
| checkShortCircuitReadBufferSize(conf); | ||
| } | ||
|
|
||
| /** | ||
| * Check if short circuit read buffer size is set and if not, set it to hbase value. | ||
| * @param conf must not be null | ||
|
|
@@ -912,5 +888,4 @@ public StreamLacksCapabilityException(String message) { | |
| super(message); | ||
| } | ||
| } | ||
|
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.