You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2010/07/07 06:19:29 UTC
svn commit: r961206 - in /activemq/sandbox/activemq-apollo-actor:
activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/
activemq-stomp/src/main/scala/org/apache/activemq/apollo/stomp/
Author: chirino
Date: Wed Jul 7 04:19:29 2010
New Revision: 961206
URL: http://svn.apache.org/viewvc?rev=961206&view=rev
Log:
adding HawtDBMemoryPool impl
and fixing compile issue wiht StompWireFormat
Added:
activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPool.scala
Modified:
activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPoolSPI.scala
activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompWireFormat.scala
Added: activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPool.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPool.scala?rev=961206&view=auto
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPool.scala (added)
+++ activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPool.scala Wed Jul 7 04:19:29 2010
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.broker.store.hawtdb
+
+import org.fusesource.hawtdispatch.BaseRetained
+import org.fusesource.hawtdb.api.Paged.SliceType
+import org.apache.activemq.apollo.{MemoryAllocation, MemoryPool}
+import java.nio.ByteBuffer
+import org.fusesource.hawtdb.api.PageFileFactory
+import java.io.File
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+class HawtDBMemoryPool(val file:File) extends MemoryPool {
+
+ private val pageFilefactory = new PageFileFactory()
+ private def pageFile = pageFilefactory.getPageFile
+
+ def stop = stop(null)
+ def start = start(null)
+
+ def stop(onComplete: Runnable) = {
+ pageFilefactory.close
+ file.delete
+ if( onComplete!=null ) {
+ onComplete.run
+ }
+ }
+
+ def start(onComplete: Runnable) = {
+ file.delete
+ pageFilefactory.setFile(file);
+ pageFilefactory.setHeaderSize(0);
+ pageFilefactory.setPageSize(1024)
+ pageFilefactory.open
+ if( onComplete!=null ) {
+ onComplete.run
+ }
+ }
+
+ class HawtMemoryAllocation(page:Int, page_count:Int, alloc_size:Int, original:ByteBuffer, slice:ByteBuffer) extends BaseRetained with MemoryAllocation {
+ def size = alloc_size
+ def buffer = slice
+
+ override def dispose = {
+ pageFile.unslice(original)
+ pageFile.allocator.free(page, page_count)
+ }
+ }
+
+ def alloc(alloc_size: Int) = {
+ val page_count: Int = pageFile.pages(alloc_size)
+ val page = pageFile.allocator.alloc(page_count)
+ val original = pageFile.slice(SliceType.READ_WRITE, page, page_count)
+
+ original.limit(original.position+alloc_size)
+
+ val slice = original.slice
+ new HawtMemoryAllocation(page, page_count, alloc_size, original, slice)
+ }
+}
\ No newline at end of file
Modified: activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPoolSPI.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPoolSPI.scala?rev=961206&r1=961205&r2=961206&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPoolSPI.scala (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-hawtdb/src/main/scala/org/apache/activemq/broker/store/hawtdb/HawtDBMemoryPoolSPI.scala Wed Jul 7 04:19:29 2010
@@ -38,7 +38,7 @@ class HawtDBMemoryPoolSPI extends Memory
def create(config: String) = {
if( config.startsWith(prefix) ) {
val file = new File(config.substring(prefix.length))
- // new HawtDBMemoryPool(file)
+ new HawtDBMemoryPool(file)
null
} else {
null
Modified: activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompWireFormat.scala
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompWireFormat.scala?rev=961206&r1=961205&r2=961206&view=diff
==============================================================================
--- activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompWireFormat.scala (original)
+++ activemq/sandbox/activemq-apollo-actor/activemq-stomp/src/main/scala/org/apache/activemq/apollo/stomp/StompWireFormat.scala Wed Jul 7 04:19:29 2010
@@ -229,7 +229,7 @@ class StompWireFormat extends WireFormat
}
- def flush():BufferState = {
+ def flush():WireFormat.BufferState = {
// if we have a pending write that is being sent over the socket...
if ( write_buffer.remaining() != 0 ) {