|
@@ -47,6 +47,7 @@ import org.apache.hadoop.hdfs.server.protocol.UpgradeCommand;
|
|
import org.apache.hadoop.http.HttpServer;
|
|
import org.apache.hadoop.http.HttpServer;
|
|
import org.apache.hadoop.ipc.*;
|
|
import org.apache.hadoop.ipc.*;
|
|
import org.apache.hadoop.conf.*;
|
|
import org.apache.hadoop.conf.*;
|
|
|
|
+import org.apache.hadoop.util.ServicePlugin;
|
|
import org.apache.hadoop.util.ReflectionUtils;
|
|
import org.apache.hadoop.util.ReflectionUtils;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.hadoop.util.StringUtils;
|
|
import org.apache.hadoop.net.NetUtils;
|
|
import org.apache.hadoop.net.NetUtils;
|
|
@@ -64,6 +65,7 @@ import java.io.*;
|
|
import java.net.*;
|
|
import java.net.*;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**********************************************************
|
|
/**********************************************************
|
|
* NameNode serves as both directory namespace manager and
|
|
* NameNode serves as both directory namespace manager and
|
|
@@ -144,6 +146,8 @@ public class NameNode implements ClientProtocol, DatanodeProtocol,
|
|
protected NamenodeRegistration nodeRegistration;
|
|
protected NamenodeRegistration nodeRegistration;
|
|
/** Is service level authorization enabled? */
|
|
/** Is service level authorization enabled? */
|
|
private boolean serviceAuthEnabled = false;
|
|
private boolean serviceAuthEnabled = false;
|
|
|
|
+ /** Activated plug-ins. */
|
|
|
|
+ private List<ServicePlugin> plugins;
|
|
|
|
|
|
/** Format a new filesystem. Destroys any filesystem that may already
|
|
/** Format a new filesystem. Destroys any filesystem that may already
|
|
* exist at this location. **/
|
|
* exist at this location. **/
|
|
@@ -273,6 +277,15 @@ public class NameNode implements ClientProtocol, DatanodeProtocol,
|
|
startHttpServer(conf);
|
|
startHttpServer(conf);
|
|
server.start(); //start RPC server
|
|
server.start(); //start RPC server
|
|
startTrashEmptier(conf);
|
|
startTrashEmptier(conf);
|
|
|
|
+
|
|
|
|
+ plugins = conf.getInstances("dfs.namenode.plugins", ServicePlugin.class);
|
|
|
|
+ for (ServicePlugin p: plugins) {
|
|
|
|
+ try {
|
|
|
|
+ p.start(this);
|
|
|
|
+ } catch (Throwable t) {
|
|
|
|
+ LOG.warn("ServicePlugin " + p + " could not be started", t);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void startTrashEmptier(Configuration conf) throws IOException {
|
|
private void startTrashEmptier(Configuration conf) throws IOException {
|
|
@@ -382,6 +395,15 @@ public class NameNode implements ClientProtocol, DatanodeProtocol,
|
|
if (stopRequested)
|
|
if (stopRequested)
|
|
return;
|
|
return;
|
|
stopRequested = true;
|
|
stopRequested = true;
|
|
|
|
+ if (plugins != null) {
|
|
|
|
+ for (ServicePlugin p : plugins) {
|
|
|
|
+ try {
|
|
|
|
+ p.stop();
|
|
|
|
+ } catch (Throwable t) {
|
|
|
|
+ LOG.warn("ServicePlugin " + p + " could not be stopped", t);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
if (httpServer != null) httpServer.stop();
|
|
if (httpServer != null) httpServer.stop();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|