/** * Get the storage policy of the source path (directory/file). * @param path The source path (directory/file). * @return Storage policy name, or {@code null} if not using {@link DistributedFileSystem} or * exception thrown when trying to get policy */ @Nullable public String getStoragePolicyName(Path path) { try { Object blockStoragePolicySpi = ReflectionUtils.invokeMethod(this.fs, "getStoragePolicy", path); return (String) ReflectionUtils.invokeMethod(blockStoragePolicySpi, "getName"); } catch (Exception e) { // Maybe fail because of using old HDFS version, try the old way if (LOG.isTraceEnabled()) { LOG.trace("Failed to get policy directly", e); } return getStoragePolicyForOldHDFSVersion(path); } }
private String getStoragePolicyName(FileSystem fs, Path path) { try { Object blockStoragePolicySpi = ReflectionUtils.invokeMethod(fs, "getStoragePolicy", path); return (String) ReflectionUtils.invokeMethod(blockStoragePolicySpi, "getName"); } catch (Exception e) { // Maybe fail because of using old HDFS version, try the old way if (LOG.isTraceEnabled()) { LOG.trace("Failed to get policy directly", e); } String policy = getStoragePolicyNameForOldHDFSVersion(fs, path); return policy == null ? "HOT" : policy;// HOT by default } }
private String getStoragePolicyName(FileSystem fs, Path path) { try { Object blockStoragePolicySpi = ReflectionUtils.invokeMethod(fs, "getStoragePolicy", path); return (String) ReflectionUtils.invokeMethod(blockStoragePolicySpi, "getName"); } catch (Exception e) { // Maybe fail because of using old HDFS version, try the old way if (LOG.isTraceEnabled()) { LOG.trace("Failed to get policy directly", e); } String policy = getStoragePolicyNameForOldHDFSVersion(fs, path); return policy == null ? "HOT" : policy;// HOT by default } }
private String getStoragePolicyName(FileSystem fs, Path path) { try { Object blockStoragePolicySpi = ReflectionUtils.invokeMethod(fs, "getStoragePolicy", path); return (String) ReflectionUtils.invokeMethod(blockStoragePolicySpi, "getName"); } catch (Exception e) { // Maybe fail because of using old HDFS version, try the old way if (LOG.isTraceEnabled()) { LOG.trace("Failed to get policy directly", e); } String policy = getStoragePolicyNameForOldHDFSVersion(fs, path); return policy == null ? "HOT" : policy;// HOT by default } }
private String getStoragePolicyName(FileSystem fs, Path path) { try { Object blockStoragePolicySpi = ReflectionUtils.invokeMethod(fs, "getStoragePolicy", path); return (String) ReflectionUtils.invokeMethod(blockStoragePolicySpi, "getName"); } catch (Exception e) { // Maybe fail because of using old HDFS version, try the old way if (LOG.isTraceEnabled()) { LOG.trace("Failed to get policy directly", e); } String policy = getStoragePolicyNameForOldHDFSVersion(fs, path); return policy == null ? "HOT" : policy;// HOT by default } }
private String getStoragePolicyName(FileSystem fs, Path path) { try { Object blockStoragePolicySpi = ReflectionUtils.invokeMethod(fs, "getStoragePolicy", path); return (String) ReflectionUtils.invokeMethod(blockStoragePolicySpi, "getName"); } catch (Exception e) { // Maybe fail because of using old HDFS version, try the old way if (LOG.isTraceEnabled()) { LOG.trace("Failed to get policy directly", e); } String policy = getStoragePolicyNameForOldHDFSVersion(fs, path); return policy == null ? "HOT" : policy;// HOT by default } }