|
@@ -28,6 +28,8 @@ import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
|
|
import org.apache.hadoop.hdfs.tools.DFSAdmin;
|
|
|
import org.apache.hadoop.io.IOUtils;
|
|
|
import org.apache.hadoop.security.UnixUserGroupInformation;
|
|
|
+import org.apache.hadoop.hdfs.protocol.NSQuotaExceededException;
|
|
|
+import org.apache.hadoop.hdfs.protocol.DSQuotaExceededException;
|
|
|
|
|
|
import junit.framework.TestCase;
|
|
|
|
|
@@ -112,7 +114,7 @@ public class TestQuota extends TestCase {
|
|
|
boolean hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.mkdirs(childDir1));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -124,7 +126,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
fout = dfs.create(childFile1);
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -148,7 +150,7 @@ public class TestQuota extends TestCase {
|
|
|
try {
|
|
|
fout.write(new byte[fileLen]);
|
|
|
fout.close();
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (DSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
IOUtils.closeStream(fout);
|
|
|
}
|
|
@@ -167,9 +169,10 @@ public class TestQuota extends TestCase {
|
|
|
DFSTestUtil.createFile(dfs, childFile1, fileLen, replication, 0);
|
|
|
|
|
|
// 11: set the quota of /test to be 1
|
|
|
+ // HADOOP-5872 - we can set quota even if it is immediately violated
|
|
|
args = new String[]{"-setQuota", "1", parent.toString()};
|
|
|
- runCommand(admin, args, true);
|
|
|
- runCommand(admin, true, "-setSpaceQuota", // for space quota
|
|
|
+ runCommand(admin, args, false);
|
|
|
+ runCommand(admin, false, "-setSpaceQuota", // for space quota
|
|
|
Integer.toString(fileLen), args[2]);
|
|
|
|
|
|
// 12: set the quota of /test/data0 to be 1
|
|
@@ -180,7 +183,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.mkdirs(new Path(childDir0, "in")));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -303,7 +306,7 @@ public class TestQuota extends TestCase {
|
|
|
boolean hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.mkdirs(tempPath));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -326,7 +329,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.mkdirs(tempPath));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -345,7 +348,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.rename(tempPath, quotaDir3));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -356,7 +359,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.rename(tempPath, new Path(quotaDir3, "nqdir32")));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -379,7 +382,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.rename(new Path("/nqdir0/nqdir30"), tempPath));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (NSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -480,7 +483,7 @@ public class TestQuota extends TestCase {
|
|
|
try {
|
|
|
DFSTestUtil.createFile(dfs, new Path(quotaDir21, "nqdir33/file2"),
|
|
|
2*fileLen, replication, 0);
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (DSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -523,7 +526,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
assertFalse(dfs.rename(dstPath, srcPath));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (DSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|
|
@@ -569,7 +572,7 @@ public class TestQuota extends TestCase {
|
|
|
out.write(new byte[fileLen + 1024]);
|
|
|
out.flush();
|
|
|
out.close();
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (DSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
IOUtils.closeStream(out);
|
|
|
}
|
|
@@ -594,7 +597,7 @@ public class TestQuota extends TestCase {
|
|
|
hasException = false;
|
|
|
try {
|
|
|
dfs.setReplication(file2, (short)(replication+1));
|
|
|
- } catch (QuotaExceededException e) {
|
|
|
+ } catch (DSQuotaExceededException e) {
|
|
|
hasException = true;
|
|
|
}
|
|
|
assertTrue(hasException);
|