HDFS-8879. Quota by storage type usage incorrectly initialized upon namenode restart. Contributed by Xiaoyu Yao.

(cherry picked from commit 3e715a4f4c)
This commit is contained in:
Kihwal Lee 2015-08-28 13:27:17 -05:00
parent ba0f66984c
commit 42aa880df3
3 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,8 @@
Hadoop HDFS Change Log
HDFS-8879. Quota by storage type usage incorrectly initialized upon namenode
restart. (xyao)
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -909,11 +909,9 @@ public class FSImage implements Closeable {
+ " quota = " + ssQuota + " < consumed = " + ssConsumed);
}
final EnumCounters<StorageType> typeSpaces =
new EnumCounters<StorageType>(StorageType.class);
final EnumCounters<StorageType> typeSpaces = counts.getTypeSpaces();
for (StorageType t : StorageType.getTypesSupportingQuota()) {
final long typeSpace = counts.getTypeSpaces().get(t) -
parentTypeSpaces.get(t);
final long typeSpace = typeSpaces.get(t) - parentTypeSpaces.get(t);
final long typeQuota = q.getTypeSpaces().get(t);
if (Quota.isViolated(typeQuota, typeSpace)) {
LOG.warn("Storage type quota violation in image for "

View File

@ -68,10 +68,7 @@ public class TestQuotaByStorageType {
.storageTypes(new StorageType[]{StorageType.SSD, StorageType.DEFAULT})
.build();
cluster.waitActive();
fsdir = cluster.getNamesystem().getFSDirectory();
dfs = cluster.getFileSystem();
fsn = cluster.getNamesystem();
refreshClusterState();
}
@After
@ -81,6 +78,13 @@ public class TestQuotaByStorageType {
}
}
// Cluster state must be refreshed after each start/restart in the test
private void refreshClusterState() throws IOException{
fsdir = cluster.getNamesystem().getFSDirectory();
dfs = cluster.getFileSystem();
fsn = cluster.getNamesystem();
}
@Test(timeout = 60000)
public void testQuotaByStorageTypeWithFileCreateOneSSD() throws Exception {
testQuotaByStorageTypeWithFileCreateCase(
@ -663,6 +667,7 @@ public class TestQuotaByStorageType {
// Restart namenode to make sure the editlog is correct
cluster.restartNameNode(true);
refreshClusterState();
INode testDirNodeAfterNNRestart = fsdir.getINode4Write(testDir.toString());
// Verify quota is still set
@ -715,6 +720,7 @@ public class TestQuotaByStorageType {
dfs.saveNamespace();
dfs.setSafeMode(HdfsConstants.SafeModeAction.SAFEMODE_LEAVE);
cluster.restartNameNode(true);
refreshClusterState();
INode testDirNodeAfterNNRestart = fsdir.getINode4Write(testDir.toString());
assertTrue(testDirNode.isDirectory());