diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java index 5d0309fa57..cfb538f8f6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/Quota.java @@ -163,7 +163,7 @@ private QuotaUsage aggregateQuota(Map results) { long ssCount = 0; long nsQuota = HdfsConstants.QUOTA_RESET; long ssQuota = HdfsConstants.QUOTA_RESET; - boolean hasQuotaUnSet = false; + boolean hasQuotaUnset = false; for (Map.Entry entry : results.entrySet()) { RemoteLocation loc = entry.getKey(); @@ -172,7 +172,7 @@ private QuotaUsage aggregateQuota(Map results) { // If quota is not set in real FileSystem, the usage // value will return -1. if (usage.getQuota() == -1 && usage.getSpaceQuota() == -1) { - hasQuotaUnSet = true; + hasQuotaUnset = true; } nsQuota = usage.getQuota(); ssQuota = usage.getSpaceQuota(); @@ -189,7 +189,7 @@ private QuotaUsage aggregateQuota(Map results) { QuotaUsage.Builder builder = new QuotaUsage.Builder() .fileAndDirectoryCount(nsCount).spaceConsumed(ssCount); - if (hasQuotaUnSet) { + if (hasQuotaUnset) { builder.quota(HdfsConstants.QUOTA_RESET) .spaceQuota(HdfsConstants.QUOTA_RESET); } else { diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java index c52b765565..13f8f37749 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClientProtocol.java @@ -20,7 +20,7 @@ import static org.apache.hadoop.hdfs.server.federation.router.FederationUtil.updateMountPointStatus; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.crypto.CryptoProtocolVersion; -import org.apache.hadoop.fs.BatchedRemoteIterator; +import org.apache.hadoop.fs.BatchedRemoteIterator.BatchedEntries; import org.apache.hadoop.fs.CacheFlag; import org.apache.hadoop.fs.ContentSummary; import org.apache.hadoop.fs.CreateFlag; @@ -1147,7 +1147,7 @@ public void removeCacheDirective(long id) throws IOException { } @Override - public BatchedRemoteIterator.BatchedEntries listCacheDirectives( + public BatchedEntries listCacheDirectives( long prevId, CacheDirectiveInfo filter) throws IOException { rpcServer.checkOperation(NameNode.OperationCategory.READ, false); return null; @@ -1169,7 +1169,7 @@ public void removeCachePool(String cachePoolName) throws IOException { } @Override - public BatchedRemoteIterator.BatchedEntries listCachePools(String prevKey) + public BatchedEntries listCachePools(String prevKey) throws IOException { rpcServer.checkOperation(NameNode.OperationCategory.READ, false); return null; @@ -1280,7 +1280,7 @@ public EncryptionZone getEZForPath(String src) throws IOException { } @Override - public BatchedRemoteIterator.BatchedEntries listEncryptionZones(long prevId) + public BatchedEntries listEncryptionZones(long prevId) throws IOException { rpcServer.checkOperation(NameNode.OperationCategory.READ, false); return null; @@ -1293,7 +1293,7 @@ public void reencryptEncryptionZone(String zone, HdfsConstants.ReencryptAction a } @Override - public BatchedRemoteIterator.BatchedEntries listReencryptionStatus( + public BatchedEntries listReencryptionStatus( long prevId) throws IOException { rpcServer.checkOperation(NameNode.OperationCategory.READ, false); return null; @@ -1529,15 +1529,17 @@ public ReplicatedBlockStats getReplicatedBlockStats() throws IOException { @Deprecated @Override - public BatchedRemoteIterator.BatchedEntries listOpenFiles(long prevId) + public BatchedEntries listOpenFiles(long prevId) throws IOException { - return listOpenFiles(prevId, EnumSet.of(OpenFilesIterator.OpenFilesType.ALL_OPEN_FILES), + return listOpenFiles(prevId, + EnumSet.of(OpenFilesIterator.OpenFilesType.ALL_OPEN_FILES), OpenFilesIterator.FILTER_PATH_DEFAULT); } @Override - public BatchedRemoteIterator.BatchedEntries listOpenFiles(long prevId, - EnumSet openFilesTypes, String path) throws IOException { + public BatchedEntries listOpenFiles(long prevId, + EnumSet openFilesTypes, String path) + throws IOException { rpcServer.checkOperation(NameNode.OperationCategory.READ, false); return null; } @@ -1669,7 +1671,7 @@ private HdfsFileStatus getFileInfoAll(final List locations, // Get the file info from everybody Map results = rpcClient.invokeConcurrent(locations, method, HdfsFileStatus.class); - int children=0; + int children = 0; // We return the first file HdfsFileStatus dirStatus = null; for (RemoteLocation loc : locations) { diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaManager.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaManager.java index fa2a6e43fa..e818f5accd 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaManager.java @@ -88,7 +88,7 @@ public RouterQuotaUsage getQuotaUsage(String path) { } /** - * Get children paths (can including itself) under specified federation path. + * Get children paths (can include itself) under specified federation path. * @param parentPath Federated path. * @return Set of children paths. */ diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUpdateService.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUpdateService.java index 9bfd705efb..dd21e1a7e6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUpdateService.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUpdateService.java @@ -186,10 +186,8 @@ private List getMountTableEntries() throws IOException { */ private List getQuotaSetMountTables() throws IOException { List mountTables = getMountTableEntries(); - Set stalePaths = new HashSet<>(); - for (String path : this.quotaManager.getAll()) { - stalePaths.add(path); - } + Set allPaths = this.quotaManager.getAll(); + Set stalePaths = new HashSet<>(allPaths); List neededMountTables = new LinkedList<>(); for (MountTable entry : mountTables) { diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java index de9119aed4..7fd845af76 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterQuotaUsage.java @@ -75,9 +75,10 @@ public Builder spaceQuota(long spaceQuota) { * @throws NSQuotaExceededException If the quota is exceeded. */ public void verifyNamespaceQuota() throws NSQuotaExceededException { - if (Quota.isViolated(getQuota(), getFileAndDirectoryCount())) { - throw new NSQuotaExceededException(getQuota(), - getFileAndDirectoryCount()); + long quota = getQuota(); + long fileAndDirectoryCount = getFileAndDirectoryCount(); + if (Quota.isViolated(quota, fileAndDirectoryCount)) { + throw new NSQuotaExceededException(quota, fileAndDirectoryCount); } } @@ -87,25 +88,29 @@ public void verifyNamespaceQuota() throws NSQuotaExceededException { * @throws DSQuotaExceededException If the quota is exceeded. */ public void verifyStoragespaceQuota() throws DSQuotaExceededException { - if (Quota.isViolated(getSpaceQuota(), getSpaceConsumed())) { - throw new DSQuotaExceededException(getSpaceQuota(), getSpaceConsumed()); + long spaceQuota = getSpaceQuota(); + long spaceConsumed = getSpaceConsumed(); + if (Quota.isViolated(spaceQuota, spaceConsumed)) { + throw new DSQuotaExceededException(spaceQuota, spaceConsumed); } } @Override public String toString() { - String nsQuota = String.valueOf(getQuota()); - String nsCount = String.valueOf(getFileAndDirectoryCount()); - if (getQuota() == HdfsConstants.QUOTA_RESET) { - nsQuota = "-"; - nsCount = "-"; + String nsQuota = "-"; + String nsCount = "-"; + long quota = getQuota(); + if (quota != HdfsConstants.QUOTA_RESET) { + nsQuota = String.valueOf(quota); + nsCount = String.valueOf(getFileAndDirectoryCount()); } - String ssQuota = StringUtils.byteDesc(getSpaceQuota()); - String ssCount = StringUtils.byteDesc(getSpaceConsumed()); - if (getSpaceQuota() == HdfsConstants.QUOTA_RESET) { - ssQuota = "-"; - ssCount = "-"; + String ssQuota = "-"; + String ssCount = "-"; + long spaceQuota = getSpaceQuota(); + if (spaceQuota != HdfsConstants.QUOTA_RESET) { + ssQuota = StringUtils.byteDesc(spaceQuota); + ssCount = StringUtils.byteDesc(getSpaceConsumed()); } StringBuilder str = new StringBuilder();