qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1306244 [4/4] - in /qpid/branches/java-config-and-management/qpid/java: ./ bdbstore/ bdbstore/bin/ bdbstore/src/main/java/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/store/...
Date Wed, 28 Mar 2012 10:30:06 GMT
Added: qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderTest.java?rev=1306244&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderTest.java
(added)
+++ qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/upgrade/UpgraderTest.java
Wed Mar 28 10:30:03 2012
@@ -0,0 +1,139 @@
+/*
+ *
+ * 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.qpid.server.store.berkeleydb.upgrade;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.qpid.server.logging.subjects.TestBlankSubject;
+import org.apache.qpid.server.store.berkeleydb.BDBMessageStore;
+import org.apache.qpid.server.store.berkeleydb.tuple.ContentBinding;
+
+import com.sleepycat.bind.tuple.IntegerBinding;
+import com.sleepycat.bind.tuple.LongBinding;
+import com.sleepycat.je.Cursor;
+import com.sleepycat.je.Database;
+import com.sleepycat.je.DatabaseConfig;
+import com.sleepycat.je.DatabaseEntry;
+import com.sleepycat.je.OperationStatus;
+import com.sleepycat.je.Transaction;
+
+public class UpgraderTest extends AbstractUpgradeTestCase
+{
+    private Upgrader _upgrader;
+
+    @Override
+    protected String getStoreDirectoryName()
+    {
+        return "bdbstore-v4";
+    }
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        _upgrader = new Upgrader(_environment, new TestBlankSubject());
+    }
+
+    private int getStoreVersion()
+    {
+        DatabaseConfig dbConfig = new DatabaseConfig();
+        dbConfig.setTransactional(true);
+        dbConfig.setAllowCreate(true);
+        int storeVersion = -1;
+        Database versionDb = null;
+        Cursor cursor = null;
+        try
+        {
+            versionDb = _environment.openDatabase(null, Upgrader.VERSION_DB_NAME, dbConfig);
+            cursor = versionDb.openCursor(null, null);
+            DatabaseEntry key = new DatabaseEntry();
+            DatabaseEntry value = new DatabaseEntry();
+            while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS)
+            {
+                int version = IntegerBinding.entryToInt(key);
+                if (storeVersion < version)
+                {
+                    storeVersion = version;
+                }
+            }
+        }
+        finally
+        {
+            if (cursor != null)
+            {
+                cursor.close();
+            }
+            if (versionDb != null)
+            {
+                versionDb.close();
+            }
+        }
+        return storeVersion;
+    }
+
+    public void testUpgrade() throws Exception
+    {
+        assertEquals("Unexpected store version", -1, getStoreVersion());
+        _upgrader.upgradeIfNecessary();
+        assertEquals("Unexpected store version", BDBMessageStore.VERSION, getStoreVersion());
+        assertContent();
+    }
+
+    public void testEmptyDatabaseUpgradeDoesNothing() throws Exception
+    {
+        File nonExistentStoreLocation = new File(TMP_FOLDER, getName());
+        deleteDirectoryIfExists(nonExistentStoreLocation);
+
+        nonExistentStoreLocation.mkdir();
+        _environment = createEnvironment(nonExistentStoreLocation);
+        _upgrader = new Upgrader(_environment, new TestBlankSubject());
+        _upgrader.upgradeIfNecessary();
+
+        List<String> databaseNames = _environment.getDatabaseNames();
+        List<String> expectedDatabases = new ArrayList<String>();
+        expectedDatabases.add("VERSION");
+        assertEquals("Expectedonly VERSION table in initially empty store after upgrade:
", expectedDatabases, databaseNames);
+        assertEquals("Unexpected store version", BDBMessageStore.VERSION, getStoreVersion());
+
+        nonExistentStoreLocation.delete();
+    }
+
+    private void assertContent()
+    {
+        final ContentBinding contentBinding = ContentBinding.getInstance();
+        CursorOperation contentCursorOperation = new CursorOperation()
+        {
+
+            @Override
+            public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction
transaction, DatabaseEntry key,
+                    DatabaseEntry value)
+            {
+                long id = LongBinding.entryToLong(key);
+                assertTrue("Unexpected id", id > 0);
+                byte[] content = contentBinding.entryToObject(value);
+                assertNotNull("Unexpected content", content);
+            }
+        };
+        new DatabaseTemplate(_environment, "MESSAGE_CONTENT", null).run(contentCursorOperation);
+    }
+}

Copied: qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v4/test-store/00000000.jdb
(from r1306213, qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb)
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v4/test-store/00000000.jdb?p2=qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v4/test-store/00000000.jdb&p1=qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb&r1=1306213&r2=1306244&rev=1306244&view=diff
==============================================================================
Files qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb
(original) and qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v4/test-store/00000000.jdb
Wed Mar 28 10:30:03 2012 differ

Added: qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/readme.txt
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/readme.txt?rev=1306244&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/readme.txt
(added)
+++ qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/readme.txt
Wed Mar 28 10:30:03 2012
@@ -0,0 +1,5 @@
+The bdbstore v5 data were obtained by upgrading the bdbstore v4 data as part of running
+test UpgradeFrom4to5Test#testPerformUpgradeWithHandlerAnsweringNo.
+
+The rationale for not using BDBStoreUpgradeTestPreparer in this case is that we need chunked
content.
+Current implementation of BDBMessageStore only stores messages in one chunk.
\ No newline at end of file

Copied: qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000000.jdb
(from r1306213, qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb)
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000000.jdb?p2=qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000000.jdb&p1=qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb&r1=1306213&r2=1306244&rev=1306244&view=diff
==============================================================================
Files qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb
(original) and qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000000.jdb
Wed Mar 28 10:30:03 2012 differ

Copied: qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000001.jdb
(from r1306213, qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb)
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000001.jdb?p2=qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000001.jdb&p1=qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb&r1=1306213&r2=1306244&rev=1306244&view=diff
==============================================================================
Files qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-to-upgrade/test-store/00000000.jdb
(original) and qpid/branches/java-config-and-management/qpid/java/bdbstore/src/test/resources/upgrade/bdbstore-v5/test-store/00000001.jdb
Wed Mar 28 10:30:03 2012 differ

Modified: qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java?rev=1306244&r1=1306243&r2=1306244&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
(original)
+++ qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/CurrentActor.java
Wed Mar 28 10:30:03 2012
@@ -20,11 +20,13 @@
  */
 package org.apache.qpid.server.logging.actors;
 
-import org.apache.qpid.server.logging.LogActor;
-
 import java.util.EmptyStackException;
 import java.util.Stack;
 
+import org.apache.qpid.server.logging.LogActor;
+import org.apache.qpid.server.logging.LogMessage;
+import org.apache.qpid.server.logging.LogSubject;
+
 /**
  * The CurrentActor is a ThreadLocal wrapper that allows threads in the broker
  * to retrieve an actor to perform logging. This approach is used so for two
@@ -126,4 +128,14 @@ public class CurrentActor
     {
         _defaultActor = defaultActor;
     }
+
+    public static void message(LogSubject subject, LogMessage message)
+    {
+        get().message(subject, message);
+    }
+
+    public static void message(LogMessage message)
+    {
+        get().message(message);
+    }
 }

Modified: qpid/branches/java-config-and-management/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java?rev=1306244&r1=1306243&r2=1306244&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java
(original)
+++ qpid/branches/java-config-and-management/qpid/java/client/src/main/java/org/apache/qpid/client/message/FieldTableSupport.java
Wed Mar 28 10:30:03 2012
@@ -48,9 +48,12 @@ public class FieldTableSupport
     public static Map<String,Object> convertToMap(FieldTable ft)
     {
         Map<String,Object> map = new HashMap<String,Object>();
-        for (AMQShortString key: ft.keySet() )
+        if(ft != null)
         {
-            map.put(key.asString(), ft.getObject(key));
+            for (AMQShortString key: ft.keySet() )
+            {
+                map.put(key.asString(), ft.getObject(key));
+            }
         }
 
         return map;

Modified: qpid/branches/java-config-and-management/qpid/java/module.xml
URL: http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/module.xml?rev=1306244&r1=1306243&r2=1306244&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/module.xml (original)
+++ qpid/branches/java-config-and-management/qpid/java/module.xml Wed Mar 28 10:30:03 2012
@@ -48,6 +48,7 @@
   <property name="module.api"          location="${build.api}/${module}/"/>
   <property name="module.test.api"     location="${build.test.api}/${module}"/>
   <property name="module.test.classes" location="${module.build}/test/classes"/>
+  <property name="module.test.resources" location="${module.build}/test/resources"/>
   <property name="module.results"      location="${build.results}/${module}"/>
   <property name="module.failed"       location="${module.results}/FAILED"/>
   <property name="module.src"          location="src/main/java"/>
@@ -179,6 +180,7 @@
     <path refid="module.class.path"/>
     <pathelement path="${module.test.depends.path}"/>
     <path refid="module.test.libs"/>
+    <pathelement path="${module.test.resources}"/>
   </path>
 
   <property name="javac.deprecation" value="off"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message