Hello,
I am attaching a minor patch for datanode command line handling that allows one to pass name of data directory as a command line parameter.
If not passed data directory configured in nutch config file is used.
It is very useful for running multiple instances of datanode on the same host - mainly for test purposes.
Regards Piotr
Index: src/java/org/apache/nutch/ndfs/NDFS.java
===================================================================
--- src/java/org/apache/nutch/ndfs/NDFS.java (revision 164635)
+++ src/java/org/apache/nutch/ndfs/NDFS.java (working copy)
@@ -411,14 +411,12 @@
Vector receivedBlockList = new Vector();
/**
- * Create using configured defaults.
+ * Create using configured defaults and dataDir.
*/
- public DataNode() throws IOException {
- this(InetAddress.getLocalHost().getHostName(),
- new File(NutchConf.get().get("ndfs.data.dir",
- "/tmp/nutch/data/name")),
- createSocketAddr
- (NutchConf.get().get("fs.default.name", "local")));
+ public DataNode(String dataDir) throws IOException {
+ this(InetAddress.getLocalHost().getHostName(), new File(dataDir),
+ createSocketAddr(NutchConf.get().get("fs.default.name",
+ "local")));
}
/**
@@ -911,7 +909,14 @@
/**
*/
public static void main(String argv[]) throws IOException {
- DataNode datanode = new DataNode();
+ String dataDir = NutchConf.get().get("ndfs.data.dir",
+ "/tmp/nutch/data/name");
+ if (argv.length > 0){
+ dataDir=argv[0];
+ }
+ LOG.info("Using ["+dataDir+"] directory for data storage.");
+
+ DataNode datanode = new DataNode(dataDir);
while (true) {
try {
datanode.offerService();
