cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r931202 - in /cassandra/trunk: src/java/org/apache/cassandra/avro/ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/migration/ src/java/org/apache/cassandra/service/ src/java/org/apach...
Date Tue, 06 Apr 2010 16:02:27 GMT
Author: gdusbabek
Date: Tue Apr  6 16:02:26 2010
New Revision: 931202

URL: http://svn.apache.org/viewvc?rev=931202&view=rev
Log:
switch to reading schema configuration from storage. Patch by Gary Dusbabek, reviewed by Jonthan
Ellis. CASSANDRA-827

Added:
    cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java
Modified:
    cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java
    cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java
    cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java
    cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/commitlog/CommitLogHeaderTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/service/ReadResponseResolverTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraDaemon.java Tue Apr  6 16:02:26
2010
@@ -75,6 +75,16 @@ public class CassandraDaemon {
                 }
             }
         });
+        
+        try
+        {
+            DatabaseDescriptor.loadSchemas();
+        }
+        catch (IOException e)
+        {
+            logger.error("Fatal exception during initialization", e);
+            System.exit(100);
+        }
 
         // initialize keyspaces
         for (String table : DatabaseDescriptor.getTables())

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=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Tue Apr 
6 16:02:26 2010
@@ -31,7 +31,9 @@ import org.apache.cassandra.dht.IPartiti
 import org.apache.cassandra.locator.IEndPointSnitch;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.UUIDGen;
 import org.apache.cassandra.utils.XMLUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -482,27 +484,18 @@ public class DatabaseDescriptor
             };
             KSMetaData systemMeta = new KSMetaData(Table.SYSTEM_TABLE, null, -1, null, systemCfDefs);
             tables.put(Table.SYSTEM_TABLE, systemMeta);
-            
-            // todo: if tables are defined in the system store, use those.  load from xml
otherwise.
-            readTablesFromXml();
-            
-            // todo: fill in repStrat and epSnitch when this table is set to replicate.
+                
             CFMetaData[] definitionCfDefs = new CFMetaData[]
             {
                 new CFMetaData(Table.DEFINITIONS, Migration.MIGRATIONS_CF, "Standard", new
TimeUUIDType(), null, "individual schema mutations", 0, 0),
                 new CFMetaData(Table.DEFINITIONS, Migration.SCHEMA_CF, "Standard", new UTF8Type(),
null, "current state of the schema", 0, 0)
             };
-            KSMetaData ksDefs = new KSMetaData(Table.DEFINITIONS, null, -1, null, definitionCfDefs);
-            tables.put(Table.DEFINITIONS, ksDefs);
+            tables.put(Table.DEFINITIONS, new KSMetaData(Table.DEFINITIONS, null, -1, null,
definitionCfDefs));
             
             // NOTE: make sure that all system CFMs defined by now. calling fixMaxId at this
point will set the base id
             // to a value that leaves room for future system cfms.
             CFMetaData.fixMaxId();
             
-            // todo: if tables are defined in the system store, use those.  load from xml
otherwise.
-            readTablesFromXml();
-            CFMetaData.fixMaxId();
-            
             /* Load the seeds for node contact points */
             String[] seedsxml = xmlUtils.getNodeValues("/Storage/Seeds/Seed");
             if (seedsxml.length <= 0)
@@ -525,8 +518,43 @@ public class DatabaseDescriptor
             throw new RuntimeException(e);
         }
     }
+    
+    public static void loadSchemas() throws IOException
+    {
+        // we can load tables from local storage if a version is set in the system table
and that acutally maps to
+        // real data in the definitions table.  If we do end up loading from xml, store the
defintions so that we
+        // 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.");
+        else
+        {
+            logger.info("Loading schema version " + uuid.toString());
+            Collection<KSMetaData> tableDefs = DefsTable.loadFromStorage(uuid);   
+            for (KSMetaData def : tableDefs)
+            {
+                DatabaseDescriptor.setTableDefinition(def, uuid);
+                // this part creates storage and jmx objects.
+                Table.open(def.name);
+            }
+            
+            // since we loaded definitions from local storage, log a warning if definitions
exist in xml.
+            try
+            {
+                XMLUtils xmlUtils = new XMLUtils(configFileName);
+                NodeList tablesxml = xmlUtils.getRequestedNodeList("/Storage/Keyspaces/Keyspace");
+                if (tablesxml.getLength() > 0)
+                    logger.warn("Schema definitions were defined both locally and in storage-conf.xml.
Definitions in storage-conf.xml were ignored.");
+            }
+            catch (Exception ex)
+            {
+                logger.warn("Problem checking for schema defintions in xml", ex);
+            }
+        }
+        CFMetaData.fixMaxId();
+    }
 
-    private static void readTablesFromXml() throws ConfigurationException
+    public static void readTablesFromXml() throws ConfigurationException
     {
         XMLUtils xmlUtils = null;
         try
@@ -730,6 +758,8 @@ public class DatabaseDescriptor
             ex.initCause(e);
             throw ex;
         }
+        if (DatabaseDescriptor.listenAddress != null)
+            defsVersion = UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress());
     }
 
     public static IAuthenticator getAuthenticator()
@@ -1118,10 +1148,9 @@ public class DatabaseDescriptor
     // process of mutating an individual keyspace, rather than setting manually here.
     public static void setTableDefinition(KSMetaData ksm, UUID newVersion)
     {
-        // at some point, this assert will be valid, because defsVersion_ will be set when
the table defs are loaded.
-//        assert newVersion != null && !newVersion.equals(defsVersion_) &&
defsVersion_.compareTo(newVersion) < 0;
         tables.put(ksm.name, ksm);
         DatabaseDescriptor.defsVersion = newVersion;
+        StorageService.instance.initReplicationStrategy(ksm.name);
     }
     
     public static void clearTableDefinition(KSMetaData ksm, UUID newVersion)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java Tue Apr  6 16:02:26 2010
@@ -25,6 +25,7 @@ import org.apache.cassandra.db.filter.Qu
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.filter.SliceQueryFilter;
 import org.apache.cassandra.db.migration.Migration;
+import org.apache.cassandra.utils.UUIDGen;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -50,6 +51,10 @@ public class DefsTable
             rm.add(new QueryPath(Migration.SCHEMA_CF, null, ks.name.getBytes()), KSMetaData.serialize(ks),
now);
         }
         rm.apply();
+        
+        rm = new RowMutation(Table.DEFINITIONS, Migration.LAST_MIGRATION_KEY);
+        rm.add(new QueryPath(Migration.SCHEMA_CF, null, Migration.LAST_MIGRATION_KEY.getBytes()),
UUIDGen.decompose(version), now);
+        rm.apply();
     }
 
     /** loads a version of keyspace definitions from storage */

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java Tue Apr  6 16:02:26
2010
@@ -145,7 +145,7 @@ public abstract class Migration
         ColumnFamilyStore cfStore = defs.getColumnFamilyStore(SCHEMA_CF);
         QueryFilter filter = QueryFilter.getNamesFilter(LAST_MIGRATION_KEY, new QueryPath(SCHEMA_CF),
LAST_MIGRATION_KEY.getBytes());
         ColumnFamily cf = cfStore.getColumnFamily(filter);
-        if (cf.getColumnNames().size() == 0)
+        if (cf == null || cf.getColumnNames().size() == 0)
             return null;
         else
             return UUIDGen.makeType1UUID(cf.getColumn(LAST_MIGRATION_KEY.getBytes()).value());

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Tue Apr  6 16:02:26
2010
@@ -33,9 +33,11 @@ import javax.management.*;
 
 import com.google.common.collect.Multimaps;
 import org.apache.cassandra.concurrent.*;
+import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.commitlog.CommitLog;
+import org.apache.cassandra.db.migration.Migration;
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.gms.*;
 import org.apache.cassandra.io.DeletionService;
@@ -47,6 +49,7 @@ import org.apache.cassandra.streaming.*;
 import org.apache.cassandra.thrift.ConsistencyLevel;
 import org.apache.cassandra.thrift.UnavailableException;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.UUIDGen;
 import org.apache.cassandra.utils.WrappedRunnable;
 import org.apache.cassandra.io.util.FileUtils;
 
@@ -1568,7 +1571,39 @@ public class StorageService implements I
        
         setMode("Node is drained", true);
     }
-    
+
+    /**
+     * load schema from xml. This can only be done on a fresh system.
+     * @throws ConfigurationException
+     * @throws IOException
+     */
+    public void loadSchemaFromXML() throws ConfigurationException, IOException
+    {
+        // blow up if there is a schema saved.
+        if (DatabaseDescriptor.getDefsVersion().timestamp() > 0 || Migration.getLastMigrationId()
!= null)
+            throw new ConfigurationException("Cannot load from XML on top of pre-existing
schemas.");
+        DatabaseDescriptor.readTablesFromXml();
+        assert DatabaseDescriptor.getDefsVersion().timestamp() > 0;
+        DefsTable.dumpToStorage(DatabaseDescriptor.getDefsVersion());
+        // flush system and definition tables.
+        Collection<Future> flushers = new ArrayList<Future>();
+        flushers.addAll(Table.open(Table.SYSTEM_TABLE).flush());
+        flushers.addAll(Table.open(Table.DEFINITIONS).flush());
+        for (Future f : flushers)
+        {
+            try
+            {
+                f.get();
+            }
+            catch (Exception e)
+            {
+                ConfigurationException ce = new ConfigurationException(e.getMessage());
+                ce.initCause(e);
+                throw ce;
+            }
+        }
+        
+    }
 
     // Never ever do this at home. Used by tests.
     Map<String, AbstractReplicationStrategy> setReplicationStrategyUnsafe(Map<String,
AbstractReplicationStrategy> replacement)

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java Tue Apr
 6 16:02:26 2010
@@ -26,6 +26,7 @@ import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.FutureTask;
 
+import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.dht.Range;
 import java.net.InetAddress;
 
@@ -169,4 +170,10 @@ public interface StorageServiceMBean
 
     /** makes node unavailable for writes, flushes memtables and replays commitlog. */
     public void drain() throws IOException, InterruptedException, ExecutionException;
+
+    /**
+     * Introduced in 0.7 to allow nodes to load their existing xml defined schemas.
+     * @todo: deprecate in 0.7+1, remove in 0.7+2.
+     */ 
+    public void loadSchemaFromXML() throws ConfigurationException, IOException;
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraDaemon.java Tue Apr  6 16:02:26
2010
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.InetAddress;
 
+import org.apache.cassandra.config.ConfigurationException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -85,6 +86,16 @@ public class CassandraDaemon
             }
         });
 
+        try
+        {
+            DatabaseDescriptor.loadSchemas();
+        }
+        catch (IOException e)
+        {
+            logger.error("Fatal exception during initialization", e);
+            System.exit(100);
+        }
+        
         // initialize keyspaces
         for (String table : DatabaseDescriptor.getTables())
         {

Modified: cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java Tue Apr  6 16:02:26
2010
@@ -29,7 +29,7 @@ import org.apache.cassandra.io.util.File
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class CleanupHelper
+public class CleanupHelper extends SchemaLoader
 {
     private static Logger logger = LoggerFactory.getLogger(CleanupHelper.class);
 

Added: cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java?rev=931202&view=auto
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java (added)
+++ cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java Tue Apr  6 16:02:26 2010
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra;
+
+import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.junit.BeforeClass;
+
+public class SchemaLoader
+{
+    // todo: when xml is fully deprecated, this method should be changed to manually load
a few table definitions into
+    // the definitions keyspace.
+    @BeforeClass
+    public static void loadSchemaFromXml()
+    {
+        try
+        {
+            DatabaseDescriptor.readTablesFromXml();
+        }
+        catch (ConfigurationException e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+}

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java Tue Apr  6 16:02:26
2010
@@ -24,13 +24,14 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.TreeMap;
 
+import org.apache.cassandra.SchemaLoader;
 import org.junit.Test;
 
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.db.filter.QueryPath;
 import static org.apache.cassandra.Util.column;
 
-public class ColumnFamilyTest
+public class ColumnFamilyTest extends SchemaLoader
 {
     // TODO test SuperColumns
 

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java Tue Apr  6 16:02:26 2010
@@ -59,12 +59,6 @@ import java.util.concurrent.ExecutionExc
 
 public class DefsTest extends CleanupHelper
 {
-    @Before
-    public void setup()
-    {
-        // just something to ensure that DD has been initialized.
-        DatabaseDescriptor.getNonSystemTables();
-    }
 
     @Test
     public void saveAndRestore() throws IOException
@@ -105,10 +99,10 @@ public class DefsTest extends CleanupHel
     public void testMigrations() throws IOException, ConfigurationException
     {
         // do a save. make sure it doesn't mess with the defs version.
-        assert DatabaseDescriptor.getDefsVersion() == null;
+        UUID prior = DatabaseDescriptor.getDefsVersion();
         UUID ver0 = UUIDGen.makeType1UUIDFromHost(FBUtilities.getLocalAddress());
         DefsTable.dumpToStorage(ver0);
-        assert DatabaseDescriptor.getDefsVersion() == null;
+        assert DatabaseDescriptor.getDefsVersion().equals(prior);
         
         // add a cf.
         CFMetaData newCf1 = new CFMetaData("Keyspace1", "MigrationCf_1", "Standard", new
UTF8Type(), null, "Migration CF ", 0, 0);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java Tue Apr  6 16:02:26
2010
@@ -26,13 +26,14 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 
+import org.apache.cassandra.SchemaLoader;
 import org.apache.commons.lang.ArrayUtils;
 import org.junit.Test;
 
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 
-public class ReadMessageTest
+public class ReadMessageTest extends SchemaLoader
 {
     @Test
     public void testMakeReadMessage() throws IOException

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/RowTest.java Tue Apr  6 16:02:26 2010
@@ -20,13 +20,14 @@ package org.apache.cassandra.db;
 
 import java.util.Arrays;
 
+import org.apache.cassandra.SchemaLoader;
 import org.junit.Test;
 
 import static junit.framework.Assert.assertEquals;
 import org.apache.cassandra.db.marshal.AsciiType;
 import static org.apache.cassandra.Util.column;
 
-public class RowTest
+public class RowTest extends SchemaLoader
 {
     @Test
     public void testDiffColumnFamily()

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/commitlog/CommitLogHeaderTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/commitlog/CommitLogHeaderTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/commitlog/CommitLogHeaderTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/commitlog/CommitLogHeaderTest.java Tue
Apr  6 16:02:26 2010
@@ -20,7 +20,9 @@ package org.apache.cassandra.db.commitlo
 
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.ConfigurationException;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.utils.Pair;
 import org.junit.Before;
@@ -34,14 +36,8 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
-public class CommitLogHeaderTest
+public class CommitLogHeaderTest extends SchemaLoader
 {
-    @Before
-    public void setup()
-    {
-        // data definitions must be loaded.
-        DatabaseDescriptor.getTables();
-    }
     
     @Test
     public void testEmptyHeader()

Modified: cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java Tue
Apr  6 16:02:26 2010
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.gms.ApplicationState;
 import org.apache.cassandra.service.StorageServiceAccessor;
@@ -40,7 +41,7 @@ import org.apache.cassandra.service.Stor
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
-public class RackUnawareStrategyTest
+public class RackUnawareStrategyTest extends SchemaLoader
 {
     @Test
     public void tryBogusTable()

Modified: cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
(original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java
Tue Apr  6 16:02:26 2010
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertNot
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 
+import org.apache.cassandra.config.ConfigurationException;
+import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.thrift.Cassandra;
 import org.apache.cassandra.thrift.ColumnOrSuperColumn;
 import org.apache.cassandra.thrift.ColumnPath;
@@ -62,12 +64,13 @@ public class EmbeddedCassandraServiceTes
      * @throws InterruptedException
      */
     @BeforeClass
-    public static void setup() throws TTransportException, IOException, InterruptedException
+    public static void setup() throws TTransportException, IOException, InterruptedException,
ConfigurationException
     {
 
         // Tell cassandra where the configuration files are.
         // Use the test configuration file.
         System.setProperty("storage-config", "test/conf");
+        DatabaseDescriptor.readTablesFromXml();
 
         cassandra = new EmbeddedCassandraService();
         cassandra.init();

Modified: cassandra/trunk/test/unit/org/apache/cassandra/service/ReadResponseResolverTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/service/ReadResponseResolverTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/service/ReadResponseResolverTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/service/ReadResponseResolverTest.java Tue
Apr  6 16:02:26 2010
@@ -23,6 +23,7 @@ package org.apache.cassandra.service;
 
 import java.util.Arrays;
 
+import org.apache.cassandra.SchemaLoader;
 import org.junit.Test;
 
 import org.apache.cassandra.db.ColumnFamily;
@@ -31,7 +32,7 @@ import static org.apache.cassandra.db.Ta
 import static org.apache.cassandra.Util.column;
 import static junit.framework.Assert.assertNull;
 
-public class ReadResponseResolverTest
+public class ReadResponseResolverTest extends SchemaLoader
 {
     @Test
     public void testResolveSupersetNewer()

Modified: cassandra/trunk/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/streaming/BootstrapTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/streaming/BootstrapTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/streaming/BootstrapTest.java Tue Apr  6
16:02:26 2010
@@ -26,12 +26,13 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.io.sstable.SSTable;
 
 import org.junit.Test;
 
-public class BootstrapTest
+public class BootstrapTest extends SchemaLoader
 {
     @Test
     public void testGetNewNames() throws IOException

Modified: cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java Tue Apr  6
16:02:26 2010
@@ -23,6 +23,8 @@ import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.util.Arrays;
+
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.ColumnFamily;
 import org.apache.cassandra.db.filter.NamesQueryFilter;
@@ -42,7 +44,7 @@ import org.json.simple.JSONValue;
 import org.json.simple.parser.ParseException;
 import org.junit.Test;
 
-public class SSTableExportTest
+public class SSTableExportTest extends SchemaLoader
 {
     @Test
     public void testEnumeratekeys() throws IOException

Modified: cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java?rev=931202&r1=931201&r2=931202&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java Tue Apr  6
16:02:26 2010
@@ -21,6 +21,8 @@ package org.apache.cassandra.tools;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
+
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.db.ColumnFamily;
 import org.apache.cassandra.db.IColumn;
@@ -33,7 +35,7 @@ import static org.apache.cassandra.io.ss
 import org.json.simple.parser.ParseException;
 import org.junit.Test;
 
-public class SSTableImportTest
+public class SSTableImportTest extends SchemaLoader
 {   
     @Test
     public void testImportSimpleCf() throws IOException, ParseException



Mime
View raw message