cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r834912 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: config/DatabaseDescriptor.java service/StorageService.java
Date Wed, 11 Nov 2009 15:34:40 GMT
Author: jbellis
Date: Wed Nov 11 15:34:40 2009
New Revision: 834912

URL: http://svn.apache.org/viewvc?rev=834912&view=rev
Log:
generify AbstractReplicationStrategy construction.  patch by jbellis

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=834912&r1=834911&r2=834912&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Wed Nov 11 15:34:40 2009
@@ -24,6 +24,7 @@
 import org.apache.cassandra.db.marshal.UTF8Type;
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.locator.IEndPointSnitch;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.utils.FileUtils;
 import org.apache.cassandra.utils.XMLUtils;
 import org.apache.log4j.Logger;
@@ -87,7 +88,7 @@
 
     private static IEndPointSnitch endPointSnitch_;
 
-    private static Class replicaPlacementStrategyClass_;
+    private static Class<AbstractReplicationStrategy> replicaPlacementStrategyClass_;
 
     /* if the size of columns or super-columns are more than this, indexing will kick in
*/
     private static int columnIndexSizeInKB_;
@@ -418,7 +419,7 @@
             }
             try
             {
-                replicaPlacementStrategyClass_ = Class.forName(replicaPlacementStrategyClassName);
+                replicaPlacementStrategyClass_ = (Class<AbstractReplicationStrategy>)
Class.forName(replicaPlacementStrategyClassName);
             }
             catch (ClassNotFoundException e)
             {
@@ -655,7 +656,7 @@
         return endPointSnitch_;
     }
 
-    public static Class getReplicaPlacementStrategyClass()
+    public static Class<AbstractReplicationStrategy> getReplicaPlacementStrategyClass()
     {
         return replicaPlacementStrategyClass_;
     }

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=834912&r1=834911&r2=834912&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
Nov 11 15:34:40 2009
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
+import java.lang.reflect.Constructor;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.LinkedBlockingQueue;
@@ -227,11 +228,12 @@
         StageManager.registerStage(StorageService.readStage_,
                                    new MultiThreadedStage(StorageService.readStage_, DatabaseDescriptor.getConcurrentReaders()));
 
-        Class cls = DatabaseDescriptor.getReplicaPlacementStrategyClass();
+        Class<AbstractReplicationStrategy> cls = DatabaseDescriptor.getReplicaPlacementStrategyClass();
         Class [] parameterTypes = new Class[] { TokenMetadata.class, IPartitioner.class,
int.class, int.class};
         try
         {
-            replicationStrategy_ = (AbstractReplicationStrategy) cls.getConstructor(parameterTypes).newInstance(tokenMetadata_,
partitioner_, DatabaseDescriptor.getReplicationFactor(), DatabaseDescriptor.getStoragePort());
+            Constructor<AbstractReplicationStrategy> constructor = cls.getConstructor(parameterTypes);
+            replicationStrategy_ = constructor.newInstance(tokenMetadata_, partitioner_,
DatabaseDescriptor.getReplicationFactor(), DatabaseDescriptor.getStoragePort());
         }
         catch (Exception e)
         {



Mime
View raw message