Skip to content

Commit 4d96582

Browse files
author
Brandon Li
committed
HDFS-4762,HDFS-4948. Merging change r1499190 from branch-2
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2.1-beta@1499199 13f79535-47bb-0310-9956-ffa450edef68
1 parent 38ee940 commit 4d96582

File tree

30 files changed

+4614
-7
lines changed

30 files changed

+4614
-7
lines changed

hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/mount/MountdBase.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,24 @@ public MountdBase(List<String> exports, RpcProgram program) throws IOException {
5050

5151
/* Start UDP server */
5252
private void startUDPServer() {
53-
rpcProgram.register(PortmapMapping.TRANSPORT_UDP);
5453
SimpleUdpServer udpServer = new SimpleUdpServer(rpcProgram.getPort(),
5554
rpcProgram, 1);
5655
udpServer.run();
5756
}
5857

5958
/* Start TCP server */
6059
private void startTCPServer() {
61-
rpcProgram.register(PortmapMapping.TRANSPORT_TCP);
6260
SimpleTcpServer tcpServer = new SimpleTcpServer(rpcProgram.getPort(),
6361
rpcProgram, 1);
6462
tcpServer.run();
6563
}
6664

67-
public void start() {
65+
public void start(boolean register) {
6866
startUDPServer();
6967
startTCPServer();
68+
if (register) {
69+
rpcProgram.register(PortmapMapping.TRANSPORT_UDP);
70+
rpcProgram.register(PortmapMapping.TRANSPORT_TCP);
71+
}
7072
}
7173
}

hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/Nfs3Base.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ protected Nfs3Base(MountdBase mountd, RpcProgram program) {
5252
this.rpcProgram = program;
5353
}
5454

55-
public void start() {
56-
mountd.start(); // Start mountd
57-
rpcProgram.register(PortmapMapping.TRANSPORT_TCP);
58-
startTCPServer(); // Start TCP server
55+
public void start(boolean register) {
56+
mountd.start(register); // Start mountd
57+
startTCPServer(); // Start TCP server
58+
if (register) {
59+
rpcProgram.register(PortmapMapping.TRANSPORT_TCP);
60+
}
5961
}
6062

6163
private void startTCPServer() {

hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/Nfs3FileAttributes.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,22 @@ public Nfs3FileAttributes(boolean isDir, int nlink, short mode, int uid,
9696
this.ctime = this.mtime;
9797
}
9898

99+
public Nfs3FileAttributes(Nfs3FileAttributes other) {
100+
this.type = other.getType();
101+
this.mode = other.getMode();
102+
this.nlink = other.getNlink();
103+
this.uid = other.getUid();
104+
this.gid = other.getGid();
105+
this.size = other.getSize();
106+
this.used = other.getUsed();
107+
this.rdev = new Specdata3();
108+
this.fsid = other.getFsid();
109+
this.fileid = other.getFileid();
110+
this.mtime = new NfsTime(other.getMtime());
111+
this.atime = new NfsTime(other.getAtime());
112+
this.ctime = new NfsTime(other.getCtime());
113+
}
114+
99115
public void serialize(XDR xdr) {
100116
xdr.writeInt(type);
101117
xdr.writeInt(mode);

hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/response/READDIR3Response.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public static class DirList3 {
6161

6262
public DirList3(Entry3[] entries, boolean eof) {
6363
this.entries = ObjectArrays.newArray(entries, entries.length);
64+
System.arraycopy(this.entries, 0, entries, 0, entries.length);
6465
this.eof = eof;
6566
}
6667
}

hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/response/READDIRPLUS3Response.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static class DirListPlus3 {
6565

6666
public DirListPlus3(EntryPlus3[] entries, boolean eof) {
6767
this.entries = ObjectArrays.newArray(entries, entries.length);
68+
System.arraycopy(this.entries, 0, entries, 0, entries.length);
6869
this.eof = eof;
6970
}
7071

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-----------------------------------------------------------------------------
2+
HDFS-NFS - NFS implementation for Hadoop HDFS
3+
4+
-----------------------------------------------------------------------------
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<FindBugsFilter>
18+
</FindBugsFilter>
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. See accompanying LICENSE file.
14+
-->
15+
<project xmlns="http://maven.apache.org/POM/4.0.0"
16+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
17+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
18+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.apache.hadoop</groupId>
22+
<artifactId>hadoop-project-dist</artifactId>
23+
<version>3.0.0-SNAPSHOT</version>
24+
<relativePath>../../hadoop-project-dist</relativePath>
25+
</parent>
26+
<groupId>org.apache.hadoop</groupId>
27+
<artifactId>hadoop-hdfs-nfs</artifactId>
28+
<version>3.0.0-SNAPSHOT</version>
29+
<description>Apache Hadoop HDFS-NFS</description>
30+
<name>Apache Hadoop HDFS-NFS</name>
31+
<packaging>jar</packaging>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.apache.hadoop</groupId>
36+
<artifactId>hadoop-annotations</artifactId>
37+
<scope>provided</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.apache.hadoop</groupId>
41+
<artifactId>hadoop-auth</artifactId>
42+
<scope>provided</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.apache.hadoop</groupId>
46+
<artifactId>hadoop-nfs</artifactId>
47+
<scope>provided</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.netty</groupId>
51+
<artifactId>netty</artifactId>
52+
<version>3.6.2.Final</version>
53+
<scope>compile</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.apache.hadoop</groupId>
57+
<artifactId>hadoop-hdfs</artifactId>
58+
<scope>compile</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.hadoop</groupId>
62+
<artifactId>hadoop-hdfs</artifactId>
63+
<scope>test</scope>
64+
<type>test-jar</type>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.apache.hadoop</groupId>
68+
<artifactId>hadoop-common</artifactId>
69+
<scope>provided</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.apache.hadoop</groupId>
73+
<artifactId>hadoop-common</artifactId>
74+
<scope>test</scope>
75+
<type>test-jar</type>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.apache.zookeeper</groupId>
79+
<artifactId>zookeeper</artifactId>
80+
<version>3.4.2</version>
81+
<type>test-jar</type>
82+
<scope>test</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>com.google.guava</groupId>
86+
<artifactId>guava</artifactId>
87+
<scope>compile</scope>
88+
</dependency>
89+
<dependency>
90+
<groupId>org.mortbay.jetty</groupId>
91+
<artifactId>jetty</artifactId>
92+
<scope>compile</scope>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.mortbay.jetty</groupId>
96+
<artifactId>jetty-util</artifactId>
97+
<scope>compile</scope>
98+
</dependency>
99+
<dependency>
100+
<groupId>com.sun.jersey</groupId>
101+
<artifactId>jersey-core</artifactId>
102+
<scope>compile</scope>
103+
</dependency>
104+
<dependency>
105+
<groupId>com.sun.jersey</groupId>
106+
<artifactId>jersey-server</artifactId>
107+
<scope>compile</scope>
108+
</dependency>
109+
<dependency>
110+
<groupId>commons-cli</groupId>
111+
<artifactId>commons-cli</artifactId>
112+
<scope>compile</scope>
113+
</dependency>
114+
<dependency>
115+
<groupId>commons-codec</groupId>
116+
<artifactId>commons-codec</artifactId>
117+
<scope>compile</scope>
118+
</dependency>
119+
<dependency>
120+
<groupId>commons-io</groupId>
121+
<artifactId>commons-io</artifactId>
122+
<scope>compile</scope>
123+
</dependency>
124+
<dependency>
125+
<groupId>commons-lang</groupId>
126+
<artifactId>commons-lang</artifactId>
127+
<scope>compile</scope>
128+
</dependency>
129+
<dependency>
130+
<groupId>commons-logging</groupId>
131+
<artifactId>commons-logging</artifactId>
132+
<scope>compile</scope>
133+
</dependency>
134+
<dependency>
135+
<groupId>commons-daemon</groupId>
136+
<artifactId>commons-daemon</artifactId>
137+
<scope>compile</scope>
138+
</dependency>
139+
<dependency>
140+
<groupId>javax.servlet.jsp</groupId>
141+
<artifactId>jsp-api</artifactId>
142+
<scope>compile</scope>
143+
</dependency>
144+
<dependency>
145+
<groupId>log4j</groupId>
146+
<artifactId>log4j</artifactId>
147+
<scope>compile</scope>
148+
</dependency>
149+
<dependency>
150+
<groupId>com.google.protobuf</groupId>
151+
<artifactId>protobuf-java</artifactId>
152+
<scope>compile</scope>
153+
</dependency>
154+
<dependency>
155+
<groupId>javax.servlet</groupId>
156+
<artifactId>servlet-api</artifactId>
157+
<scope>compile</scope>
158+
</dependency>
159+
<dependency>
160+
<groupId>junit</groupId>
161+
<artifactId>junit</artifactId>
162+
<scope>test</scope>
163+
</dependency>
164+
<dependency>
165+
<groupId>org.mockito</groupId>
166+
<artifactId>mockito-all</artifactId>
167+
<scope>test</scope>
168+
</dependency>
169+
<dependency>
170+
<groupId>org.slf4j</groupId>
171+
<artifactId>slf4j-log4j12</artifactId>
172+
<scope>provided</scope>
173+
</dependency>
174+
<dependency>
175+
<groupId>org.codehaus.jackson</groupId>
176+
<artifactId>jackson-core-asl</artifactId>
177+
<scope>compile</scope>
178+
</dependency>
179+
<dependency>
180+
<groupId>org.codehaus.jackson</groupId>
181+
<artifactId>jackson-mapper-asl</artifactId>
182+
<scope>compile</scope>
183+
</dependency>
184+
<dependency>
185+
<groupId>tomcat</groupId>
186+
<artifactId>jasper-runtime</artifactId>
187+
<scope>compile</scope>
188+
</dependency>
189+
<dependency>
190+
<groupId>xmlenc</groupId>
191+
<artifactId>xmlenc</artifactId>
192+
<scope>compile</scope>
193+
</dependency>
194+
</dependencies>
195+
196+
</project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hdfs.nfs.mount;
19+
20+
import java.io.IOException;
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
24+
import org.apache.hadoop.conf.Configuration;
25+
import org.apache.hadoop.mount.MountdBase;
26+
27+
/**
28+
* Main class for starting mountd daemon. This daemon implements the NFS
29+
* mount protocol. When receiving a MOUNT request from an NFS client, it checks
30+
* the request against the list of currently exported file systems. If the
31+
* client is permitted to mount the file system, rpc.mountd obtains a file
32+
* handle for requested directory and returns it to the client.
33+
*/
34+
public class Mountd extends MountdBase {
35+
/**
36+
* Constructor
37+
* @param exports
38+
* @throws IOException
39+
*/
40+
public Mountd(List<String> exports) throws IOException {
41+
super(exports, new RpcProgramMountd(exports));
42+
}
43+
44+
public Mountd(List<String> exports, Configuration config) throws IOException {
45+
super(exports, new RpcProgramMountd(exports, config));
46+
}
47+
48+
public static void main(String[] args) throws IOException {
49+
List<String> exports = new ArrayList<String>();
50+
exports.add("/");
51+
Mountd mountd = new Mountd(exports);
52+
mountd.start(true);
53+
}
54+
}

0 commit comments

Comments
 (0)