HDFS-6378. Merging change r1610543 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1610545 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brandon Li 2014-07-14 21:54:48 +00:00
parent c9c1ee9a9c
commit ca6e01d472
5 changed files with 32 additions and 11 deletions

View File

@ -19,12 +19,16 @@ package org.apache.hadoop.mount;
import java.io.IOException; import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.oncrpc.RpcProgram; import org.apache.hadoop.oncrpc.RpcProgram;
import org.apache.hadoop.oncrpc.SimpleTcpServer; import org.apache.hadoop.oncrpc.SimpleTcpServer;
import org.apache.hadoop.oncrpc.SimpleUdpServer; import org.apache.hadoop.oncrpc.SimpleUdpServer;
import org.apache.hadoop.portmap.PortmapMapping; import org.apache.hadoop.portmap.PortmapMapping;
import org.apache.hadoop.util.ShutdownHookManager; import org.apache.hadoop.util.ShutdownHookManager;
import static org.apache.hadoop.util.ExitUtil.terminate;
/** /**
* Main class for starting mountd daemon. This daemon implements the NFS * Main class for starting mountd daemon. This daemon implements the NFS
* mount protocol. When receiving a MOUNT request from an NFS client, it checks * mount protocol. When receiving a MOUNT request from an NFS client, it checks
@ -33,6 +37,7 @@ import org.apache.hadoop.util.ShutdownHookManager;
* handle for requested directory and returns it to the client. * handle for requested directory and returns it to the client.
*/ */
abstract public class MountdBase { abstract public class MountdBase {
public static final Log LOG = LogFactory.getLog(MountdBase.class);
private final RpcProgram rpcProgram; private final RpcProgram rpcProgram;
private int udpBoundPort; // Will set after server starts private int udpBoundPort; // Will set after server starts
private int tcpBoundPort; // Will set after server starts private int tcpBoundPort; // Will set after server starts
@ -74,8 +79,13 @@ abstract public class MountdBase {
if (register) { if (register) {
ShutdownHookManager.get().addShutdownHook(new Unregister(), ShutdownHookManager.get().addShutdownHook(new Unregister(),
SHUTDOWN_HOOK_PRIORITY); SHUTDOWN_HOOK_PRIORITY);
try {
rpcProgram.register(PortmapMapping.TRANSPORT_UDP, udpBoundPort); rpcProgram.register(PortmapMapping.TRANSPORT_UDP, udpBoundPort);
rpcProgram.register(PortmapMapping.TRANSPORT_TCP, tcpBoundPort); rpcProgram.register(PortmapMapping.TRANSPORT_TCP, tcpBoundPort);
} catch (Throwable e) {
LOG.fatal("Failed to start the server. Cause:", e);
terminate(1, e);
}
} }
} }

View File

@ -25,6 +25,8 @@ import org.apache.hadoop.oncrpc.SimpleTcpServer;
import org.apache.hadoop.portmap.PortmapMapping; import org.apache.hadoop.portmap.PortmapMapping;
import org.apache.hadoop.util.ShutdownHookManager; import org.apache.hadoop.util.ShutdownHookManager;
import static org.apache.hadoop.util.ExitUtil.terminate;
/** /**
* Nfs server. Supports NFS v3 using {@link RpcProgram}. * Nfs server. Supports NFS v3 using {@link RpcProgram}.
* Currently Mountd program is also started inside this class. * Currently Mountd program is also started inside this class.
@ -50,7 +52,12 @@ public abstract class Nfs3Base {
if (register) { if (register) {
ShutdownHookManager.get().addShutdownHook(new Unregister(), ShutdownHookManager.get().addShutdownHook(new Unregister(),
SHUTDOWN_HOOK_PRIORITY); SHUTDOWN_HOOK_PRIORITY);
try {
rpcProgram.register(PortmapMapping.TRANSPORT_TCP, nfsBoundPort); rpcProgram.register(PortmapMapping.TRANSPORT_TCP, nfsBoundPort);
} catch (Throwable e) {
LOG.fatal("Failed to start the server. Cause:", e);
terminate(1, e);
}
} }
} }

View File

@ -131,7 +131,7 @@ public abstract class RpcProgram extends SimpleChannelUpstreamHandler {
} catch (IOException e) { } catch (IOException e) {
String request = set ? "Registration" : "Unregistration"; String request = set ? "Registration" : "Unregistration";
LOG.error(request + " failure with " + host + ":" + port LOG.error(request + " failure with " + host + ":" + port
+ ", portmap entry: " + mapEntry, e); + ", portmap entry: " + mapEntry);
throw new RuntimeException(request + " failure", e); throw new RuntimeException(request + " failure", e);
} }
} }

View File

@ -60,6 +60,7 @@ public class SimpleUdpClient {
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length,
IPAddress, port); IPAddress, port);
socket.send(sendPacket); socket.send(sendPacket);
socket.setSoTimeout(500);
DatagramPacket receivePacket = new DatagramPacket(receiveData, DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length); receiveData.length);
socket.receive(receivePacket); socket.receive(receivePacket);

View File

@ -577,6 +577,9 @@ Release 2.5.0 - UNRELEASED
HDFS-6647. Edit log corruption when pipeline recovery occurs for deleted HDFS-6647. Edit log corruption when pipeline recovery occurs for deleted
file present in snapshot (kihwal) file present in snapshot (kihwal)
HDFS-6378. NFS registration should timeout instead of hanging when
portmap/rpcbind is not available (Abhiraj Butala via brandonli)
BREAKDOWN OF HDFS-2006 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-2006 SUBTASKS AND RELATED JIRAS
HDFS-6299. Protobuf for XAttr and client-side implementation. (Yi Liu via umamahesh) HDFS-6299. Protobuf for XAttr and client-side implementation. (Yi Liu via umamahesh)