Author: aching
Date: Wed Sep 14 03:50:57 2011
New Revision: 1170427

URL: http://svn.apache.org/viewvc?rev=1170427&view=rev
Log:
GIRAPH-30: NPE in ZooKeeperManager if base directory cannot be
created. apurtell via aching.


Modified:
    incubator/giraph/trunk/CHANGELOG
    
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java

Modified: incubator/giraph/trunk/CHANGELOG
URL: 
http://svn.apache.org/viewvc/incubator/giraph/trunk/CHANGELOG?rev=1170427&r1=1170426&r2=1170427&view=diff
==============================================================================
--- incubator/giraph/trunk/CHANGELOG (original)
+++ incubator/giraph/trunk/CHANGELOG Wed Sep 14 03:50:57 2011
@@ -2,6 +2,9 @@ Giraph Change Log
 
 Release 0.70.0 - unreleased
 
+  GIRAPH-30: NPE in ZooKeeperManager if base directory cannot be
+  created. apurtell via aching.
+
   GIRAPH-27: Mutable static global state in Vertex.java should be
   refactored. jake.mannix via aching.
  

Modified: 
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
URL: 
http://svn.apache.org/viewvc/incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java?rev=1170427&r1=1170426&r2=1170427&view=diff
==============================================================================
--- 
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java 
(original)
+++ 
incubator/giraph/trunk/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java 
Wed Sep 14 03:50:57 2011
@@ -229,6 +229,21 @@ public class ZooKeeperManager {
             LOG.error("createCandidateStamp: Failed to mkdirs " +
                       baseDirectory);
         }
+        // Check that the base directory exists and is a directory
+        try {
+            if (!fs.getFileStatus(baseDirectory).isDir()) {
+                throw new IllegalArgumentException(
+                    "createCandidateStamp: " + baseDirectory +
+                    " is not a directory, but should be.");
+            }
+        } catch (IOException e) {
+            throw new IllegalArgumentException(
+                "createCandidateStamp: Couldn't get file status " +
+                "for base directory " + baseDirectory + ".  If there is an " +
+                "issue with this directory, please set an accesible " +
+                "base directory with the Hadoop configuration option " +
+                GiraphJob.ZOOKEEPER_MANAGER_DIRECTORY);
+        }
 
         Path myCandidacyPath = new Path(
             taskDirectory, myHostname +


Reply via email to