cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r788145 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: db/CalloutManager.java db/DBManager.java db/RecoveryManager.java db/SystemTable.java db/Table.java service/CassandraDaemon.java service/StorageService.java
Date Wed, 24 Jun 2009 19:25:17 GMT
Author: jbellis
Date: Wed Jun 24 19:25:17 2009
New Revision: 788145

URL: http://svn.apache.org/viewvc?rev=788145&view=rev
Log:
DBManager obscures rather than clarifies what is going on.  Remove it.

At some point we stopped calling DBManager.instance(), so Table.onStart was
not getting called.  Move that into CassandraDaemon so we don't rely on a side
effect to run it.

patch by jbellis; reviewed by Jun Rao for CASSANDRA-235

Removed:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/DBManager.java
Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CalloutManager.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RecoveryManager.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CalloutManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CalloutManager.java?rev=788145&r1=788144&r2=788145&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CalloutManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CalloutManager.java Wed Jun
24 19:25:17 2009
@@ -107,7 +107,7 @@
      * 
      * @throws IOException
      */
-    void onStart() throws IOException
+    public void onStart() throws IOException
     {
     	String location = DatabaseDescriptor.getCalloutLocation();
     	if ( location == null )

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RecoveryManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RecoveryManager.java?rev=788145&r1=788144&r2=788145&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RecoveryManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/RecoveryManager.java Wed Jun
24 19:25:17 2009
@@ -35,7 +35,7 @@
     private static RecoveryManager instance_;
     private static Logger logger_ = Logger.getLogger(RecoveryManager.class);
 
-    synchronized static RecoveryManager instance() throws IOException
+    public synchronized static RecoveryManager instance() throws IOException
     {
         if (instance_ == null)
         {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java?rev=788145&r1=788144&r2=788145&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java Wed Jun 24
19:25:17 2009
@@ -66,7 +66,7 @@
      * columns namely "Token" and "Generation". This is the token that
      * gets gossiped around and the generation info is used for FD.
     */
-    public static DBManager.StorageMetadata initMetadata() throws IOException
+    public static StorageMetadata initMetadata() throws IOException
     {
         /* Read the system table to retrieve the storage ID and the generation */
         Table table = Table.open(Table.SYSTEM_TABLE);
@@ -84,7 +84,7 @@
             cf.addColumn(new Column(GENERATION, BasicUtilities.intToByteArray(generation))
);
             rm.add(cf);
             rm.apply();
-            return new DBManager.StorageMetadata(token, generation);
+            return new StorageMetadata(token, generation);
         }
 
         /* we crashed and came back up need to bump generation # */
@@ -100,6 +100,33 @@
         cf.addColumn(generation2);
         rm.add(cf);
         rm.apply();
-        return new DBManager.StorageMetadata(token, gen);
+        return new StorageMetadata(token, gen);
+    }
+
+    public static class StorageMetadata
+    {
+        private Token myToken;
+        private int generation_;
+
+        StorageMetadata(Token storageId, int generation)
+        {
+            myToken = storageId;
+            generation_ = generation;
+        }
+
+        public Token getStorageId()
+        {
+            return myToken;
+        }
+
+        public void setStorageId(Token storageId)
+        {
+            myToken = storageId;
+        }
+
+        public int getGeneration()
+        {
+            return generation_;
+        }
     }
 }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=788145&r1=788144&r2=788145&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Wed Jun 24 19:25:17
2009
@@ -375,17 +375,12 @@
         return sb.toString();
     }
 
-    void onStart() throws IOException
+    public void onStart() throws IOException
     {
-        /* Cache the callouts if any */
-        CalloutManager.instance().onStart();
-        Set<String> columnFamilies = tableMetadata_.getColumnFamilies();
-        for ( String columnFamily : columnFamilies )
+        for (String columnFamily : tableMetadata_.getColumnFamilies())
         {
-            ColumnFamilyStore cfStore = columnFamilyStores_.get( columnFamily );
-            if ( cfStore != null )
-                cfStore.onStart();
-        }         
+            columnFamilyStores_.get(columnFamily).onStart();
+        }
     }
     
     /** 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java?rev=788145&r1=788144&r2=788145&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraDaemon.java Wed
Jun 24 19:25:17 2009
@@ -21,6 +21,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.util.Set;
 
 import org.apache.log4j.Logger;
 import org.apache.thrift.protocol.TBinaryProtocol;
@@ -32,6 +33,9 @@
 import org.apache.thrift.TProcessorFactory;
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.db.Table;
+import org.apache.cassandra.db.RecoveryManager;
+import org.apache.cassandra.db.CalloutManager;
 
 /**
  * This class supports two methods for creating a Cassandra node daemon, 
@@ -65,7 +69,22 @@
                 }
             }
         });
-        
+
+        // initialize stuff
+        CalloutManager.instance().onStart();
+
+        Set<String> tables = DatabaseDescriptor.getTableToColumnFamilyMap().keySet();
+        for (String table : tables)
+        {
+            Table tbl = Table.open(table);
+            tbl.onStart();
+        }
+
+        // replay the log if necessary
+        RecoveryManager recoveryMgr = RecoveryManager.instance();
+        recoveryMgr.doRecovery();
+
+        // now we start listening for clients
         CassandraServer peerStorageServer = new CassandraServer();
         peerStorageServer.start();
         Cassandra.Processor processor = new Cassandra.Processor(peerStorageServer);

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=788145&r1=788144&r2=788145&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Wed
Jun 24 19:25:17 2009
@@ -174,7 +174,7 @@
 
     /* This abstraction maintains the token/endpoint metadata information */
     private TokenMetadata tokenMetadata_ = new TokenMetadata();
-    private DBManager.StorageMetadata storageMetadata_;
+    private SystemTable.StorageMetadata storageMetadata_;
 
     /* Timer is used to disseminate load information */
     private Timer loadTimer_ = new Timer(false);



Mime
View raw message