activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1435245 - in /activemq/activemq-apollo/trunk: apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/ apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/ apollo-web/src/main/scala/org/apache/activem...
Date Fri, 18 Jan 2013 16:50:44 GMT
Author: chirino
Date: Fri Jan 18 16:50:44 2013
New Revision: 1435245

URL: http://svn.apache.org/viewvc?rev=1435245&view=rev
Log:
Fix for APLO-245: The LevelDB store does not seem to get cleaned/compacted

Posting to '/virtual-hosts/{id}/store/action/compact' will now compact the store.

Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/Store.scala
    activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/Store.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/Store.scala?rev=1435245&r1=1435244&r2=1435245&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/Store.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/store/Store.scala
Fri Jan 18 16:50:44 2013
@@ -199,4 +199,10 @@ trait Store extends ServiceTrait {
    * Imports a previous export from the input stream.
    */
   def import_data(is:InputStream, cb:(Option[String])=>Unit):Unit
+
+  /**
+   * Compacts the data in the store.
+   */
+  def compact(callback: =>Unit) = callback
+
 }
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala?rev=1435245&r1=1435244&r2=1435245&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-leveldb/src/main/scala/org/apache/activemq/apollo/broker/store/leveldb/LevelDBStore.scala
Fri Jan 18 16:50:44 2013
@@ -31,6 +31,9 @@ import java.io._
 import org.apache.activemq.apollo.web.resources.ViewHelper
 import org.fusesource.hawtbuf.Buffer
 import FileSupport._
+import org.apache.activemq.apollo.broker.store.leveldb.LevelDBClient._
+import org.apache.activemq.apollo.broker.store.QueueRecord
+
 /**
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
@@ -321,4 +324,14 @@ class LevelDBStore(val config: LevelDBSt
     cb(client.import_data(is))
   }
 
+  /**
+   * Compacts the data in the store.
+   */
+  override def compact(callback: => Unit) = write_executor {
+    info("Compacting '%s'", toString)
+    client.index.compact_needed = true
+    client.gc
+    info("'%s' compaction completed", toString)
+    callback
+  }
 }

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala?rev=1435245&r1=1435244&r2=1435245&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
Fri Jan 18 16:50:44 2013
@@ -427,6 +427,26 @@ class BrokerResource() extends Resource 
     }
   }
 
+  @POST @Path("/virtual-hosts/{id}/store/action/compact")
+  @ApiOperation(value = "Compacts the store.")
+  @Produces(Array("text/html;qs=5"))
+  def store_compact(@PathParam("id") id : String):Unit = {
+    with_virtual_host(id) { host =>
+      admining(host) {
+        if(host.store!=null) {
+          val rc = FutureResult[Unit]()
+          host.store.compact {
+            rc(Success(()))
+          }
+          rc
+        } else {
+          result(NOT_FOUND)
+        }
+      }
+    }
+  }
+
+
   class JosqlHelper {
 
     def get(o:AnyRef, name:String):AnyRef = {



Mime
View raw message