cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r758992 - in /incubator/cassandra/trunk: ./ src/org/apache/cassandra/config/ src/org/apache/cassandra/db/ src/org/apache/cassandra/service/ src/org/apache/cassandra/test/ test/ test/org/ test/org/apache/ test/org/apache/cassandra/ test/org/...
Date Fri, 27 Mar 2009 02:43:48 GMT
Author: jbellis
Date: Fri Mar 27 02:43:46 2009
New Revision: 758992

URL: http://svn.apache.org/viewvc?rev=758992&view=rev
Log:
test support.  this requires some refactoring so that tests can be independent

Added:
    incubator/cassandra/trunk/test/
    incubator/cassandra/trunk/test/org/
    incubator/cassandra/trunk/test/org/apache/
    incubator/cassandra/trunk/test/org/apache/cassandra/
    incubator/cassandra/trunk/test/org/apache/cassandra/ServerTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/
    incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnComparatorFactoryTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/CommitLogTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/DBManagerTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/RecoveryManagerTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/SystemTableTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/db/TableTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/dht/
    incubator/cassandra/trunk/test/org/apache/cassandra/dht/RangeTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/io/
    incubator/cassandra/trunk/test/org/apache/cassandra/io/DataInputBufferTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/io/SSTableTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/service/
    incubator/cassandra/trunk/test/org/apache/cassandra/service/CassandraServerTest.java
    incubator/cassandra/trunk/test/org/apache/cassandra/utils/
    incubator/cassandra/trunk/test/org/apache/cassandra/utils/KeyGenerator.java
    incubator/cassandra/trunk/test/org/apache/cassandra/utils/ResetableIterator.java
    incubator/cassandra/trunk/test/testng.xml
Modified:
    incubator/cassandra/trunk/build.xml
    incubator/cassandra/trunk/src/org/apache/cassandra/config/DatabaseDescriptor.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/BinaryMemtable.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/CommitLog.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/DBManager.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/RecoveryManager.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/SystemTable.java
    incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java
    incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java
    incubator/cassandra/trunk/src/org/apache/cassandra/test/DBTest.java

Modified: incubator/cassandra/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/build.xml?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/build.xml (original)
+++ incubator/cassandra/trunk/build.xml Fri Mar 27 02:43:46 2009
@@ -8,6 +8,8 @@
     <property name="build.lib" value="${basedir}/lib"/>
     <property name="build.dir" value="${basedir}/build"/>
     <property name="build.classes" value="${build.dir}/classes"/>
+    <property name="test.dir" value="${basedir}/test"/>
+    <property name="test.classes" value="${basedir}/test/classes"/>
     <property name="final.name" value="cassandra"/>
 
     <!-- 
@@ -25,9 +27,11 @@
     -->
     <target name="init">
         <mkdir dir="${build.classes}"/>
+        <mkdir dir="${test.classes}"/>
     </target>
     <target name="clean">
         <delete dir="${build.classes}"/>
+        <delete dir="${test.classes}"/>
     </target>
     <target depends="clean" name="cleanall"/>
 
@@ -88,4 +92,30 @@
   </target>
 
 
+  <target name="build-test" depends="build" description="Build the Cassandra classes">
+    <javac
+     debug="${javac.debug}"
+     debuglevel="${javac.debuglevel}"
+     destdir="${test.classes}"
+    >
+      <classpath refid="cassandra.classpath"/>
+      <src path="${test.dir}"/>
+    </javac>
+  </target>
+
+  <taskdef resource="testngtasks" classpath="lib/testng-5.8-jdk15.jar"/>
+  <target name="test" depends="build-test">
+    <echo message="running tests"/>
+    <testng outputDir="${test.dir}/output"
+            haltOnFailure="true"
+            verbose="2">
+      <jvmarg value="-Dstorage-config=conf"/>
+      <classpath>
+        <path refid="cassandra.classpath" />
+        <pathelement location="${test.classes}"/>
+      </classpath>
+      <classfileset dir="${test.classes}" includes="**/*.class" />
+    </testng>
+  </target>
+
 </project>

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/config/DatabaseDescriptor.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/config/DatabaseDescriptor.java Fri Mar 27 02:43:46 2009
@@ -25,6 +25,8 @@
 import org.apache.cassandra.db.ColumnFamily;
 import org.apache.cassandra.db.Table;
 import org.apache.cassandra.db.TypeInfo;
+import org.apache.cassandra.db.DBManager;
+import org.apache.cassandra.db.SystemTable;
 import org.apache.cassandra.db.Table.TableMetadata;
 import org.apache.cassandra.utils.FileUtils;
 import org.apache.cassandra.utils.XMLUtils;
@@ -114,304 +116,347 @@
     
     // the path qualified config file (storage-conf.xml) name
     private static String configFileName_;
-
-    public static Map<String, Map<String, CFMetaData>> init(String filePath) throws Throwable
-    {
-        /* Read the configuration file to retrieve DB related properties. */
-        String file = filePath + System.getProperty("file.separator") + "storage-conf.xml";
-        return initInternal(file);
-    }
-
-    public static Map<String, Map<String, CFMetaData>> init() throws Throwable
-    {
-        /* Read the configuration file to retrieve DB related properties. */
-        configFileName_ = System.getProperty("storage-config") + System.getProperty("file.separator") + "storage-conf.xml";
-        return initInternal(configFileName_);
-    }
     
-    public static Map<String, Map<String, CFMetaData>> initInternal(String file) throws Throwable
+    static
     {
-        String os = System.getProperty("os.name");
-        XMLUtils xmlUtils = new XMLUtils(file);        
+        try
+        {
+            String file = System.getProperty("storage-config") + System.getProperty("file.separator") + "storage-conf.xml";
+            String os = System.getProperty("os.name");
+            XMLUtils xmlUtils = new XMLUtils(file);
+
+            /* Cluster Name */
+            clusterName_ = xmlUtils.getNodeValue("/Storage/ClusterName");
+
+            /* Ganglia servers contact list */
+            gangliaServers_ = xmlUtils.getNodeValues("/Storage/GangliaServers/GangliaServer");
+
+            /* ZooKeeper's address */
+            zkAddress_ = xmlUtils.getNodeValue("/Storage/ZookeeperAddress");
+
+            /* Hashing strategy */
+            hashingStrategy_ = xmlUtils.getNodeValue("/Storage/HashingStrategy");
+            /* Callout location */
+            calloutLocation_ = xmlUtils.getNodeValue("/Storage/CalloutLocation");
+
+            /* JobTracker address */
+            jobTrackerHost_ = xmlUtils.getNodeValue("/Storage/JobTrackerHost");
+
+            /* Job Jar file location */
+            jobJarFileLocation_ = xmlUtils.getNodeValue("/Storage/JobJarFileLocation");
+
+            /* Zookeeper's session timeout */
+            String zkSessionTimeout = xmlUtils.getNodeValue("/Storage/ZookeeperSessionTimeout");
+            if ( zkSessionTimeout != null )
+                zkSessionTimeout_ = Integer.parseInt(zkSessionTimeout);
+
+            /* Data replication factor */
+            String replicationFactor = xmlUtils.getNodeValue("/Storage/ReplicationFactor");
+            if ( replicationFactor != null )
+                replicationFactor_ = Integer.parseInt(replicationFactor);
+
+            /* RPC Timeout */
+            String rpcTimeoutInMillis = xmlUtils.getNodeValue("/Storage/RpcTimeoutInMillis");
+            if ( rpcTimeoutInMillis != null )
+                rpcTimeoutInMillis_ = Integer.parseInt(rpcTimeoutInMillis);
+
+            /* Thread per pool */
+            String threadsPerPool = xmlUtils.getNodeValue("/Storage/ThreadsPerPool");
+            if ( threadsPerPool != null )
+                threadsPerPool_ = Integer.parseInt(threadsPerPool);
+
+            /* TCP port on which the storage system listens */
+            String port = xmlUtils.getNodeValue("/Storage/StoragePort");
+            if ( port != null )
+                storagePort_ = Integer.parseInt(port);
+
+            /* UDP port for control messages */
+            port = xmlUtils.getNodeValue("/Storage/ControlPort");
+            if ( port != null )
+                controlPort_ = Integer.parseInt(port);
+
+            /* HTTP port for HTTP messages */
+            port = xmlUtils.getNodeValue("/Storage/HttpPort");
+            if ( port != null )
+                httpPort_ = Integer.parseInt(port);
+
+            /* Touch Key Cache Size */
+            String touchKeyCacheSize = xmlUtils.getNodeValue("/Storage/TouchKeyCacheSize");
+            if ( touchKeyCacheSize != null )
+                touchKeyCacheSize_ = Integer.parseInt(touchKeyCacheSize);
+
+            /* Number of days to keep the memtable around w/o flushing */
+            String lifetime = xmlUtils.getNodeValue("/Storage/MemtableLifetimeInDays");
+            if ( lifetime != null )
+                memtableLifetime_ = Integer.parseInt(lifetime);
+
+            /* Size of the memtable in memory in MB before it is dumped */
+            String memtableSize = xmlUtils.getNodeValue("/Storage/MemtableSizeInMB");
+            if ( memtableSize != null )
+                memtableSize_ = Integer.parseInt(memtableSize);
+            /* Number of objects in millions in the memtable before it is dumped */
+            String memtableObjectCount = xmlUtils.getNodeValue("/Storage/MemtableObjectCountInMillions");
+            if ( memtableObjectCount != null )
+                memtableObjectCount_ = Integer.parseInt(memtableObjectCount);
+
+            /* This parameter enables or disables consistency checks.
+             * If set to false the read repairs are disable for very
+             * high throughput on reads but at the cost of consistency.*/
+            String doConsistencyCheck = xmlUtils.getNodeValue("/Storage/DoConsistencyChecksBoolean");
+            if ( doConsistencyCheck != null )
+                doConsistencyCheck_ = Boolean.parseBoolean(doConsistencyCheck);
+
+
+            /* read the size at which we should do column indexes */
+            String columnIndexSizeInKB = xmlUtils.getNodeValue("/Storage/ColumnIndexSizeInKB");
+            if(columnIndexSizeInKB == null)
+            {
+                columnIndexSizeInKB_ = 64;
+            }
+            else
+            {
+                columnIndexSizeInKB_ = Integer.parseInt(columnIndexSizeInKB);
+            }
 
-        /* Cluster Name */
-        clusterName_ = xmlUtils.getNodeValue("/Storage/ClusterName");
+            /* metadata directory */
+            metadataDirectory_ = xmlUtils.getNodeValue("/Storage/MetadataDirectory");
+            if ( metadataDirectory_ != null )
+                FileUtils.createDirectory(metadataDirectory_);
+            else
+            {
+                if ( os.equals("Linux") )
+                {
+                    metadataDirectory_ = "/var/storage/system";
+                }
+            }
 
-        /* Ganglia servers contact list */
-        gangliaServers_ = xmlUtils.getNodeValues("/Storage/GangliaServers/GangliaServer");
-        
-        /* ZooKeeper's address */
-        zkAddress_ = xmlUtils.getNodeValue("/Storage/ZookeeperAddress");
-        
-        /* Hashing strategy */
-        hashingStrategy_ = xmlUtils.getNodeValue("/Storage/HashingStrategy");
-        /* Callout location */
-        calloutLocation_ = xmlUtils.getNodeValue("/Storage/CalloutLocation");
-        
-        /* JobTracker address */
-        jobTrackerHost_ = xmlUtils.getNodeValue("/Storage/JobTrackerHost");
-        
-        /* Job Jar file location */
-        jobJarFileLocation_ = xmlUtils.getNodeValue("/Storage/JobJarFileLocation");       
-        
-        /* Zookeeper's session timeout */
-        String zkSessionTimeout = xmlUtils.getNodeValue("/Storage/ZookeeperSessionTimeout");
-        if ( zkSessionTimeout != null )
-            zkSessionTimeout_ = Integer.parseInt(zkSessionTimeout);
-
-        /* Data replication factor */
-        String replicationFactor = xmlUtils.getNodeValue("/Storage/ReplicationFactor");
-        if ( replicationFactor != null )
-        	replicationFactor_ = Integer.parseInt(replicationFactor);
-
-        /* RPC Timeout */
-        String rpcTimeoutInMillis = xmlUtils.getNodeValue("/Storage/RpcTimeoutInMillis");
-        if ( rpcTimeoutInMillis != null )
-        	rpcTimeoutInMillis_ = Integer.parseInt(rpcTimeoutInMillis);
-
-        /* Thread per pool */
-        String threadsPerPool = xmlUtils.getNodeValue("/Storage/ThreadsPerPool");
-        if ( threadsPerPool != null )
-            threadsPerPool_ = Integer.parseInt(threadsPerPool);
-
-        /* TCP port on which the storage system listens */
-        String port = xmlUtils.getNodeValue("/Storage/StoragePort");
-        if ( port != null )
-            storagePort_ = Integer.parseInt(port);
-
-        /* UDP port for control messages */
-        port = xmlUtils.getNodeValue("/Storage/ControlPort");
-        if ( port != null )
-            controlPort_ = Integer.parseInt(port);
-
-        /* HTTP port for HTTP messages */
-        port = xmlUtils.getNodeValue("/Storage/HttpPort");
-        if ( port != null )
-            httpPort_ = Integer.parseInt(port);
-
-        /* Touch Key Cache Size */
-        String touchKeyCacheSize = xmlUtils.getNodeValue("/Storage/TouchKeyCacheSize");
-        if ( touchKeyCacheSize != null )
-            touchKeyCacheSize_ = Integer.parseInt(touchKeyCacheSize);
-
-        /* Number of days to keep the memtable around w/o flushing */
-        String lifetime = xmlUtils.getNodeValue("/Storage/MemtableLifetimeInDays");
-        if ( lifetime != null )
-            memtableLifetime_ = Integer.parseInt(lifetime);
-        
-        /* Size of the memtable in memory in MB before it is dumped */
-        String memtableSize = xmlUtils.getNodeValue("/Storage/MemtableSizeInMB");
-        if ( memtableSize != null )
-        	memtableSize_ = Integer.parseInt(memtableSize);
-        /* Number of objects in millions in the memtable before it is dumped */
-        String memtableObjectCount = xmlUtils.getNodeValue("/Storage/MemtableObjectCountInMillions");
-        if ( memtableObjectCount != null )
-        	memtableObjectCount_ = Integer.parseInt(memtableObjectCount);
-        
-        /* This parameter enables or disables consistency checks. 
-         * If set to false the read repairs are disable for very
-         * high throughput on reads but at the cost of consistency.*/
-        String doConsistencyCheck = xmlUtils.getNodeValue("/Storage/DoConsistencyChecksBoolean");
-        if ( doConsistencyCheck != null )
-        	doConsistencyCheck_ = Boolean.parseBoolean(doConsistencyCheck);
-        
-        
-        /* read the size at which we should do column indexes */
-        String columnIndexSizeInKB = xmlUtils.getNodeValue("/Storage/ColumnIndexSizeInKB");
-        if(columnIndexSizeInKB == null)
-        {
-        	columnIndexSizeInKB_ = 64;
-        }
-        else
-        {
-        	columnIndexSizeInKB_ = Integer.parseInt(columnIndexSizeInKB);
-        }
+            /* snapshot directory */
+            snapshotDirectory_ = xmlUtils.getNodeValue("/Storage/SnapshotDirectory");
+            if ( snapshotDirectory_ != null )
+                FileUtils.createDirectory(snapshotDirectory_);
+            else
+            {
+                    snapshotDirectory_ = metadataDirectory_ + System.getProperty("file.separator") + "snapshot";
+            }
 
-        /* metadata directory */
-        metadataDirectory_ = xmlUtils.getNodeValue("/Storage/MetadataDirectory");
-        if ( metadataDirectory_ != null )
-            FileUtils.createDirectory(metadataDirectory_);
-        else
-        {
-            if ( os.equals("Linux") )
+            /* map output directory */
+            mapOutputDirectories_ = xmlUtils.getNodeValues("/Storage/MapOutputDirectories/MapOutputDirectory");
+            if ( mapOutputDirectories_.length > 0 )
             {
-                metadataDirectory_ = "/var/storage/system";
+                for ( String mapOutputDirectory : mapOutputDirectories_ )
+                    FileUtils.createDirectory(mapOutputDirectory);
             }
-        }
 
-        /* snapshot directory */
-        snapshotDirectory_ = xmlUtils.getNodeValue("/Storage/SnapshotDirectory");
-        if ( snapshotDirectory_ != null )
-            FileUtils.createDirectory(snapshotDirectory_);
-        else
-        {
-            	snapshotDirectory_ = metadataDirectory_ + System.getProperty("file.separator") + "snapshot";
-        }
-        
-        /* map output directory */
-        mapOutputDirectories_ = xmlUtils.getNodeValues("/Storage/MapOutputDirectories/MapOutputDirectory");
-        if ( mapOutputDirectories_.length > 0 )
-        {
-            for ( String mapOutputDirectory : mapOutputDirectories_ )
-                FileUtils.createDirectory(mapOutputDirectory);
-        }
-        
-        /* data file directory */
-        dataFileDirectories_ = xmlUtils.getNodeValues("/Storage/DataFileDirectories/DataFileDirectory");
-        if ( dataFileDirectories_.length > 0 )
-        {
-        	for ( String dataFileDirectory : dataFileDirectories_ )
-        		FileUtils.createDirectory(dataFileDirectory);
-        }
-        else
-        {
-            if ( os.equals("Linux") )
+            /* data file directory */
+            dataFileDirectories_ = xmlUtils.getNodeValues("/Storage/DataFileDirectories/DataFileDirectory");
+            if ( dataFileDirectories_.length > 0 )
             {
-                dataFileDirectories_ = new String[]{"/var/storage/data"};
+                for ( String dataFileDirectory : dataFileDirectories_ )
+                    FileUtils.createDirectory(dataFileDirectory);
+            }
+            else
+            {
+                if ( os.equals("Linux") )
+                {
+                    dataFileDirectories_ = new String[]{"/var/storage/data"};
+                }
             }
-        }
 
-        /* bootstrap file directory */
-        bootstrapFileDirectory_ = xmlUtils.getNodeValue("/Storage/BootstrapFileDirectory");
-        if ( bootstrapFileDirectory_ != null )
-            FileUtils.createDirectory(bootstrapFileDirectory_);
-        else
-        {
-            if ( os.equals("Linux") )
+            /* bootstrap file directory */
+            bootstrapFileDirectory_ = xmlUtils.getNodeValue("/Storage/BootstrapFileDirectory");
+            if ( bootstrapFileDirectory_ != null )
+                FileUtils.createDirectory(bootstrapFileDirectory_);
+            else
             {
-                bootstrapFileDirectory_ = "/var/storage/bootstrap";
+                if ( os.equals("Linux") )
+                {
+                    bootstrapFileDirectory_ = "/var/storage/bootstrap";
+                }
             }
-        }
 
-        /* commit log directory */
-        logFileDirectory_ = xmlUtils.getNodeValue("/Storage/CommitLogDirectory");
-        if ( logFileDirectory_ != null )
-            FileUtils.createDirectory(logFileDirectory_);
-        else
-        {
-            if ( os.equals("Linux") )
+            /* commit log directory */
+            logFileDirectory_ = xmlUtils.getNodeValue("/Storage/CommitLogDirectory");
+            if ( logFileDirectory_ != null )
+                FileUtils.createDirectory(logFileDirectory_);
+            else
             {
-                logFileDirectory_ = "/var/storage/commitlog";
+                if ( os.equals("Linux") )
+                {
+                    logFileDirectory_ = "/var/storage/commitlog";
+                }
             }
-        }
 
-        /* threshold after which commit log should be rotated. */
-        String value = xmlUtils.getNodeValue("/Storage/CommitLogRotationThresholdInMB");
-        if ( value != null)
-            logRotationThreshold_ = Integer.parseInt(value) * 1024 * 1024;
-
-        /* fast sync option */
-        value = xmlUtils.getNodeValue("/Storage/CommitLogFastSync");
-        if ( value != null )
-            fastSync_ = Boolean.parseBoolean(value);
-
-        tableToCFMetaDataMap_ = new HashMap<String, Map<String, CFMetaData>>();
-
-        /* Rack Aware option */
-        value = xmlUtils.getNodeValue("/Storage/RackAware");
-        if ( value != null )
-            rackAware_ = Boolean.parseBoolean(value);
-
-        /* Read the table related stuff from config */
-        NodeList tables = xmlUtils.getRequestedNodeList("/Storage/Tables/Table");
-        int size = tables.getLength();
-        for ( int i = 0; i < size; ++i )
-        {
-            Node table = tables.item(i);
+            /* threshold after which commit log should be rotated. */
+            String value = xmlUtils.getNodeValue("/Storage/CommitLogRotationThresholdInMB");
+            if ( value != null)
+                logRotationThreshold_ = Integer.parseInt(value) * 1024 * 1024;
+
+            /* fast sync option */
+            value = xmlUtils.getNodeValue("/Storage/CommitLogFastSync");
+            if ( value != null )
+                fastSync_ = Boolean.parseBoolean(value);
+
+            tableToCFMetaDataMap_ = new HashMap<String, Map<String, CFMetaData>>();
+
+            /* Rack Aware option */
+            value = xmlUtils.getNodeValue("/Storage/RackAware");
+            if ( value != null )
+                rackAware_ = Boolean.parseBoolean(value);
+
+            /* Read the table related stuff from config */
+            NodeList tables = xmlUtils.getRequestedNodeList("/Storage/Tables/Table");
+            int size = tables.getLength();
+            for ( int i = 0; i < size; ++i )
+            {
+                Node table = tables.item(i);
+
+                /* parsing out the table name */
+                String tName = XMLUtils.getAttributeValue(table, "Name");
+                tables_.add(tName);
+                tableToCFMetaDataMap_.put(tName, new HashMap<String, CFMetaData>());
+
+                String xqlTable = "/Storage/Tables/Table[@Name='" + tName + "']/";
+                NodeList columnFamilies = xmlUtils.getRequestedNodeList(xqlTable + "ColumnFamily");
+
+                // get name of the rowKey for this table
+                String n_rowKey = xmlUtils.getNodeValue(xqlTable + "RowKey");
+                if (n_rowKey == null)
+                    n_rowKey = d_rowKey_;
 
-            /* parsing out the table name */
-            String tName = XMLUtils.getAttributeValue(table, "Name");
-            tables_.add(tName);
-            tableToCFMetaDataMap_.put(tName, new HashMap<String, CFMetaData>());
-
-            String xqlTable = "/Storage/Tables/Table[@Name='" + tName + "']/";
-            NodeList columnFamilies = xmlUtils.getRequestedNodeList(xqlTable + "ColumnFamily");
-
-            // get name of the rowKey for this table
-            String n_rowKey = xmlUtils.getNodeValue(xqlTable + "RowKey");
-            if (n_rowKey == null)
-                n_rowKey = d_rowKey_;
-
-            //NodeList columnFamilies = xmlUtils.getRequestedNodeList(table, "ColumnFamily");            
-            int size2 = columnFamilies.getLength();
-
-            for ( int j = 0; j < size2; ++j )
-            {
-                Node columnFamily = columnFamilies.item(j);
-                String cName = XMLUtils.getAttributeValue(columnFamily, "Name");
-                String xqlCF = xqlTable + "ColumnFamily[@Name='" + cName + "']/";
-
-                /* squirrel away the application column families */
-                applicationColumnFamilies_.add(cName);
-
-                // Parse out the column type
-                String columnType = xmlUtils.getAttributeValue(columnFamily, "ColumnType");
-                columnType = ColumnFamily.getColumnType(columnType);
-
-                // Parse out the column family sorting property for columns
-                String columnIndexProperty = XMLUtils.getAttributeValue(columnFamily, "ColumnSort");
-                String columnIndexType = ColumnFamily.getColumnSortProperty(columnIndexProperty);
-
-                // Parse out user-specified logical names for the various dimensions
-                // of a the column family from the config.
-                String n_superColumnMap = xmlUtils.getNodeValue(xqlCF + "SuperColumnMap");
-                if (n_superColumnMap == null)
-                    n_superColumnMap = d_superColumnMap_;
-                
-                String n_superColumnKey = xmlUtils.getNodeValue(xqlCF + "SuperColumnKey");
-                if (n_superColumnKey == null)
-                    n_superColumnKey = d_superColumnKey_;
-                
-                String n_columnMap = xmlUtils.getNodeValue(xqlCF + "ColumnMap");
-                if (n_columnMap == null)
-                    n_columnMap = d_columnMap_;
-                
-                String n_columnKey = xmlUtils.getNodeValue(xqlCF + "ColumnKey");
-                if (n_columnKey == null)
-                    n_columnKey = d_columnKey_;
-
-                String n_columnValue = xmlUtils.getNodeValue(xqlCF + "ColumnValue");
-                if (n_columnValue == null)
-                    n_columnValue = d_columnValue_;
-
-                String n_columnTimestamp = xmlUtils.getNodeValue(xqlCF + "ColumnTimestamp");
-                if (n_columnTimestamp == null)
-                    n_columnTimestamp = d_columnTimestamp_;
-
-                // now populate the column family meta data and
-                // insert it into the table dictionary. 
-                CFMetaData cfMetaData = new CFMetaData();
-                
-                cfMetaData.tableName = tName;
-                cfMetaData.cfName = cName;
-                
-                cfMetaData.columnType = columnType;
-                cfMetaData.indexProperty_ = columnIndexType;
-
-                cfMetaData.n_rowKey = n_rowKey;
-                cfMetaData.n_columnMap = n_columnMap;
-                cfMetaData.n_columnKey = n_columnKey;
-                cfMetaData.n_columnValue = n_columnValue;
-                cfMetaData.n_columnTimestamp = n_columnTimestamp;
-                if ("Super".equals(columnType))
+                //NodeList columnFamilies = xmlUtils.getRequestedNodeList(table, "ColumnFamily");
+                int size2 = columnFamilies.getLength();
+
+                for ( int j = 0; j < size2; ++j )
                 {
-                    cfMetaData.n_superColumnKey = n_superColumnKey;
-                    cfMetaData.n_superColumnMap = n_superColumnMap;
+                    Node columnFamily = columnFamilies.item(j);
+                    String cName = XMLUtils.getAttributeValue(columnFamily, "Name");
+                    String xqlCF = xqlTable + "ColumnFamily[@Name='" + cName + "']/";
+
+                    /* squirrel away the application column families */
+                    applicationColumnFamilies_.add(cName);
+
+                    // Parse out the column type
+                    String columnType = xmlUtils.getAttributeValue(columnFamily, "ColumnType");
+                    columnType = ColumnFamily.getColumnType(columnType);
+
+                    // Parse out the column family sorting property for columns
+                    String columnIndexProperty = XMLUtils.getAttributeValue(columnFamily, "ColumnSort");
+                    String columnIndexType = ColumnFamily.getColumnSortProperty(columnIndexProperty);
+
+                    // Parse out user-specified logical names for the various dimensions
+                    // of a the column family from the config.
+                    String n_superColumnMap = xmlUtils.getNodeValue(xqlCF + "SuperColumnMap");
+                    if (n_superColumnMap == null)
+                        n_superColumnMap = d_superColumnMap_;
+
+                    String n_superColumnKey = xmlUtils.getNodeValue(xqlCF + "SuperColumnKey");
+                    if (n_superColumnKey == null)
+                        n_superColumnKey = d_superColumnKey_;
+
+                    String n_columnMap = xmlUtils.getNodeValue(xqlCF + "ColumnMap");
+                    if (n_columnMap == null)
+                        n_columnMap = d_columnMap_;
+
+                    String n_columnKey = xmlUtils.getNodeValue(xqlCF + "ColumnKey");
+                    if (n_columnKey == null)
+                        n_columnKey = d_columnKey_;
+
+                    String n_columnValue = xmlUtils.getNodeValue(xqlCF + "ColumnValue");
+                    if (n_columnValue == null)
+                        n_columnValue = d_columnValue_;
+
+                    String n_columnTimestamp = xmlUtils.getNodeValue(xqlCF + "ColumnTimestamp");
+                    if (n_columnTimestamp == null)
+                        n_columnTimestamp = d_columnTimestamp_;
+
+                    // now populate the column family meta data and
+                    // insert it into the table dictionary.
+                    CFMetaData cfMetaData = new CFMetaData();
+
+                    cfMetaData.tableName = tName;
+                    cfMetaData.cfName = cName;
+
+                    cfMetaData.columnType = columnType;
+                    cfMetaData.indexProperty_ = columnIndexType;
+
+                    cfMetaData.n_rowKey = n_rowKey;
+                    cfMetaData.n_columnMap = n_columnMap;
+                    cfMetaData.n_columnKey = n_columnKey;
+                    cfMetaData.n_columnValue = n_columnValue;
+                    cfMetaData.n_columnTimestamp = n_columnTimestamp;
+                    if ("Super".equals(columnType))
+                    {
+                        cfMetaData.n_superColumnKey = n_superColumnKey;
+                        cfMetaData.n_superColumnMap = n_superColumnMap;
+                    }
+
+                    tableToCFMetaDataMap_.get(tName).put(cName, cfMetaData);
                 }
+            }
 
-                tableToCFMetaDataMap_.get(tName).put(cName, cfMetaData);
+            /* Load the seeds for node contact points */
+            String[] seeds = xmlUtils.getNodeValues("/Storage/Seeds/Seed");
+            for( int i = 0; i < seeds.length; ++i )
+            {
+                seeds_.add( seeds[i] );
             }
         }
-
-        /* Load the seeds for node contact points */
-        String[] seeds = xmlUtils.getNodeValues("/Storage/Seeds/Seed");
-        for( int i = 0; i < seeds.length; ++i )
-        {            
-            seeds_.add( seeds[i] );
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        
+        try
+        {
+            storeMetadata();
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException(e);
         }
-        return tableToCFMetaDataMap_;
     }
     
+
+    /*
+     * Create the metadata tables. This table has information about
+     * the table name and the column families that make up the table.
+     * Each column family also has an associated ID which is an int.
+    */
+    private static void storeMetadata() throws IOException
+    {
+        AtomicInteger idGenerator = new AtomicInteger(0);
+        Set<String> tables = tableToCFMetaDataMap_.keySet();
+
+        for ( String table : tables )
+        {
+            Table.TableMetadata tmetadata = Table.TableMetadata.instance();
+            if (tmetadata.isEmpty())
+            {
+                tmetadata = Table.TableMetadata.instance();
+                /* Column families associated with this table */
+                Map<String, CFMetaData> columnFamilies = tableToCFMetaDataMap_.get(table);
+
+                for (String columnFamily : columnFamilies.keySet())
+                {
+                    tmetadata.add(columnFamily, idGenerator.getAndIncrement(), DatabaseDescriptor.getColumnType(columnFamily));
+                }
+
+                /*
+                 * Here we add all the system related column families.
+                */
+                /* Add the TableMetadata column family to this map. */
+                tmetadata.add(Table.TableMetadata.cfName_, idGenerator.getAndIncrement());
+                /* Add the LocationInfo column family to this map. */
+                tmetadata.add(SystemTable.cfName_, idGenerator.getAndIncrement());
+                /* Add the recycle column family to this map. */
+                tmetadata.add(Table.recycleBin_, idGenerator.getAndIncrement());
+                /* Add the Hints column family to this map. */
+                tmetadata.add(Table.hints_, idGenerator.getAndIncrement(), ColumnFamily.getColumnType("Super"));
+                tmetadata.apply();
+                idGenerator.set(0);
+            }
+        }
+    }
+
     public static String getHashingStrategy()
     {
         return hashingStrategy_;
@@ -735,9 +780,9 @@
             return TypeInfo.LONG;
         }
     }
-    
-    public static void main(String[] args) throws Throwable
+
+    public static Map<String, Map<String, CFMetaData>> getTableToColumnFamilyMap()
     {
-        DatabaseDescriptor.initInternal("C:\\Engagements\\Cassandra-Golden\\storage-conf.xml");
+        return tableToCFMetaDataMap_;
     }
 }

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/BinaryMemtable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/BinaryMemtable.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/BinaryMemtable.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/BinaryMemtable.java Fri Mar 27 02:43:46 2009
@@ -29,8 +29,9 @@
 import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.io.SSTable;
 import org.apache.cassandra.utils.BloomFilter;
+import org.apache.cassandra.io.SSTable;
+
 import org.apache.log4j.Logger;
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/CommitLog.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/CommitLog.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/CommitLog.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/CommitLog.java Fri Mar 27 02:43:46 2009
@@ -626,9 +626,6 @@
     public static void main(String[] args) throws Throwable
     {
         LogUtil.init();
-
-        // the return value is not used in this case
-        DatabaseDescriptor.init();
         
         File logDir = new File(DatabaseDescriptor.getLogFileLocation());
         File[] files = logDir.listFiles();

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/DBManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/DBManager.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/DBManager.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/DBManager.java Fri Mar 27 02:43:46 2009
@@ -91,10 +91,7 @@
 
     public DBManager() throws Throwable
     {
-        /* Read the configuration file */
-        Map<String, Map<String, CFMetaData>> tableToColumnFamilyMap = DatabaseDescriptor.init();
-        storeMetadata(tableToColumnFamilyMap);
-        Set<String> tables = tableToColumnFamilyMap.keySet();
+        Set<String> tables = DatabaseDescriptor.getTableToColumnFamilyMap().keySet();
         
         for (String table : tables)
         {
@@ -107,47 +104,6 @@
     }
 
     /*
-     * Create the metadata tables. This table has information about
-     * the table name and the column families that make up the table.
-     * Each column family also has an associated ID which is an int.
-    */
-    private static void storeMetadata(Map<String, Map<String, CFMetaData>> tableToColumnFamilyMap) throws Throwable
-    {
-        AtomicInteger idGenerator = new AtomicInteger(0);
-        Set<String> tables = tableToColumnFamilyMap.keySet();
-
-        for ( String table : tables )
-        {
-            Table.TableMetadata tmetadata = Table.TableMetadata.instance();
-            if ( tmetadata.isEmpty() )
-            {
-                tmetadata = Table.TableMetadata.instance();
-                /* Column families associated with this table */
-                Map<String, CFMetaData> columnFamilies = tableToColumnFamilyMap.get(table);
-
-                for (String columnFamily : columnFamilies.keySet())
-                {
-                    tmetadata.add(columnFamily, idGenerator.getAndIncrement(), DatabaseDescriptor.getColumnType(columnFamily));
-                }
-
-                /*
-                 * Here we add all the system related column families. 
-                */
-                /* Add the TableMetadata column family to this map. */
-                tmetadata.add(Table.TableMetadata.cfName_, idGenerator.getAndIncrement());
-                /* Add the LocationInfo column family to this map. */
-                tmetadata.add(SystemTable.cfName_, idGenerator.getAndIncrement());
-                /* Add the recycle column family to this map. */
-                tmetadata.add(Table.recycleBin_, idGenerator.getAndIncrement());
-                /* Add the Hints column family to this map. */
-                tmetadata.add(Table.hints_, idGenerator.getAndIncrement(), ColumnFamily.getColumnType("Super"));
-                tmetadata.apply();
-                idGenerator.set(0);
-            }
-        }
-    }
-
-    /*
      * This method reads the system table and retrieves the metadata
      * associated with this storage instance. Currently we store the
      * metadata in a Column Family called LocatioInfo which has two

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/RecoveryManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/RecoveryManager.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/RecoveryManager.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/RecoveryManager.java Fri Mar 27 02:43:46 2009
@@ -93,7 +93,6 @@
     
     public static void main(String[] args) throws Throwable
     {
-        DatabaseDescriptor.init();
         long start = System.currentTimeMillis();
         RecoveryManager rm = RecoveryManager.instance();
         rm.doRecovery();  

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/SystemTable.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/SystemTable.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/SystemTable.java Fri Mar 27 02:43:46 2009
@@ -45,7 +45,7 @@
     /* Name of the SystemTable */
     public static final String name_ = "System";
     /* Name of the only column family in the Table */
-    static final String cfName_ = "LocationInfo";
+    public static final String cfName_ = "LocationInfo";
     /* Name of columns in this table */
     static final String generation_ = "Generation";
     static final String token_ = "Token";

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/db/Table.java Fri Mar 27 02:43:46 2009
@@ -153,7 +153,7 @@
             cfTypeMap_.put(cf, type);
         }
         
-        boolean isEmpty()
+        public boolean isEmpty()
         {
             return cfIdMap_.isEmpty();
         }
@@ -193,7 +193,7 @@
             return cfIdMap_.containsKey(cfName);
         }
         
-        void apply() throws IOException
+        public void apply() throws IOException
         {
             String table = DatabaseDescriptor.getTables().get(0);
             DataOutputBuffer bufOut = new DataOutputBuffer();
@@ -895,13 +895,4 @@
         long timeTaken = System.currentTimeMillis() - start;
         dbAnalyticsSource_.updateWriteStatistics(timeTaken);
     }
-
-    public static void main(String[] args) throws Throwable
-    {
-        StorageService service = StorageService.instance();
-        service.start();
-        Table table = Table.open("Mailbox");
-        Row row = table.get("35300190:1");
-        System.out.println( row.key() );
-    }
 }

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/service/StorageService.java Fri Mar 27 02:43:46 2009
@@ -171,7 +171,7 @@
     
     public static PartitionerType getPartitionerType()
     {
-        return (DatabaseDescriptor.getHashingStrategy().equalsIgnoreCase(DatabaseDescriptor.ophf_)) ? PartitionerType.OPHF : PartitionerType.RANDOM;
+        return (DatabaseDescriptor.ophf_.equalsIgnoreCase(DatabaseDescriptor.getHashingStrategy())) ? PartitionerType.OPHF : PartitionerType.RANDOM;
     }
 
     /**
@@ -444,10 +444,10 @@
     	components_.add(component);
     }
 
-    private void initPartitioner()
+    static
     {
         String hashingStrategy = DatabaseDescriptor.getHashingStrategy();
-        if ( hashingStrategy.equalsIgnoreCase(DatabaseDescriptor.ophf_) )
+        if (DatabaseDescriptor.ophf_.equalsIgnoreCase(hashingStrategy))
         {
             partitioner_ = new OrderPreservingHashPartitioner();
         }        
@@ -458,9 +458,7 @@
     }
     
     public void start() throws Throwable
-    {        
-    	/* Set up the partitioner */
-        initPartitioner();
+    {
         /* Start the DB */
         storageMetadata_ = DBManager.instance().start();  
         /* Set up TCP endpoint */

Modified: incubator/cassandra/trunk/src/org/apache/cassandra/test/DBTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/org/apache/cassandra/test/DBTest.java?rev=758992&r1=758991&r2=758992&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/org/apache/cassandra/test/DBTest.java (original)
+++ incubator/cassandra/trunk/src/org/apache/cassandra/test/DBTest.java Fri Mar 27 02:43:46 2009
@@ -182,7 +182,6 @@
         //doWrites();
         //doRead("543");
         
-        DatabaseDescriptor.init();
         DBTest.doTest();
     }
 }

Added: incubator/cassandra/trunk/test/org/apache/cassandra/ServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/ServerTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/ServerTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/ServerTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,22 @@
+package org.apache.cassandra;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+
+import java.io.File;
+
+@Test(groups={"serial"})
+public class ServerTest {
+    // TODO clean up static structures too (e.g. memtables)
+    @BeforeMethod
+    public void cleanup() {
+        // for convenience, this assumes that you haven't changed the test config away from storing everything
+        // under /var/cassandra.
+        for (String dirname : new String[] {"bootstrap", "commitlog", "data", "staging", "system"}) {
+            File dir = new File("/var/cassandra", dirname);
+            for (File f : dir.listFiles()) {
+                f.delete();
+            }
+        }
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnComparatorFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnComparatorFactoryTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnComparatorFactoryTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnComparatorFactoryTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,25 @@
+package org.apache.cassandra.db;
+
+import org.testng.annotations.Test;
+
+import java.util.Comparator;
+
+public class ColumnComparatorFactoryTest {
+    public Comparator<IColumn> nameComparator;
+
+    @Test
+    public void testLT() {
+        IColumn col1 = new Column("Column-8");
+        IColumn col2 = new Column("Column-9");
+        nameComparator = ColumnComparatorFactory.getComparator(ColumnComparatorFactory.ComparatorType.NAME);
+        assert nameComparator.compare(col1, col2) < 0;
+    }
+
+    @Test
+    public void testGT() {
+        IColumn col1 = new Column("Column-9");
+        IColumn col2 = new Column("Column-10");
+        // tricky -- remember we're comparing _lexically_
+        assert nameComparator.compare(col1, col2) > 0;
+	}
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyStoreTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,114 @@
+package org.apache.cassandra.db;
+
+import org.apache.cassandra.ServerTest;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Random;
+
+public class ColumnFamilyStoreTest extends ServerTest {
+    @Test
+    public void testMain() throws IOException, ColumnFamilyNotDefinedException {
+        Table table = Table.open("Table1");
+        Random random = new Random();
+        byte[] bytes1 = new byte[1024];
+        byte[] bytes2 = new byte[1024];
+        random.nextBytes(bytes1);
+        random.nextBytes(bytes2);
+
+        for (int i = 800; i < 1000; ++i)
+        {
+            String key = Integer.toString(i);
+            RowMutation rm;
+            for ( int j = 0; j < 8; ++j )
+            {
+                byte[] bytes = j % 2 == 0 ? bytes1 : bytes2;
+                rm = new RowMutation("Table1", key);
+                rm.add("Standard1:" + "Column-" + j, bytes, j);
+                rm.apply();
+
+                for ( int k = 0; k < 8; ++k )
+                {
+                    bytes = (j + k) % 2 == 0 ? bytes1 : bytes2;
+                    rm = new RowMutation("Table1", key);
+                    rm.add("Super1:" + "SuperColumn-" + j + ":Column-" + k, bytes, k);
+                    rm.apply();
+                }
+            }
+        }
+
+        for ( int i = 800; i < 1000; ++i )
+        {
+            String key = Integer.toString(i);
+            // TODO actually test results
+            ColumnFamily cf = table.get(key, "Super1:SuperColumn-1");
+            assert cf != null;
+            Collection<IColumn> superColumns = cf.getAllColumns();
+            for ( IColumn superColumn : superColumns )
+            {
+                Collection<IColumn> subColumns = superColumn.getSubColumns();
+                for ( IColumn subColumn : subColumns )
+                {
+                    //System.out.println(subColumn);
+                }
+            }
+        }
+    }
+
+    @Test
+    public void testRemove() throws IOException, ColumnFamilyNotDefinedException {
+        Table table = Table.open("Table1");
+        ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
+        RowMutation rm;
+
+        // add data
+        rm = new RowMutation("Table1", "key1");
+        rm.add("Standard1:Column1", "asdf".getBytes(), 0);
+        rm.apply();
+        store.forceFlush();
+
+        // remove
+        rm = new RowMutation("Table1", "key1");
+        ColumnFamily cf = new ColumnFamily("Standard1");
+        cf.delete(1);
+        rm.add(cf.name(), cf);
+        rm.apply();
+
+        ColumnFamily retrieved = store.getColumnFamily("key1", "Standard1", new IdentityFilter());
+        assert retrieved.getColumnCount() == 0;
+    }
+
+    @Test
+    public void testRemoveSuperColumn() throws IOException, ColumnFamilyNotDefinedException {
+        Table table = Table.open("Table1");
+        ColumnFamilyStore store = table.getColumnFamilyStore("Super1");
+        RowMutation rm;
+
+        // add data
+        rm = new RowMutation("Table1", "key1");
+        rm.add("Super1:SC1:Column1", "asdf".getBytes(), 0);
+        rm.apply();
+        store.forceFlush();
+
+        // remove
+        rm = new RowMutation("Table1", "key1");
+        ColumnFamily cf = new ColumnFamily("Super1");
+        SuperColumn sc = new SuperColumn("SC1");
+        sc.markForDeleteAt(1);
+        cf.addColumn(sc);
+        rm.add(cf.name(), cf);
+        rm.apply();
+
+        List<ColumnFamily> families = store.getColumnFamilies("key1", "Super1", new IdentityFilter());
+        assert families.get(0).getAllColumns().first().getMarkedForDeleteAt() == 1; // delete marker, just added
+        assert !families.get(1).getAllColumns().first().isMarkedForDelete(); // flushed old version
+        ColumnFamily resolved = ColumnFamilyStore.resolve(families);
+        assert resolved.getAllColumns().first().getMarkedForDeleteAt() == 1;
+        Collection<IColumn> subColumns = resolved.getAllColumns().first().getSubColumns();
+        assert subColumns.size() == 1;
+        assert subColumns.iterator().next().timestamp() == 0;
+        assert ColumnFamilyStore.removeDeleted(resolved).getColumnCount() == 0;
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/ColumnFamilyTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,67 @@
+package org.apache.cassandra.db;
+
+import org.apache.cassandra.io.DataInputBuffer;
+import org.apache.cassandra.io.DataOutputBuffer;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Random;
+import java.util.TreeMap;
+
+public class ColumnFamilyTest
+{
+    // TODO test SuperColumns
+
+    @Test
+    public void testSingleColumn() throws IOException {
+        Random random = new Random();
+        byte[] bytes = new byte[1024];
+        random.nextBytes(bytes);
+        ColumnFamily cf;
+
+        cf = new ColumnFamily("Standard1", "Standard");
+        cf.addColumn("C", bytes, 1);
+        DataOutputBuffer bufOut = new DataOutputBuffer();
+        ColumnFamily.serializer().serialize(cf, bufOut);
+
+        DataInputBuffer bufIn = new DataInputBuffer();
+        bufIn.reset(bufOut.getData(), bufOut.getLength());
+        cf = ColumnFamily.serializer().deserialize(bufIn);
+        assert cf != null;
+        assert cf.name().equals("Standard1");
+        assert cf.getAllColumns().size() == 1;
+    }
+
+    @Test
+    public void testManyColumns() throws IOException {
+        ColumnFamily cf;
+
+        TreeMap<String, byte[]> map = new TreeMap<String,byte[]>();
+        for ( int i = 100; i < 1000; ++i )
+        {
+            map.put(Integer.toString(i), ("Avinash Lakshman is a good man: " + i).getBytes());
+        }
+
+        // write
+        cf = new ColumnFamily("Standard1", "Standard");
+        DataOutputBuffer bufOut = new DataOutputBuffer();
+        for (String cName: map.navigableKeySet())
+        {
+            cf.addColumn(cName, map.get(cName), 314);
+        }
+        ColumnFamily.serializer().serialize(cf, bufOut);
+
+        // verify
+        DataInputBuffer bufIn = new DataInputBuffer();
+        bufIn.reset(bufOut.getData(), bufOut.getLength());
+        cf = ColumnFamily.serializer().deserialize(bufIn);
+        for (String cName: map.navigableKeySet())
+        {
+            assert Arrays.equals(cf.getColumn(cName).value(), map.get(cName));
+
+        }
+        assert new HashSet<String>(cf.getColumns().keySet()).equals(map.keySet());
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/CommitLogTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/CommitLogTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/CommitLogTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/CommitLogTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,45 @@
+package org.apache.cassandra.db;
+
+import org.testng.annotations.Test;
+
+import java.util.Set;
+import java.util.Map;
+import java.util.Arrays;
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.io.DataInputBuffer;
+import org.apache.cassandra.ServerTest;
+
+public class CommitLogTest extends ServerTest {
+    @Test
+    public void testMain() throws IOException {
+        // TODO this is useless, since it assumes we have a working set of commit logs to parse
+        /*
+        File logDir = new File(DatabaseDescriptor.getLogFileLocation());
+        File[] files = logDir.listFiles();
+        Arrays.sort( files, new FileUtils.FileComparator() );
+
+        byte[] bytes = new byte[CommitLogHeader.size(Integer.parseInt(args[0]))];
+        for ( File file : files )
+        {
+            CommitLog clog = new CommitLog( file );
+            clog.readCommitLogHeader(file.getAbsolutePath(), bytes);
+            DataInputBuffer bufIn = new DataInputBuffer();
+            bufIn.reset(bytes, 0, bytes.length);
+            CommitLogHeader clHeader = CommitLogHeader.serializer().deserialize(bufIn);
+
+            StringBuilder sb = new StringBuilder("");
+            for ( byte b : bytes )
+            {
+                sb.append(b);
+                sb.append(" ");
+            }
+
+            System.out.println("FILE:" + file);
+            System.out.println(clHeader.toString());
+        }
+        */
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/DBManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/DBManagerTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/DBManagerTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/DBManagerTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,12 @@
+package org.apache.cassandra.db;
+
+import org.testng.annotations.Test;
+import org.apache.cassandra.ServerTest;
+
+public class DBManagerTest extends ServerTest {
+    @Test
+    public void testMain() throws Throwable {
+        // TODO clean up old detritus
+        DBManager.instance().start();
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/RecoveryManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/RecoveryManagerTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/RecoveryManagerTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/RecoveryManagerTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,16 @@
+package org.apache.cassandra.db;
+
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+
+import org.apache.cassandra.ServerTest;
+
+public class RecoveryManagerTest extends ServerTest {
+    @Test
+    public void testDoRecovery() throws IOException {
+        // TODO nothing to recover
+        RecoveryManager rm = RecoveryManager.instance();
+        rm.doRecovery();  
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/SystemTableTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/SystemTableTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/SystemTableTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/SystemTableTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,14 @@
+package org.apache.cassandra.db;
+
+import org.apache.cassandra.ServerTest;
+import org.apache.cassandra.service.StorageService;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+
+public class SystemTableTest extends ServerTest {
+    @Test
+    public void testMain() throws IOException {
+        SystemTable.openSystemTable(SystemTable.cfName_).updateToken( StorageService.hash("503545744:0") );
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/db/TableTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/db/TableTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/db/TableTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/db/TableTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,15 @@
+package org.apache.cassandra.db;
+
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+
+import org.apache.cassandra.service.StorageService;
+
+public class TableTest {
+    @Test
+    public void testOpen() throws Throwable {
+        Table table = Table.open("Mailbox");
+        Row row = table.get("35300190:1");
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/dht/RangeTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/dht/RangeTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/dht/RangeTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/dht/RangeTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,20 @@
+package org.apache.cassandra.dht;
+
+import org.testng.annotations.Test;
+
+import java.math.BigInteger;
+
+public class RangeTest {
+    @Test
+    public void testRange() {
+        Range left = new Range(new BigInteger("0"), new BigInteger("100"));
+        assert left.contains(new BigInteger("10"));
+        assert !left.contains(new BigInteger("-1"));
+        assert !left.contains(new BigInteger("101"));
+
+        Range right = new Range(new BigInteger("100"), new BigInteger("0"));
+        assert right.contains(new BigInteger("200"));
+        assert right.contains(new BigInteger("-10"));
+        assert !right.contains(new BigInteger("1"));
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/io/DataInputBufferTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/io/DataInputBufferTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/io/DataInputBufferTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/io/DataInputBufferTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,39 @@
+package org.apache.cassandra.io;
+
+import org.testng.annotations.Test;
+
+import java.util.Random;
+import java.io.IOException;
+
+public class DataInputBufferTest {
+    @Test
+    public void testRandom() throws IOException {
+        Random random = new Random();
+        byte[] bytes = new byte[1024*1024];
+        random.nextBytes(bytes);
+
+        DataInputBuffer.FastByteArrayInputStream bis = new DataInputBuffer.FastByteArrayInputStream(bytes);
+        int read = 0;
+        int n = 0;
+        while ( true )
+        {
+            read = bis.read();
+            if ( read == -1 )
+                break;
+            assert read == ((int)bytes[n++]&0xFF);
+        }
+        assert n == bytes.length;
+    }
+
+    @Test
+    public void testSmall() throws IOException {
+        DataOutputBuffer bufOut = new DataOutputBuffer();
+        bufOut.writeUTF("Avinash");
+        bufOut.writeInt(41*1024*1024);
+        DataInputBuffer bufIn = new DataInputBuffer();
+        bufIn.reset(bufOut.getData(), bufOut.getLength());
+        assert bufIn.readUTF().equals("Avinash");
+        assert bufIn.readInt() == 41 * 1024 * 1024;
+    }
+
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/io/SSTableTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/io/SSTableTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/io/SSTableTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/io/SSTableTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,75 @@
+package org.apache.cassandra.io;
+
+import org.apache.cassandra.ServerTest;
+import org.apache.cassandra.db.FileStruct;
+import org.apache.cassandra.utils.BloomFilter;
+import org.apache.commons.collections.CollectionUtils;
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+public class SSTableTest extends ServerTest {
+    // @Test
+    public void testSingleWrite() throws IOException {
+        File f = File.createTempFile("sstable", "");
+        SSTable ssTable;
+
+        // write test data
+        ssTable = new SSTable(f.getParent(), f.getName());
+        BloomFilter bf = new BloomFilter(1000, 8);
+        Random random = new Random();
+        byte[] bytes = new byte[1024];
+        random.nextBytes(bytes);
+
+        String key = Integer.toString(1);
+        ssTable.append(key, bytes);
+        bf.fill(key);
+        ssTable.close(bf);
+
+        // TODO append/next are not symmetrical ops anymore
+        
+        // verify
+        ssTable = new SSTable(f.getPath() + "-Data.db");
+        DataInputBuffer bufIn = ssTable.next(key, "Test:C");
+        byte[] bytes2 = new byte[1024];
+        bufIn.readFully(bytes2);
+        assert Arrays.equals(bytes2, bytes);
+    }
+
+    // @Test
+    public void testManyWrites() throws IOException {
+        File f = File.createTempFile("sstable", "");
+        SSTable ssTable;
+
+        TreeMap<String, byte[]> map = new TreeMap<String,byte[]>();
+        for ( int i = 100; i < 1000; ++i )
+        {
+            map.put(Integer.toString(i), ("Avinash Lakshman is a good man: " + i).getBytes());
+        }
+
+        // write
+        ssTable = new SSTable(f.getParent(), f.getName());
+        BloomFilter bf = new BloomFilter(1000, 8);
+        for (String key: map.navigableKeySet())
+        {
+            ssTable.append(key, map.get(key));
+        }
+        ssTable.close(bf);
+
+        // TODO append/next are not symmetrical ops anymore
+
+        // verify
+        List<String> keys = new ArrayList(map.keySet());
+        Collections.shuffle(keys);
+        ssTable = new SSTable(f.getPath() + "-Data.db");
+        for (String key: keys)
+        {
+            DataInputBuffer bufIn = ssTable.next(key, "Test:C");
+            byte[] bytes2 = new byte[map.get(key).length];
+            bufIn.readFully(bytes2);
+            assert Arrays.equals(bytes2, map.get(key));
+        }
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/service/CassandraServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/service/CassandraServerTest.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/service/CassandraServerTest.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/service/CassandraServerTest.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,46 @@
+package org.apache.cassandra.service;
+
+import org.apache.cassandra.ServerTest;
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.IteratorUtils;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.*;
+
+public class CassandraServerTest extends ServerTest {
+    /*
+    @Test
+    public void test_get_column() throws Throwable {
+        CassandraServer server = new CassandraServer();
+        server.start();
+
+        try {
+            column_t c1 = new column_t("c1", "0", 0L);
+            column_t c2 = new column_t("c2", "0", 0L);
+            List<column_t> columns = new ArrayList<column_t>();
+            columns.add(c1);
+            columns.add(c2);
+            Map<String, List<column_t>> cfmap = new HashMap<String, List<column_t>>();
+            cfmap.put("Standard1", columns);
+            cfmap.put("Standard2", columns);
+
+            batch_mutation_t m = new batch_mutation_t("Table1", "key1", cfmap);
+            server.batch_insert(m, 1);
+
+            column_t column;
+            column = server.get_column("Table1", "key1", "Standard1:c2");
+            assert column.value.equals("0");
+
+            column = server.get_column("Table1", "key1", "Standard2:c2");
+            assert column.value.equals("0");
+
+            ArrayList<column_t> column_ts = server.get_slice_strong("Table1", "key1", "Standard1", -1, -1);
+            assert column_ts.size() == 2;
+        } finally {
+            server.shutdown();
+        }
+    }
+    */
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/utils/KeyGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/utils/KeyGenerator.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/utils/KeyGenerator.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/utils/KeyGenerator.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,148 @@
+package org.apache.cassandra.utils;
+
+import java.io.*;
+import java.util.Random;
+
+public class KeyGenerator {
+    private static String randomKey(Random r) {
+        StringBuffer buffer = new StringBuffer();
+        for (int j = 0; j < 16; j++) {
+            buffer.append((char)r.nextInt());
+        }
+        return buffer.toString();
+    }
+
+    static class RandomStringGenerator implements ResetableIterator<String> {
+        int i, n, seed;
+        Random random;
+
+        RandomStringGenerator(int seed, int n) {
+            i = 0;
+            this.seed = seed;
+            this.n = n;
+            reset();
+        }
+
+        public int size() {
+            return n;
+        }
+
+        public void reset() {
+            random = new Random(seed);
+        }
+
+        public boolean hasNext() {
+            return i < n;
+        }
+
+        public String next() {
+            i++;
+            return randomKey(random);
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    static class IntGenerator implements ResetableIterator<String> {
+        private int i, start, n;
+
+        IntGenerator(int n) {
+            this(0, n);
+        }
+
+        IntGenerator(int start, int n) {
+            this.start = start;
+            this.n = n;
+            reset();
+        }
+
+        public int size() {
+            return n - start;
+        }
+
+        public void reset() {
+            i = start;
+        }
+
+        public boolean hasNext() {
+            return i < n;
+        }
+
+        public String next() {
+            return Integer.toString(i++);
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    static class WordGenerator implements ResetableIterator<String> {
+        static int WORDS;
+
+        static {
+            try {
+                BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("/usr/share/dict/words")));
+                while (br.ready()) {
+                    br.readLine();
+                    WORDS++;
+                }
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        BufferedReader reader;
+        private int modulo;
+        private int skip;
+        String next;
+
+        WordGenerator(int skip, int modulo) {
+            this.skip = skip;
+            this.modulo = modulo;
+            reset();
+        }
+
+        public int size() {
+            return (1 + WORDS - skip) / modulo;
+        }
+
+        public void reset() {
+            try {
+                reader = new BufferedReader(new InputStreamReader(new FileInputStream("/usr/share/dict/words")));
+            } catch (FileNotFoundException e) {
+                throw new RuntimeException(e);
+            }
+            for (int i = 0; i < skip; i++) {
+                try {
+                    reader.readLine();
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+            next();
+        }
+
+        public boolean hasNext() {
+            return next != null;
+        }
+
+        public String next() {
+            try {
+                String s = next;
+                for (int i = 0; i < modulo; i++) {
+                    next = reader.readLine();
+                }
+                return s;
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Added: incubator/cassandra/trunk/test/org/apache/cassandra/utils/ResetableIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/org/apache/cassandra/utils/ResetableIterator.java?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/org/apache/cassandra/utils/ResetableIterator.java (added)
+++ incubator/cassandra/trunk/test/org/apache/cassandra/utils/ResetableIterator.java Fri Mar 27 02:43:46 2009
@@ -0,0 +1,9 @@
+package org.apache.cassandra.utils;
+
+import java.util.Iterator;
+
+public interface ResetableIterator<T> extends Iterator<T> {
+    public void reset();
+
+    int size();
+}

Added: incubator/cassandra/trunk/test/testng.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/testng.xml?rev=758992&view=auto
==============================================================================
--- incubator/cassandra/trunk/test/testng.xml (added)
+++ incubator/cassandra/trunk/test/testng.xml Fri Mar 27 02:43:46 2009
@@ -0,0 +1 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >



Mime
View raw message