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
This commit is contained in:
Brandon Li 2013-09-25 21:59:35 +00:00
parent 464470e715
commit 3582026204
7 changed files with 70 additions and 3 deletions

View File

@ -1226,4 +1226,19 @@
</description> </description>
</property> </property>
<property>
<name>nfs3.server.port</name>
<value>2049</value>
<description>
Specify the port number used by Hadoop NFS.
</description>
</property>
<property>
<name>nfs3.mountd.port</name>
<value>4242</value>
<description>
Specify the port number used by Hadoop mount daemon.
</description>
</property>
</configuration> </configuration>

View File

@ -69,4 +69,13 @@
<value>simple</value> <value>simple</value>
</property> </property>
<property>
<name>nfs3.server.port</name>
<value>2079</value>
</property>
<property>
<name>nfs3.mountd.port</name>
<value>4272</value>
</property>
</configuration> </configuration>

View File

@ -19,6 +19,7 @@
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mount.MountdBase; import org.apache.hadoop.mount.MountdBase;
import org.apache.hadoop.oncrpc.RpcProgram; import org.apache.hadoop.oncrpc.RpcProgram;
import org.apache.hadoop.oncrpc.RpcUtil; import org.apache.hadoop.oncrpc.RpcUtil;
@ -38,6 +39,7 @@ public abstract class Nfs3Base {
public static final Log LOG = LogFactory.getLog(Nfs3Base.class); public static final Log LOG = LogFactory.getLog(Nfs3Base.class);
private final MountdBase mountd; private final MountdBase mountd;
private final RpcProgram rpcProgram; private final RpcProgram rpcProgram;
private final int nfsPort;
public MountdBase getMountBase() { public MountdBase getMountBase() {
return mountd; return mountd;
@ -47,9 +49,17 @@ public RpcProgram getRpcProgram() {
return rpcProgram; 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) { protected Nfs3Base(MountdBase mountd, RpcProgram program) {
this.mountd = mountd; this.mountd = mountd;
this.rpcProgram = program; this.rpcProgram = program;
this.nfsPort = Nfs3Constant.PORT;
} }
public void start(boolean register) { public void start(boolean register) {
@ -61,7 +71,7 @@ public void start(boolean register) {
} }
private void startTCPServer() { private void startTCPServer() {
SimpleTcpServer tcpServer = new SimpleTcpServer(Nfs3Constant.PORT, SimpleTcpServer tcpServer = new SimpleTcpServer(nfsPort,
rpcProgram, 0) { rpcProgram, 0) {
@Override @Override
public ChannelPipelineFactory getPipelineFactory() { public ChannelPipelineFactory getPipelineFactory() {

View File

@ -76,7 +76,8 @@ public RpcProgramMountd(List<String> exports) throws IOException {
public RpcProgramMountd(List<String> exports, Configuration config) public RpcProgramMountd(List<String> exports, Configuration config)
throws IOException { throws IOException {
// Note that RPC cache is not enabled // 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.hostsMatcher = NfsExports.getInstance(config);
this.mounts = Collections.synchronizedList(new ArrayList<MountEntry>()); this.mounts = Collections.synchronizedList(new ArrayList<MountEntry>());

View File

@ -42,7 +42,7 @@ public Nfs3(List<String> exports) throws IOException {
} }
public Nfs3(List<String> exports, Configuration config) throws IOException { public Nfs3(List<String> 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 { public static void main(String[] args) throws IOException {

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>nfs3.server.port</name>
<value>2079</value>
</property>
<property>
<name>nfs3.mountd.port</name>
<value>4272</value>
</property>
</configuration>

View File

@ -335,6 +335,9 @@ Release 2.1.2 - UNRELEASED
OPTIMIZATIONS OPTIMIZATIONS
HDFS-5246. Make Hadoop nfs server port and mount daemon port
configurable. (Jinghui Wang via brandonli)
BUG FIXES BUG FIXES
HDFS-5139. Remove redundant -R option from setrep. HDFS-5139. Remove redundant -R option from setrep.