activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject [1/2] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5748
Date Wed, 08 Jul 2015 17:13:23 GMT
Repository: activemq
Updated Branches:
  refs/heads/master e1c707e81 -> c853bcf43


https://issues.apache.org/jira/browse/AMQ-5748

Fixing an issue that prevented old versions of KahaDB from being
upgraded to the newest version 6


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/8871b0e4
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/8871b0e4
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/8871b0e4

Branch: refs/heads/master
Commit: 8871b0e496bae1396fb7323b01d7f715b4a211f7
Parents: e1c707e
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Wed Jul 8 15:50:16 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Wed Jul 8 16:10:11 2015 +0000

----------------------------------------------------------------------
 .../activemq/store/kahadb/MessageDatabase.java  |  52 ++++++++++++-------
 .../store/kahadb/KahaDBVersionTest.java         |   8 ++-
 .../store/kahadb/KahaDBVersion5/db-1.log        | Bin 0 -> 1048576 bytes
 .../store/kahadb/KahaDBVersion5/db.data         | Bin 0 -> 667648 bytes
 .../store/kahadb/KahaDBVersion5/db.redo         | Bin 0 -> 668944 bytes
 5 files changed, 40 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/8871b0e4/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
----------------------------------------------------------------------
diff --git a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
index e35619e..2fa4bb1 100644
--- a/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
+++ b/activemq-kahadb-store/src/main/java/org/apache/activemq/store/kahadb/MessageDatabase.java
@@ -1930,7 +1930,7 @@ public abstract class MessageDatabase extends ServiceSupport implements
BrokerSe
 
     protected class StoredDestinationMarshaller extends VariableMarshaller<StoredDestination>
{
 
-    	final MessageKeysMarshaller messageKeysMarshaller = new MessageKeysMarshaller();
+        final MessageKeysMarshaller messageKeysMarshaller = new MessageKeysMarshaller();
 
         @Override
         public StoredDestination readPayload(final DataInput dataIn) throws IOException {
@@ -2128,6 +2128,15 @@ public abstract class MessageDatabase extends ServiceSupport implements
BrokerSe
         rc.messageIdIndex.setValueMarshaller(LongMarshaller.INSTANCE);
         rc.messageIdIndex.load(tx);
 
+        //go through an upgrade old index if older than version 6
+        if (metadata.version < 6) {
+            for (Iterator<Entry<Location, Long>> iterator = rc.locationIndex.iterator(tx);
iterator.hasNext(); ) {
+                Entry<Location, Long> entry = iterator.next();
+                // modify so it is upgraded
+                rc.locationIndex.put(tx, entry.getKey(), entry.getValue());
+            }
+        }
+
         // If it was a topic...
         if (topic) {
 
@@ -2275,24 +2284,24 @@ public abstract class MessageDatabase extends ServiceSupport implements
BrokerSe
     protected final Map<String, MessageStore> storeCache =
             new ConcurrentHashMap<String, MessageStore>();
 
-	/**
-	 * Locate the storeMessageSize counter for this KahaDestination
-	 * @param kahaDestination
-	 * @return
-	 */
-	protected MessageStoreStatistics getStoreStats(String kahaDestKey) {
-	    MessageStoreStatistics storeStats = null;
-		try {
-		    MessageStore messageStore = storeCache.get(kahaDestKey);
-		    if (messageStore != null) {
-		        storeStats = messageStore.getMessageStoreStatistics();
-		    }
-		} catch (Exception e1) {
-			 LOG.error("Getting size counter of destination failed", e1);
-		}
-
-		return storeStats;
-	}
+    /**
+     * Locate the storeMessageSize counter for this KahaDestination
+     * @param kahaDestination
+     * @return
+     */
+    protected MessageStoreStatistics getStoreStats(String kahaDestKey) {
+        MessageStoreStatistics storeStats = null;
+        try {
+            MessageStore messageStore = storeCache.get(kahaDestKey);
+            if (messageStore != null) {
+                storeStats = messageStore.getMessageStoreStatistics();
+            }
+        } catch (Exception e1) {
+             LOG.error("Getting size counter of destination failed", e1);
+        }
+
+        return storeStats;
+    }
 
     /**
      * Determine whether this Destination matches the DestinationType
@@ -2319,6 +2328,7 @@ public abstract class MessageDatabase extends ServiceSupport implements
BrokerSe
 
         }
 
+        @Override
         public Location readPayload(DataInput dataIn) throws IOException {
             Location rc = new Location();
             rc.setDataFileId(dataIn.readInt());
@@ -2329,6 +2339,7 @@ public abstract class MessageDatabase extends ServiceSupport implements
BrokerSe
             return rc;
         }
 
+        @Override
         public void writePayload(Location object, DataOutput dataOut)
                 throws IOException {
             dataOut.writeInt(object.getDataFileId());
@@ -2336,14 +2347,17 @@ public abstract class MessageDatabase extends ServiceSupport implements
BrokerSe
             dataOut.writeInt(object.getSize());
         }
 
+        @Override
         public int getFixedSize() {
             return 12;
         }
 
+        @Override
         public Location deepCopy(Location source) {
             return new Location(source);
         }
 
+        @Override
         public boolean isDeepCopySupported() {
             return true;
         }

http://git-wip-us.apache.org/repos/asf/activemq/blob/8871b0e4/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
index c03f60d..0b643b9 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/store/kahadb/KahaDBVersionTest.java
@@ -56,6 +56,8 @@ public class KahaDBVersionTest extends TestCase {
     final static File VERSION_2_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion2");
     final static File VERSION_3_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion3");
     final static File VERSION_4_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion4");
+    final static File VERSION_5_DB = new File(basedir + "/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5");
+
 
     BrokerService broker = null;
 
@@ -76,7 +78,7 @@ public class KahaDBVersionTest extends TestCase {
 
     public void XtestCreateStore() throws Exception {
         KahaDBPersistenceAdapter kaha = new KahaDBPersistenceAdapter();
-        File dir = new File("src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion4");
+        File dir = new File("src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5");
         IOHelper.deleteFile(dir);
         kaha.setDirectory(dir);
         kaha.setJournalMaxFileLength(1024 * 1024);
@@ -127,6 +129,10 @@ public class KahaDBVersionTest extends TestCase {
         doConvertRestartCycle(VERSION_4_DB);
     }
 
+    public void testVersion5Conversion() throws Exception {
+        doConvertRestartCycle(VERSION_5_DB);
+    }
+
     public void doConvertRestartCycle(File existingStore) throws Exception {
 
         File testDir = new File("target/activemq-data/kahadb/versionDB");

http://git-wip-us.apache.org/repos/asf/activemq/blob/8871b0e4/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db-1.log
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db-1.log
b/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db-1.log
new file mode 100644
index 0000000..f9249eb
Binary files /dev/null and b/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db-1.log
differ

http://git-wip-us.apache.org/repos/asf/activemq/blob/8871b0e4/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.data
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.data
b/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.data
new file mode 100644
index 0000000..08fc5a0
Binary files /dev/null and b/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.data
differ

http://git-wip-us.apache.org/repos/asf/activemq/blob/8871b0e4/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.redo
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.redo
b/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.redo
new file mode 100644
index 0000000..bd94d0b
Binary files /dev/null and b/activemq-unit-tests/src/test/resources/org/apache/activemq/store/kahadb/KahaDBVersion5/db.redo
differ


Mime
View raw message