|
@@ -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
|
|
@@ -40,11 +45,11 @@ abstract public class MountdBase {
|
|
public RpcProgram getRpcProgram() {
|
|
public RpcProgram getRpcProgram() {
|
|
return rpcProgram;
|
|
return rpcProgram;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Constructor
|
|
* Constructor
|
|
* @param program
|
|
* @param program
|
|
- * @throws IOException
|
|
|
|
|
|
+ * @throws IOException
|
|
*/
|
|
*/
|
|
public MountdBase(RpcProgram program) throws IOException {
|
|
public MountdBase(RpcProgram program) throws IOException {
|
|
rpcProgram = program;
|
|
rpcProgram = program;
|
|
@@ -74,11 +79,16 @@ abstract public class MountdBase {
|
|
if (register) {
|
|
if (register) {
|
|
ShutdownHookManager.get().addShutdownHook(new Unregister(),
|
|
ShutdownHookManager.get().addShutdownHook(new Unregister(),
|
|
SHUTDOWN_HOOK_PRIORITY);
|
|
SHUTDOWN_HOOK_PRIORITY);
|
|
- rpcProgram.register(PortmapMapping.TRANSPORT_UDP, udpBoundPort);
|
|
|
|
- rpcProgram.register(PortmapMapping.TRANSPORT_TCP, tcpBoundPort);
|
|
|
|
|
|
+ try {
|
|
|
|
+ rpcProgram.register(PortmapMapping.TRANSPORT_UDP, udpBoundPort);
|
|
|
|
+ rpcProgram.register(PortmapMapping.TRANSPORT_TCP, tcpBoundPort);
|
|
|
|
+ } catch (Throwable e) {
|
|
|
|
+ LOG.fatal("Failed to start the server. Cause:", e);
|
|
|
|
+ terminate(1, e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Priority of the mountd shutdown hook.
|
|
* Priority of the mountd shutdown hook.
|
|
*/
|
|
*/
|
|
@@ -91,5 +101,5 @@ abstract public class MountdBase {
|
|
rpcProgram.unregister(PortmapMapping.TRANSPORT_TCP, tcpBoundPort);
|
|
rpcProgram.unregister(PortmapMapping.TRANSPORT_TCP, tcpBoundPort);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|