Author: gdusbabek Date: Mon May 24 19:05:42 2010 New Revision: 947766 URL: http://svn.apache.org/viewvc?rev=947766&view=rev Log: git a better message when no schema is defined. patch by gdusbabek, reviewed by jbellis. CASSANDRA-1087
Modified: cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Modified: cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=947766&r1=947765&r2=947766&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Mon May 24 19:05:42 2010 @@ -43,7 +43,9 @@ import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.error.YAMLException; import java.io.File; +import java.io.FileFilter; import java.io.FileInputStream; +import java.io.FilenameFilter; import java.io.IOError; import java.io.IOException; import java.io.InputStream; @@ -366,7 +368,39 @@ public class DatabaseDescriptor // don't load from xml anymore. UUID uuid = Migration.getLastMigrationId(); if (uuid == null) - logger.warn("Couldn't detect any schema definitions in local storage. I hope you've got a plan."); + { + logger.info("Couldn't detect any schema definitions in local storage."); + // peek around the data directories to see if anything is there. + boolean hasExistingTables = false; + for (String dataDir : DatabaseDescriptor.getAllDataFileLocations()) + { + File dataPath = new File(dataDir); + if (dataPath.exists() && dataPath.isDirectory()) + { + // see if there are other directories present. + int dirCount = dataPath.listFiles(new FileFilter() + { + @Override + public boolean accept(File pathname) + { + return pathname.isDirectory(); + } + }).length; + if (dirCount > 0) + hasExistingTables = true; + } + if (hasExistingTables) + { + break; + } + } + + if (hasExistingTables) + logger.info("Found table data in data directories. Consider using JMX to call org.apache.cassandra.service.StorageService.loadSchemaFromYaml()."); + else + logger.info("Consider using JMX to org.apache.cassandra.service.StorageService.loadSchemaFromYaml() or set up a schema using the system_* calls provided via thrift."); + + } else { logger.info("Loading schema version " + uuid.toString());