Author: cutting
Date: Wed Oct 5 11:56:30 2005
New Revision: 295082
URL: http://svn.apache.org/viewcvs?rev=295082&view=rev
Log:
Make tolerant of non-existing local directories, e.g., to permit
varying numbers of drives on machines.
Modified:
lucene/nutch/branches/mapred/src/java/org/apache/nutch/mapred/JobConf.java
Modified:
lucene/nutch/branches/mapred/src/java/org/apache/nutch/mapred/JobConf.java
URL:
http://svn.apache.org/viewcvs/lucene/nutch/branches/mapred/src/java/org/apache/nutch/mapred/JobConf.java?rev=295082&r1=295081&r2=295082&view=diff
==============================================================================
--- lucene/nutch/branches/mapred/src/java/org/apache/nutch/mapred/JobConf.java
(original)
+++ lucene/nutch/branches/mapred/src/java/org/apache/nutch/mapred/JobConf.java
Wed Oct 5 11:56:30 2005
@@ -110,10 +110,16 @@
throws IOException {
String[] localDirs = getLocalDirs();
String path = subdir + File.separator + name;
- int i = (path.hashCode() & Integer.MAX_VALUE) % localDirs.length;
- File file = new File(localDirs[i], path);
- file.getParentFile().mkdirs();
- return file;
+ int hashCode = path.hashCode();
+ for (int i = 0; i < localDirs.length; i++) { // try each local dir
+ int index = (hashCode+i & Integer.MAX_VALUE) % localDirs.length;
+ File file = new File(localDirs[index], path);
+ File dir = file.getParentFile();
+ if (dir.exists() || dir.mkdirs()) {
+ return file;
+ }
+ }
+ throw new IOException("No valid local directories.");
}
public void setInputDir(File dir) { set("mapred.input.dir", dir); }