activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1205168 - in /activemq/activemq-apollo/trunk: apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/ apollo-distro/src/main/descriptors/ apollo-leveldb/ apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leve...
Date Tue, 22 Nov 2011 21:05:44 GMT
Author: chirino
Date: Tue Nov 22 21:05:42 2011
New Revision: 1205168

URL: http://svn.apache.org/viewvc?rev=1205168&view=rev
Log:
Fallback to using a pure java implementation of the leveldb library if the JNI version is
not supported on the platform.

Modified:
    activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
    activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml
    activemq/activemq-apollo/trunk/apollo-leveldb/pom.xml
    activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/dto/LevelDBStoreDTO.java
    activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/leveldb/LevelDBClient.scala

Modified: activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala?rev=1205168&r1=1205167&r2=1205168&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-cli/src/main/scala/org/apache/activemq/apollo/cli/commands/Create.scala
Tue Nov 22 21:05:42 2011
@@ -251,7 +251,9 @@ class Create extends Action {
   }
 
   def store_config = {
-    if( can_load("org.fusesource.leveldbjni.JniDBFactory") ) {
+    if( can_load("org.apache.activemq.apollo.broker.store.leveldb.LevelDBStore")
+        && ( can_load("org.fusesource.leveldbjni.JniDBFactory")
+        || can_load("org.iq80.leveldb.impl.Iq80DBFactory"))) {
     """<!-- You can delete this element if you want to disable persistence for this virtual
host -->
     <leveldb_store directory="${apollo.base}/data"/>
     """

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml?rev=1205168&r1=1205167&r2=1205168&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml Tue Nov
22 21:05:42 2011
@@ -32,6 +32,7 @@
         <include>org.codehaus.jackson:jackson-mapper-asl</include>
         <include>org.codehaus.jackson:jackson-core-asl</include>
         <include>org.fusesource.leveldbjni:leveldbjni-all</include>
+        <include>org.iq80.leveldb:leveldb</include>
         
         <!-- security stuff -->
         <include>org.jasypt:jasypt</include>

Modified: activemq/activemq-apollo/trunk/apollo-leveldb/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-leveldb/pom.xml?rev=1205168&r1=1205167&r2=1205168&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-leveldb/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-leveldb/pom.xml Tue Nov 22 21:05:42 2011
@@ -41,11 +41,17 @@
       <artifactId>apollo-broker</artifactId>
       <version>1.0-SNAPSHOT</version>
     </dependency>
+
     <dependency>
       <groupId>org.fusesource.leveldbjni</groupId>
       <artifactId>leveldbjni-all</artifactId>
       <version>1.1-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.iq80.leveldb</groupId>
+      <artifactId>leveldb</artifactId>
+      <version>0.1-SNAPSHOT</version>
+    </dependency>
 
     <!-- Since we implement a jade template to display the LevelDB status -->
     <dependency>

Modified: activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/dto/LevelDBStoreDTO.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/dto/LevelDBStoreDTO.java?rev=1205168&r1=1205167&r2=1205168&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/dto/LevelDBStoreDTO.java
(original)
+++ activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/dto/LevelDBStoreDTO.java
Tue Nov 22 21:05:42 2011
@@ -73,6 +73,9 @@ public class LevelDBStoreDTO extends Sto
     @XmlAttribute(name="index_compression")
     public String index_compression;
 
+    @XmlAttribute(name="index_factory")
+    public String index_factory;
+
     @Override
     public boolean equals(Object o) {
         if (this == o) return true;
@@ -81,10 +84,8 @@ public class LevelDBStoreDTO extends Sto
 
         LevelDBStoreDTO that = (LevelDBStoreDTO) o;
 
-        if (directory != null ? !directory.equals(that.directory) : that.directory != null)
-            return false;
-        if (gc_interval != null ? !gc_interval.equals(that.gc_interval) : that.gc_interval
!= null)
-            return false;
+        if (directory != null ? !directory.equals(that.directory) : that.directory != null)
return false;
+        if (gc_interval != null ? !gc_interval.equals(that.gc_interval) : that.gc_interval
!= null) return false;
         if (index_block_restart_interval != null ? !index_block_restart_interval.equals(that.index_block_restart_interval)
: that.index_block_restart_interval != null)
             return false;
         if (index_block_size != null ? !index_block_size.equals(that.index_block_size) :
that.index_block_size != null)
@@ -97,16 +98,14 @@ public class LevelDBStoreDTO extends Sto
             return false;
         if (index_write_buffer_size != null ? !index_write_buffer_size.equals(that.index_write_buffer_size)
: that.index_write_buffer_size != null)
             return false;
-        if (log_size != null ? !log_size.equals(that.log_size) : that.log_size != null)
-            return false;
+        if (index_factory != null ? !index_factory.equals(that.index_factory) : that.index_factory
!= null) return false;
+        if (log_size != null ? !log_size.equals(that.log_size) : that.log_size != null) return
false;
         if (log_write_buffer_size != null ? !log_write_buffer_size.equals(that.log_write_buffer_size)
: that.log_write_buffer_size != null)
             return false;
         if (paranoid_checks != null ? !paranoid_checks.equals(that.paranoid_checks) : that.paranoid_checks
!= null)
             return false;
-        if (read_threads != null ? !read_threads.equals(that.read_threads) : that.read_threads
!= null)
-            return false;
-        if (sync != null ? !sync.equals(that.sync) : that.sync != null)
-            return false;
+        if (read_threads != null ? !read_threads.equals(that.read_threads) : that.read_threads
!= null) return false;
+        if (sync != null ? !sync.equals(that.sync) : that.sync != null) return false;
         if (verify_checksums != null ? !verify_checksums.equals(that.verify_checksums) :
that.verify_checksums != null)
             return false;
 
@@ -119,6 +118,7 @@ public class LevelDBStoreDTO extends Sto
         result = 31 * result + (directory != null ? directory.hashCode() : 0);
         result = 31 * result + (gc_interval != null ? gc_interval.hashCode() : 0);
         result = 31 * result + (read_threads != null ? read_threads.hashCode() : 0);
+        result = 31 * result + (index_factory != null ? index_factory.hashCode() : 0);
         result = 31 * result + (sync != null ? sync.hashCode() : 0);
         result = 31 * result + (paranoid_checks != null ? paranoid_checks.hashCode() : 0);
         result = 31 * result + (verify_checksums != null ? verify_checksums.hashCode() :
0);

Modified: activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/leveldb/LevelDBClient.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/leveldb/LevelDBClient.scala?rev=1205168&r1=1205167&r2=1205168&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/leveldb/LevelDBClient.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/leveldb/LevelDBClient.scala
Tue Nov 22 21:05:42 2011
@@ -38,6 +38,7 @@ import org.fusesource.hawtbuf.{Buffer, A
 import java.util.concurrent.atomic.{AtomicReference, AtomicLong}
 import org.apache.activemq.apollo.broker.store.MapEntryPB.Bean
 import org.apache.activemq.apollo.broker.store.leveldb.HelperTrait._
+import org.apache.activemq.apollo.broker.Broker
 
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -143,7 +144,7 @@ class LevelDBClient(store: LevelDBStore)
   var last_gc_duration = 0L
   var in_gc = false
   var gc_detected_log_usage = Map[Long, UsageCounter]()
-  var factory:DBFactory = org.fusesource.leveldbjni.JniDBFactory.factory
+  var factory:DBFactory = _
 
 
   def dirty_index_file = directory / ("dirty"+INDEX_SUFFIX)
@@ -162,6 +163,15 @@ class LevelDBClient(store: LevelDBStore)
   def start() = {
     import OptionSupport._
 
+    val factory_names = Option(config.index_factory).getOrElse("org.fusesource.leveldbjni.JniDBFactory,
org.iq80.leveldb.impl.Iq80DBFactory")
+    factory = factory_names.split("""(,|\s)+""").map(_.trim()).flatMap { name=>
+      try {
+        Some(Broker.class_loader.loadClass(name).newInstance().asInstanceOf[DBFactory])
+      } catch {
+        case x => None
+      }
+    }.headOption.getOrElse(throw new Exception("Could not load any of the index factory classes:
"+factory_names))
+
     sync = config.sync.getOrElse(true);
     verify_checksums = config.verify_checksums.getOrElse(false);
 



Mime
View raw message