From 35820262045dfc00471e25fe3d352cbcaf8632d1 Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Wed, 25 Sep 2013 21:59:35 +0000 Subject: [PATCH] HDFS-5246. Make Hadoop nfs server port and mount daemon port configurable. Contributed by Jinghui Wang git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1526316 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/resources/core-default.xml | 15 ++++++++++ .../src/test/resources/core-site.xml | 9 ++++++ .../org/apache/hadoop/nfs/nfs3/Nfs3Base.java | 12 +++++++- .../hdfs/nfs/mount/RpcProgramMountd.java | 3 +- .../org/apache/hadoop/hdfs/nfs/nfs3/Nfs3.java | 2 +- .../src/test/resources/core-site.xml | 29 +++++++++++++++++++ hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ 7 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 hadoop-hdfs-project/hadoop-hdfs-nfs/src/test/resources/core-site.xml diff --git a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml index 8b2b0e1f17..41ab1ef9c2 100644 --- a/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml +++ b/hadoop-common-project/hadoop-common/src/main/resources/core-default.xml @@ -1226,4 +1226,19 @@ + + nfs3.server.port + 2049 + + Specify the port number used by Hadoop NFS. + + + + + nfs3.mountd.port + 4242 + + Specify the port number used by Hadoop mount daemon. + + diff --git a/hadoop-common-project/hadoop-common/src/test/resources/core-site.xml b/hadoop-common-project/hadoop-common/src/test/resources/core-site.xml index 158a17e674..6053363829 100644 --- a/hadoop-common-project/hadoop-common/src/test/resources/core-site.xml +++ b/hadoop-common-project/hadoop-common/src/test/resources/core-site.xml @@ -69,4 +69,13 @@ simple + + nfs3.server.port + 2079 + + + + nfs3.mountd.port + 4272 + diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/Nfs3Base.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/Nfs3Base.java index dcd01c023c..66afbb0d76 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/Nfs3Base.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/Nfs3Base.java @@ -19,6 +19,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.mount.MountdBase; import org.apache.hadoop.oncrpc.RpcProgram; import org.apache.hadoop.oncrpc.RpcUtil; @@ -38,6 +39,7 @@ public abstract class Nfs3Base { public static final Log LOG = LogFactory.getLog(Nfs3Base.class); private final MountdBase mountd; private final RpcProgram rpcProgram; + private final int nfsPort; public MountdBase getMountBase() { return mountd; @@ -47,9 +49,17 @@ public RpcProgram getRpcProgram() { return rpcProgram; } + protected Nfs3Base(MountdBase mountd, RpcProgram program, Configuration conf) { + this.mountd = mountd; + this.rpcProgram = program; + this.nfsPort = conf.getInt("nfs3.server.port", Nfs3Constant.PORT); + LOG.info("NFS server port set to: "+nfsPort); + } + protected Nfs3Base(MountdBase mountd, RpcProgram program) { this.mountd = mountd; this.rpcProgram = program; + this.nfsPort = Nfs3Constant.PORT; } public void start(boolean register) { @@ -61,7 +71,7 @@ public void start(boolean register) { } private void startTCPServer() { - SimpleTcpServer tcpServer = new SimpleTcpServer(Nfs3Constant.PORT, + SimpleTcpServer tcpServer = new SimpleTcpServer(nfsPort, rpcProgram, 0) { @Override public ChannelPipelineFactory getPipelineFactory() { diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/mount/RpcProgramMountd.java b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/mount/RpcProgramMountd.java index 8d679ecc73..0c1ada6132 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/mount/RpcProgramMountd.java +++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/mount/RpcProgramMountd.java @@ -76,7 +76,8 @@ public RpcProgramMountd(List exports) throws IOException { public RpcProgramMountd(List exports, Configuration config) throws IOException { // Note that RPC cache is not enabled - super("mountd", "localhost", PORT, PROGRAM, VERSION_1, VERSION_3, 0); + super("mountd", "localhost", config.getInt("nfs3.mountd.port", PORT), + PROGRAM, VERSION_1, VERSION_3, 0); this.hostsMatcher = NfsExports.getInstance(config); this.mounts = Collections.synchronizedList(new ArrayList()); diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/Nfs3.java b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/Nfs3.java index 46bc838aa5..06b9890bf9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/Nfs3.java +++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/Nfs3.java @@ -42,7 +42,7 @@ public Nfs3(List exports) throws IOException { } public Nfs3(List exports, Configuration config) throws IOException { - super(new Mountd(exports, config), new RpcProgramNfs3(config)); + super(new Mountd(exports, config), new RpcProgramNfs3(config), config); } public static void main(String[] args) throws IOException { diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/test/resources/core-site.xml b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/test/resources/core-site.xml new file mode 100644 index 0000000000..19e778be04 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/test/resources/core-site.xml @@ -0,0 +1,29 @@ + + + + + + + + + nfs3.server.port + 2079 + + + + nfs3.mountd.port + 4272 + + diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 0f9d874c83..4db26da535 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -335,6 +335,9 @@ Release 2.1.2 - UNRELEASED OPTIMIZATIONS + HDFS-5246. Make Hadoop nfs server port and mount daemon port + configurable. (Jinghui Wang via brandonli) + BUG FIXES HDFS-5139. Remove redundant -R option from setrep.