[jboss-cvs] JBoss Messaging SVN: r7600 - in trunk: src/main/org/jboss/messaging/core/persistence/impl/journal and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jul 21 18:55:09 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-07-21 18:55:09 -0400 (Tue, 21 Jul 2009)
New Revision: 7600

Added:
   trunk/tests/src/org/jboss/messaging/tests/integration/persistence/RestartSMTest.java
Modified:
   trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
   trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
Log:
https://jira.jboss.org/jira/browse/JBMESSAGING-1568 - moving create directory away from constructor

Modified: trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2009-07-21 15:30:09 UTC (rev 7599)
+++ trunk/src/main/org/jboss/messaging/core/journal/impl/JournalImpl.java	2009-07-21 22:55:09 UTC (rev 7600)
@@ -1344,7 +1344,7 @@
    {
       final Set<Long> recordsToDelete = new HashSet<Long>();
       final List<RecordInfo> records = new ArrayList<RecordInfo>();
-      
+
       final int DELETE_FLUSH = 20000;
 
       long maxID = load(new LoaderCallback()
@@ -1367,7 +1367,7 @@
          public void deleteRecord(final long id)
          {
             recordsToDelete.add(id);
-            
+
             // Clean up when the list is too large, or it won't be possible to load large sets of files
             // Done as part of JBMESSAGING-1678
             if (recordsToDelete.size() == DELETE_FLUSH)
@@ -1376,7 +1376,7 @@
                while (iter.hasNext())
                {
                   RecordInfo record = iter.next();
-                  
+
                   if (recordsToDelete.contains(record.id))
                   {
                      iter.remove();
@@ -1620,6 +1620,18 @@
 
       checkControlFile();
 
+      records.clear();
+
+      dataFiles.clear();
+
+      pendingCloseFiles.clear();
+
+      freeFiles.clear();
+
+      openedFiles.clear();
+
+      transactions.clear();
+
       final Map<Long, TransactionHolder> loadTransactions = new LinkedHashMap<Long, TransactionHolder>();
 
       final List<JournalFile> orderedFiles = orderFiles();

Modified: trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2009-07-21 15:30:09 UTC (rev 7599)
+++ trunk/src/main/org/jboss/messaging/core/persistence/impl/journal/JournalStorageManager.java	2009-07-21 22:55:09 UTC (rev 7600)
@@ -143,6 +143,16 @@
    private final boolean syncNonTransactional;
 
    private final int perfBlastPages;
+   
+   private final boolean createBindingsDir;
+   
+   private final String bindingsDir;
+   
+   private final boolean createJournalDir;
+   
+   private final String journalDir;
+   
+   private final String largeMessagesDirectory;
 
    public JournalStorageManager(final Configuration config, final Executor executor)
    {
@@ -153,15 +163,24 @@
          throw new IllegalArgumentException("Only NIO and AsyncIO are supported journals");
       }
 
-      String bindingsDir = config.getBindingsDirectory();
+      bindingsDir = config.getBindingsDirectory();
 
       if (bindingsDir == null)
       {
          throw new NullPointerException("bindings-dir is null");
       }
+      
+      createBindingsDir = config.isCreateBindingsDir();
 
-      checkAndCreateDir(bindingsDir, config.isCreateBindingsDir());
+      journalDir = config.getJournalDirectory();
 
+      if (journalDir == null)
+      {
+         throw new NullPointerException("journal-dir is null");
+      }
+      
+      createJournalDir = config.isCreateJournalDir();
+
       SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir);
 
       bindingsJournal = new JournalImpl(1024 * 1024,
@@ -173,19 +192,10 @@
                                         "bindings",
                                         1);
 
-      String journalDir = config.getJournalDirectory();
-
-      if (journalDir == null)
-      {
-         throw new NullPointerException("journal-dir is null");
-      }
-
       syncNonTransactional = config.isJournalSyncNonTransactional();
 
       syncTransactional = config.isJournalSyncTransactional();
 
-      checkAndCreateDir(journalDir, config.isCreateJournalDir());
-
       SequentialFileFactory journalFF = null;
 
       if (config.getJournalType() == JournalType.ASYNCIO)
@@ -225,12 +235,10 @@
                                        "jbm",
                                        config.getJournalMaxAIO());
 
-      String largeMessagesDirectory = config.getLargeMessagesDirectory();
+      largeMessagesDirectory = config.getLargeMessagesDirectory();
 
-      checkAndCreateDir(largeMessagesDirectory, config.isCreateJournalDir());
+      largeMessagesFactory = new NIOSequentialFileFactory(largeMessagesDirectory);
 
-      largeMessagesFactory = new NIOSequentialFileFactory(config.getLargeMessagesDirectory());
-
       perfBlastPages = config.getJournalPerfBlastPages();
    }
 
@@ -997,6 +1005,14 @@
          return;
       }
 
+
+      checkAndCreateDir(bindingsDir, createBindingsDir);
+
+      checkAndCreateDir(journalDir, createJournalDir);
+      
+      checkAndCreateDir(largeMessagesDirectory, createJournalDir);
+
+
       cleanupIncompleteFiles();
 
       bindingsJournal.start();

Added: trunk/tests/src/org/jboss/messaging/tests/integration/persistence/RestartSMTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/persistence/RestartSMTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/persistence/RestartSMTest.java	2009-07-21 22:55:09 UTC (rev 7600)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.persistence;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.persistence.QueueBindingInfo;
+import org.jboss.messaging.core.persistence.impl.journal.JournalStorageManager;
+import org.jboss.messaging.core.server.JournalType;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.tests.util.ServiceTestBase;
+import org.jboss.messaging.utils.Pair;
+import org.jboss.messaging.utils.SimpleString;
+
+/**
+ * A DeleteMessagesRestartTest
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * 
+ * Created Mar 2, 2009 10:14:38 AM
+ *
+ *
+ */
+public class RestartSMTest extends ServiceTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testRestartStorageManager() throws Exception
+   {
+      File testdir = new File(getTestDir());
+      deleteDirectory(testdir);
+      
+      Configuration configuration = createConfigForJournal();
+
+      configuration.start();
+
+      configuration.setJournalType(JournalType.ASYNCIO);
+
+      final JournalStorageManager journal = new JournalStorageManager(configuration, Executors.newCachedThreadPool());
+      journal.start();
+
+      List<QueueBindingInfo> queueBindingInfos = new ArrayList<QueueBindingInfo>();
+
+      journal.loadBindingJournal(queueBindingInfos);
+
+      Map<Long, Queue> queues = new HashMap<Long, Queue>();
+
+      journal.loadMessageJournal(null, null, queues, null);
+
+      journal.stop();
+
+      deleteDirectory(testdir);
+
+      journal.start();
+
+      queues = new HashMap<Long, Queue>();
+
+      journal.loadMessageJournal(null, null, queues, null);
+
+      queueBindingInfos = new ArrayList<QueueBindingInfo>();
+
+      journal.loadBindingJournal(queueBindingInfos);
+
+      journal.start();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}




More information about the jboss-cvs-commits mailing list