cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r1215295 - /cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
Date Fri, 16 Dec 2011 21:31:37 GMT
Author: brandonwilliams
Date: Fri Dec 16 21:31:36 2011
New Revision: 1215295

URL: http://svn.apache.org/viewvc?rev=1215295&view=rev
Log:
Check for permission problems with directories on startup.
Patch by Yuki Morishita, reviewed by brandonwilliams for CASSANDRA-3544

Modified:
    cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java

Modified: cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java?rev=1215295&r1=1215294&r2=1215295&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
(original)
+++ cassandra/branches/cassandra-1.0/src/java/org/apache/cassandra/service/AbstractCassandraDaemon.java
Fri Dec 16 21:31:36 2011
@@ -23,6 +23,8 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -46,6 +48,9 @@ import org.apache.cassandra.db.commitlog
 import org.apache.cassandra.db.migration.Migration;
 import org.apache.cassandra.utils.CLibrary;
 import org.apache.cassandra.utils.Mx4jTool;
+import org.apache.commons.lang.ArrayUtils;
+
+import com.google.common.collect.Iterables;
 
 /**
  * The <code>CassandraDaemon</code> is an abstraction for a Cassandra daemon
@@ -117,10 +122,10 @@ public abstract class AbstractCassandraD
      */
     protected void setup() throws IOException
     {
-    	logger.info("JVM vendor/version: {}/{}", System.getProperty("java.vm.name"), System.getProperty("java.version")
);
+        logger.info("JVM vendor/version: {}/{}", System.getProperty("java.vm.name"), System.getProperty("java.version")
);
         logger.info("Heap size: {}/{}", Runtime.getRuntime().totalMemory(), Runtime.getRuntime().maxMemory());
-		logger.info("Classpath: {}", System.getProperty("java.class.path"));
-    	CLibrary.tryMlockall();
+        logger.info("Classpath: {}", System.getProperty("java.class.path"));
+        CLibrary.tryMlockall();
 
         listenPort = DatabaseDescriptor.getRpcPort();
         listenAddr = DatabaseDescriptor.getRpcAddress();
@@ -139,7 +144,20 @@ public abstract class AbstractCassandraD
                 }
             }
         });
-        
+
+        // check all directories(data, commitlog, saved cache) for existence and permission
+        Iterable<String> dirs = Iterables.concat(Arrays.asList(DatabaseDescriptor.getAllDataFileLocations()),
+                                                 Arrays.asList(new String[] {DatabaseDescriptor.getCommitLogLocation(),
+                                                                             DatabaseDescriptor.getSavedCachesLocation()}));
+        for (String dataDir : dirs)
+        {
+            logger.debug("Checking directory {}", dataDir);
+            File dir = new File(dataDir);
+            if (dir.exists())
+                assert dir.isDirectory() && dir.canRead() && dir.canWrite()
&& dir.canExecute()
+                    : String.format("Directory %s is not accessible.", dataDir);
+        }
+
         // check the system table to keep user from shooting self in foot by changing partitioner,
cluster name, etc.
         // we do a one-off scrub of the system table first; we can't load the list of the
rest of the tables,
         // until system table is opened.



Mime
View raw message