cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Make creation of system_{auth, traces} keyspaces less fragile
Date Thu, 12 Mar 2015 00:16:34 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 87d56d125 -> 24915cd48


Make creation of system_{auth,traces} keyspaces less fragile

patch by Sam Tunnicliffe; reviewed by Aleksey Yeschenko for
CASSANDRA-8853


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/24915cd4
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/24915cd4
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/24915cd4

Branch: refs/heads/trunk
Commit: 24915cd48e9e13d99df4d08610e382d3c424dd35
Parents: 87d56d1
Author: Sam Tunnicliffe <sam@beobal.com>
Authored: Tue Mar 10 11:38:05 2015 +0000
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Wed Mar 11 17:16:12 2015 -0700

----------------------------------------------------------------------
 .../cassandra/service/StorageService.java       | 34 ++++++++++++++++----
 1 file changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/24915cd4/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 35c67c4..19e0a5a 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -51,9 +51,7 @@ import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.dht.Range;
-import org.apache.cassandra.exceptions.ConfigurationException;
-import org.apache.cassandra.exceptions.InvalidRequestException;
-import org.apache.cassandra.exceptions.UnavailableException;
+import org.apache.cassandra.exceptions.*;
 import org.apache.cassandra.gms.*;
 import org.apache.cassandra.io.sstable.SSTableDeletingTask;
 import org.apache.cassandra.io.sstable.SSTableLoader;
@@ -807,7 +805,7 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
 
         // if we don't have system_traces keyspace at this point, then create it manually
         if (Schema.instance.getKSMetaData(TraceKeyspace.NAME) == null)
-            MigrationManager.announceNewKeyspace(TraceKeyspace.definition(), 0, false);
+            maybeAddKeyspace(TraceKeyspace.definition());
 
         if (!isSurveyMode)
         {
@@ -872,14 +870,14 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
             // the ks exists with the only the legacy tables defined
             if (Schema.instance.getKSMetaData(AuthKeyspace.NAME) == null)
             {
-                MigrationManager.announceNewKeyspace(AuthKeyspace.definition(), 0, false);
+                maybeAddKeyspace(AuthKeyspace.definition());
             }
             else
             {
                 for (Map.Entry<String, CFMetaData> table : AuthKeyspace.definition().cfMetaData().entrySet())
                 {
                     if (Schema.instance.getCFMetaData(AuthKeyspace.NAME, table.getKey())
== null)
-                        MigrationManager.announceNewColumnFamily(table.getValue());
+                        maybeAddTable(table.getValue());
                 }
             }
         }
@@ -894,6 +892,30 @@ public class StorageService extends NotificationBroadcasterSupport implements
IE
         MigrationManager.instance.register(new AuthMigrationListener());
     }
 
+    private void maybeAddTable(CFMetaData cfm)
+    {
+        try
+        {
+            MigrationManager.announceNewColumnFamily(cfm);
+        }
+        catch (AlreadyExistsException e)
+        {
+            logger.debug("Attempted to create new table {}, but it already exists", cfm.cfName);
+        }
+    }
+
+    private void maybeAddKeyspace(KSMetaData ksm)
+    {
+        try
+        {
+            MigrationManager.announceNewKeyspace(ksm, 0, false);
+        }
+        catch (AlreadyExistsException e)
+        {
+            logger.debug("Attempted to create new keyspace {}, but it already exists", ksm.name);
+        }
+    }
+
     public boolean isJoined()
     {
         return joined;


Mime
View raw message