HDFS-9413. getContentSummary() on standby should throw StandbyException. (Brahma Reddy Battula via mingma)
(cherry picked from commit 02653add98
)
This commit is contained in:
parent
1d107d8058
commit
42b55ff23e
|
@ -1450,6 +1450,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-9410. Some tests should always reset sysout and syserr.
|
HDFS-9410. Some tests should always reset sysout and syserr.
|
||||||
(Xiao Chen via waltersu4549)
|
(Xiao Chen via waltersu4549)
|
||||||
|
|
||||||
|
HDFS-9413. getContentSummary() on standby should throw StandbyException.
|
||||||
|
(Brahma Reddy Battula via mingma)
|
||||||
|
|
||||||
Release 2.7.3 - UNRELEASED
|
Release 2.7.3 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -2914,9 +2914,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
* or null if file not found
|
* or null if file not found
|
||||||
*/
|
*/
|
||||||
ContentSummary getContentSummary(final String src) throws IOException {
|
ContentSummary getContentSummary(final String src) throws IOException {
|
||||||
|
checkOperation(OperationCategory.READ);
|
||||||
readLock();
|
readLock();
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
try {
|
try {
|
||||||
|
checkOperation(OperationCategory.READ);
|
||||||
return FSDirStatAndListingOp.getContentSummary(dir, src);
|
return FSDirStatAndListingOp.getContentSummary(dir, src);
|
||||||
} catch (AccessControlException ace) {
|
} catch (AccessControlException ace) {
|
||||||
success = false;
|
success = false;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hdfs.server.namenode.ha;
|
package org.apache.hadoop.hdfs.server.namenode.ha;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -34,6 +35,7 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;
|
||||||
import org.apache.hadoop.hdfs.MiniDFSNNTopology;
|
import org.apache.hadoop.hdfs.MiniDFSNNTopology;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
import org.apache.hadoop.io.IOUtils;
|
import org.apache.hadoop.io.IOUtils;
|
||||||
|
import org.apache.hadoop.ipc.StandbyException;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -130,4 +132,17 @@ public class TestQuotasWithHA {
|
||||||
assertEquals(1, cs.getDirectoryCount());
|
assertEquals(1, cs.getDirectoryCount());
|
||||||
assertEquals(0, cs.getFileCount());
|
assertEquals(0, cs.getFileCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that getContentSummary on Standby should should throw standby
|
||||||
|
* exception.
|
||||||
|
*/
|
||||||
|
@Test(expected = StandbyException.class)
|
||||||
|
public void testgetContentSummaryOnStandby() throws Exception {
|
||||||
|
Configuration nn1conf =cluster.getConfiguration(1);
|
||||||
|
// just reset the standby reads to default i.e False on standby.
|
||||||
|
HAUtil.setAllowStandbyReads(nn1conf, false);
|
||||||
|
cluster.restartNameNode(1);
|
||||||
|
cluster.getNameNodeRpc(1).getContentSummary("/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue