[jboss-cvs] JBoss Messaging SVN: r5550 - in trunk: src/main/org/jboss/messaging/core/paging/impl and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 19 18:55:58 EST 2008
Author: clebert.suconic at jboss.com
Date: 2008-12-19 18:55:57 -0500 (Fri, 19 Dec 2008)
New Revision: 5550
Modified:
trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java
trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java
trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
Log:
Loading page-stores from existing directories
Modified: trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-12-19 17:11:39 UTC (rev 5549)
+++ trunk/src/main/org/jboss/messaging/core/paging/PagingManager.java 2008-12-19 23:55:57 UTC (rev 5550)
@@ -165,4 +165,10 @@
*/
void startGlobalDepage();
+ /**
+ * Reload previously created PagingStores into memory
+ * @throws Exception
+ */
+ void reloadStores() throws Exception;
+
}
Modified: trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java 2008-12-19 17:11:39 UTC (rev 5549)
+++ trunk/src/main/org/jboss/messaging/core/paging/PagingStoreFactory.java 2008-12-19 23:55:57 UTC (rev 5550)
@@ -22,6 +22,7 @@
package org.jboss.messaging.core.paging;
+import java.util.List;
import java.util.concurrent.Executor;
import org.jboss.messaging.core.persistence.StorageManager;
@@ -44,8 +45,10 @@
void stop() throws InterruptedException;
void setPagingManager(PagingManager manager);
-
+
void setStorageManager(StorageManager storageManager);
void setPostOffice(PostOffice office);
+
+ List<SimpleString> getStoredDestinations() throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-12-19 17:11:39 UTC (rev 5549)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingManagerImpl.java 2008-12-19 23:55:57 UTC (rev 5550)
@@ -23,6 +23,7 @@
package org.jboss.messaging.core.paging.impl;
import java.util.Collection;
+import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -125,7 +126,20 @@
{
this.globalMode.set(globalMode);
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.messaging.core.paging.PagingManager#reloadStores()
+ */
+ public void reloadStores() throws Exception
+ {
+ List<SimpleString> destinations = pagingSPI.getStoredDestinations();
+ for (SimpleString dest: destinations)
+ {
+ createPageStore(dest);
+ }
+ }
+
/**
* @param destination
* @return
Modified: trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java 2008-12-19 17:11:39 UTC (rev 5549)
+++ trunk/src/main/org/jboss/messaging/core/paging/impl/PagingStoreFactoryNIO.java 2008-12-19 23:55:57 UTC (rev 5550)
@@ -22,20 +22,25 @@
package org.jboss.messaging.core.paging.impl;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.jboss.messaging.core.journal.SequentialFileFactory;
import org.jboss.messaging.core.journal.impl.NIOSequentialFileFactory;
+import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.paging.PagingManager;
import org.jboss.messaging.core.paging.PagingStore;
import org.jboss.messaging.core.paging.PagingStoreFactory;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.PostOffice;
+import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.util.Base64;
import org.jboss.messaging.util.JBMThreadFactory;
@@ -51,6 +56,7 @@
public class PagingStoreFactoryNIO implements PagingStoreFactory
{
// Constants -----------------------------------------------------
+ private static final Logger log = Logger.getLogger(PagingStoreFactoryNIO.class);
// Attributes ----------------------------------------------------
@@ -128,7 +134,42 @@
{
this.postOffice = postOffice;
}
+
+ public List<SimpleString> getStoredDestinations() throws Exception
+ {
+ File pageDirectory = new File(directory);
+
+ File[] files = pageDirectory.listFiles();
+
+ if (files == null)
+ {
+ return Collections.<SimpleString>emptyList();
+ }
+ else
+ {
+
+ ArrayList<SimpleString> filesReturn = new ArrayList<SimpleString>(files.length);
+
+ for (File file: files)
+ {
+ if (file.isDirectory())
+ {
+ try
+ {
+ filesReturn.add(new SimpleString(Base64.decode(file.getName(), Base64.URL_SAFE)));
+ }
+ catch (Exception e)
+ {
+ log.warn("Invalid encoding on directory " + file.getCanonicalPath(), e);
+ }
+ }
+ }
+
+ return filesReturn;
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-12-19 17:11:39 UTC (rev 5549)
+++ trunk/src/main/org/jboss/messaging/core/postoffice/impl/PostOfficeImpl.java 2008-12-19 23:55:57 UTC (rev 5550)
@@ -214,8 +214,6 @@
public synchronized boolean addDestination(final SimpleString address, final boolean durable) throws Exception
{
- pagingManager.createPageStore(address);
-
boolean added = addressManager.addDestination(address);
if (added)
@@ -281,8 +279,6 @@
storageManager.addBinding(binding);
}
- pagingManager.createPageStore(address);
-
return binding;
}
@@ -533,9 +529,6 @@
queues.put(binding.getQueue().getPersistenceID(), binding.getQueue());
}
- preInitPageDestinations();
-
-
Map<SimpleString, List<Pair<SimpleString, Long>>> duplicateIDMap = new HashMap<SimpleString, List<Pair<SimpleString, Long>>>();
storageManager.loadMessageJournal(this, queues, resourceManager, duplicateIDMap);
@@ -552,24 +545,13 @@
}
}
+
// This is necessary as if the server was previously stopped while a depage was being executed,
// it needs to resume the depage process on those destinations
+ pagingManager.reloadStores();
pagingManager.startGlobalDepage();
}
- /**
- * We need to pre-initialize already existent destinations on loading, or resuming Depage after restart won't work
- * @throws Exception
- */
- private void preInitPageDestinations() throws Exception
- {
- Set<SimpleString> destinations = addressManager.getDestinations();
- for (SimpleString destination : destinations)
- {
- pagingManager.createPageStore(destination);
- }
- }
-
private class MessageExpiryRunner extends Thread
{
@Override
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-12-19 17:11:39 UTC (rev 5549)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/paging/PagingManagerIntegrationTest.java 2008-12-19 23:55:57 UTC (rev 5550)
@@ -28,10 +28,9 @@
import org.jboss.messaging.core.paging.Page;
import org.jboss.messaging.core.paging.PagedMessage;
-import org.jboss.messaging.core.paging.PagingStore;
import org.jboss.messaging.core.paging.impl.PagedMessageImpl;
-import org.jboss.messaging.core.paging.impl.PagingStoreFactoryNIO;
import org.jboss.messaging.core.paging.impl.PagingManagerImpl;
+import org.jboss.messaging.core.paging.impl.PagingStoreFactoryNIO;
import org.jboss.messaging.core.paging.impl.TestSupportPageStore;
import org.jboss.messaging.core.remoting.impl.ByteBufferWrapper;
import org.jboss.messaging.core.server.ServerMessage;
More information about the jboss-cvs-commits
mailing list