Author: ritchiem
Date: Mon Mar  9 16:03:45 2009
New Revision: 751722

URL: http://svn.apache.org/viewvc?rev=751722&view=rev
Log:
QPID-949 : Removed the deleteOnExit calls on all flowed entries, as this will 
increase our memory usage. Instead add a close method on the BackingStore that 
is called when the queue closes and clean up the backing then. Also moved the 
QueueHousekeeping thread stop to before we do any queue closing in the VHost. 
This will ensure that we are not causing any operations that might inadvertadly 
load a message, and so prevent the backing file from being deleted. This should 
of course now not occur as all getMessage() calls have been removed.

Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FlowableBaseQueueEntryList.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueBackingStore.java
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java?rev=751722&r1=751721&r2=751722&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStore.java
 Mon Mar  9 16:03:45 2009
@@ -28,6 +28,7 @@
 import org.apache.qpid.framing.ContentHeaderBody;
 import org.apache.qpid.framing.abstraction.ContentChunk;
 import org.apache.qpid.framing.abstraction.MessagePublishInfo;
+import org.apache.qpid.util.FileUtils;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -55,7 +56,6 @@
         MessageMetaData mmd;
 
         File handle = getFileHandle(messageId);
-        handle.deleteOnExit();
 
         ObjectInputStream input = null;
 
@@ -192,8 +192,6 @@
             _log.info("Unloading Message (ID:" + messageId + ")");
         }
 
-        handle.deleteOnExit();
-
         ObjectOutputStream writer = null;
         Exception error = null;
 
@@ -295,7 +293,6 @@
         if (!bin_dir.exists())
         {
             bin_dir.mkdirs();
-            bin_dir.deleteOnExit();
         }
 
         String id = bin_path + File.separator + messageId;
@@ -304,7 +301,7 @@
     }
 
     public void delete(Long messageId)
-    {        
+    {
         File handle = getFileHandle(messageId);
 
         if (handle.exists())
@@ -320,6 +317,15 @@
         }
     }
 
+    public void close()
+    {
+        _log.info("Closing Backing store at:" + _flowToDiskLocation);
+        if (!FileUtils.delete(new File(_flowToDiskLocation), true))
+        {
+            _log.error("Unable to fully delete backing store location");
+        }
+    }
+
     private class RecoverDataBuffer implements ContentChunk
     {
         private int _length;

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java?rev=751722&r1=751721&r2=751722&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FileQueueBackingStoreFactory.java
 Mon Mar  9 16:03:45 2009
@@ -56,6 +56,7 @@
 
         _flowToDiskLocation += File.separator + QUEUE_BACKING_DIR + 
File.separator + vHostName;
 
+        //Check the location we will create QUEUE_BACKING_DIR in.
         File root = new File(location);
         if (!root.exists())
         {
@@ -121,8 +122,7 @@
 
         _log.info("Creating Flow to Disk Store : " + store.getAbsolutePath());
         store.deleteOnExit();
-
-        if(!store.mkdir())
+        if (!store.mkdir())
         {
             throw new ConfigurationException("Unable to create Temporary Flow 
to Disk store:" + store.getAbsolutePath());
         }

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FlowableBaseQueueEntryList.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FlowableBaseQueueEntryList.java?rev=751722&r1=751721&r2=751722&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FlowableBaseQueueEntryList.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/FlowableBaseQueueEntryList.java
 Mon Mar  9 16:03:45 2009
@@ -236,6 +236,8 @@
             //Shutdown thread for inhaler.
             
ReferenceCountingExecutorService.getInstance().releaseExecutorService();
             
ReferenceCountingExecutorService.getInstance().releaseExecutorService();
+
+            _backingStore.close();
         }
     }
 

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueBackingStore.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueBackingStore.java?rev=751722&r1=751721&r2=751722&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueBackingStore.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/queue/QueueBackingStore.java
 Mon Mar  9 16:03:45 2009
@@ -31,4 +31,6 @@
     void unload(AMQMessage message) throws UnableToFlowMessageException;
 
     void delete(Long messageId);
+
+    void close();
 }

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java?rev=751722&r1=751721&r2=751722&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
 Mon Mar  9 16:03:45 2009
@@ -422,6 +422,12 @@
         //Stop Connections
         _connectionRegistry.close();
 
+        //Stop Housekeeping
+        if (_houseKeepingTimer != null)
+        {
+            _houseKeepingTimer.cancel();
+        }
+
         //Stop the Queues processing
         if (_queueRegistry != null)
         {
@@ -429,13 +435,7 @@
             {
                 queue.stop();
             }
-        }        
-
-        //Stop Housekeeping
-        if (_houseKeepingTimer != null)
-        {
-            _houseKeepingTimer.cancel();
-        }        
+        }
 
         //Close TransactionLog
         if (_transactionLog != null)



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to