rhmessaging commits: r2375 - mgmt/trunk/cumin/python/wooly.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-09-02 11:36:42 -0400 (Tue, 02 Sep 2008)
New Revision: 2375
Modified:
mgmt/trunk/cumin/python/wooly/widgets.py
Log:
Do the 'None'-ifying down in the property renderer
Modified: mgmt/trunk/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/widgets.py 2008-09-02 15:13:36 UTC (rev 2374)
+++ mgmt/trunk/cumin/python/wooly/widgets.py 2008-09-02 15:36:42 UTC (rev 2375)
@@ -439,6 +439,8 @@
if type(value) is str:
value = escape(value)
+ elif value is None:
+ value = "<em>None</em>"
return value
17 years, 8 months
rhmessaging commits: r2374 - store/branches/java/broker-queue-refactor/java/bdbstore/lib.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-09-02 11:13:36 -0400 (Tue, 02 Sep 2008)
New Revision: 2374
Added:
store/branches/java/broker-queue-refactor/java/bdbstore/lib/slf4j-api-1.4.0.jar
Log:
Added missing slf4j api jar
Added: store/branches/java/broker-queue-refactor/java/bdbstore/lib/slf4j-api-1.4.0.jar
===================================================================
(Binary files differ)
Property changes on: store/branches/java/broker-queue-refactor/java/bdbstore/lib/slf4j-api-1.4.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years, 8 months
rhmessaging commits: r2373 - store/branches/java/broker-queue-refactor/java/bdbstore.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-09-02 11:10:31 -0400 (Tue, 02 Sep 2008)
New Revision: 2373
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
Log:
Ensured that the build-tools has only main classes and librarires on classpath.
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-02 15:05:53 UTC (rev 2372)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-02 15:10:31 UTC (rev 2373)
@@ -27,6 +27,13 @@
</fileset>
</path>
+ <path id="tools.class.path">
+ <path refid="class.path"/>
+ <pathelement path="${build.classes}"/>
+ <pathelement path="${build.tools.classes}"/>
+ </path>
+
+
<path id="test.class.path">
<path refid="class.path"/>
<pathelement path="${build.classes}"/>
@@ -62,7 +69,7 @@
<target name="build-tools" depends="init,build-main">
<javac srcdir="${src.tools.dir}"
destdir="${build.tools.classes}"
- classpathref="test.class.path"/>
+ classpathref="tools.class.path"/>
</target>
<target name="jar" depends="build">
17 years, 8 months
rhmessaging commits: r2372 - mgmt/trunk/cumin/python/wooly.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-09-02 11:05:53 -0400 (Tue, 02 Sep 2008)
New Revision: 2372
Modified:
mgmt/trunk/cumin/python/wooly/widgets.py
Log:
Escape string values of PropertySets.
Modified: mgmt/trunk/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/widgets.py 2008-09-02 14:41:20 UTC (rev 2371)
+++ mgmt/trunk/cumin/python/wooly/widgets.py 2008-09-02 15:05:53 UTC (rev 2372)
@@ -1,4 +1,5 @@
from math import ceil
+from xml.sax.saxutils import escape
from parameters import *
from resources import *
@@ -434,8 +435,13 @@
return prop[0]
def render_value(self, session, prop):
- return prop[1]
+ value = prop[1]
+ if type(value) is str:
+ value = escape(value)
+
+ return value
+
class ActionSet(RenderingItemSet):
def __init__(self, app, name, item_renderer=None):
super(ActionSet, self).__init__(app, name, item_renderer)
17 years, 8 months
rhmessaging commits: r2371 - store/branches/java/broker-queue-refactor/java/bdbstore.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-09-02 10:41:20 -0400 (Tue, 02 Sep 2008)
New Revision: 2371
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
Log:
Fixed the build order so that the tools can be tested
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-02 14:32:02 UTC (rev 2370)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-02 14:41:20 UTC (rev 2371)
@@ -45,7 +45,7 @@
<delete dir="${build.dir}"/>
</target>
- <target name="build" depends="init,build-main,build-tests,build-tools"/>
+ <target name="build" depends="init,build-main,build-tools,build-tests"/>
<target name="build-main" depends="init">
<javac srcdir="${src.main.dir}"
17 years, 8 months
rhmessaging commits: r2370 - store/branches/java/broker-queue-refactor/java/bdbstore.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-09-02 10:32:02 -0400 (Tue, 02 Sep 2008)
New Revision: 2370
Added:
store/branches/java/broker-queue-refactor/java/bdbstore/default.testprofile
store/branches/java/broker-queue-refactor/java/bdbstore/log4j-test.xml
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
Log:
Updated build system to run BDB tests
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-02 14:31:35 UTC (rev 2369)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-02 14:32:02 UTC (rev 2370)
@@ -3,13 +3,24 @@
-->
<project name="BDBStore" default="build">
- <property name="src.dir" location="src/main/java"/>
+ <property name="src.tools.dir" location="src/tools/java"/>
+ <property name="src.main.dir" location="src/main/java"/>
<property name="src.test.dir" location="src/test/java"/>
<property name="build.dir" location="build"/>
<property name="lib.dir" location="lib"/>
<property name="build.classes" location="build/classes"/>
<property name="build.test.classes" location="build/test/classes"/>
+ <property name="build.tools.classes" location="build/tools/classes"/>
+ <property name="build.results" location="build/results"/>
+ <property name="java.naming.factory.initial" value="org.apache.qpid.jndi.PropertiesFileInitialContextFactory"/>
+
+ <available property="src.test.dir.exists" file="${src.test.dir}"/>
+
+ <dirname property="project.root" file="${ant.file.common}"/>
+
+ <property file="${project.root}/default.testprofile"/>
+
<path id="class.path">
<fileset dir="lib">
<include name="**/*.jar"/>
@@ -19,40 +30,47 @@
<path id="test.class.path">
<path refid="class.path"/>
<pathelement path="${build.classes}"/>
+ <pathelement path="${build.tools.classes}"/>
+ <pathelement path="${build.test.classes}"/>
</path>
<target name="init">
- <mkdir dir="build/classes"/>
- <mkdir dir="build/test/classes"/>
+ <mkdir dir="${build.classes}"/>
+ <mkdir dir="${build.test.classes}"/>
+ <mkdir dir="${build.tools.classes}"/>
+ <mkdir dir="${build.results}"/>
</target>
<target name="clean" description="remove build artifacts">
<delete dir="${build.dir}"/>
</target>
- <target name="build" depends="init">
- <javac srcdir="${src.dir}"
+ <target name="build" depends="init,build-main,build-tests,build-tools"/>
+
+ <target name="build-main" depends="init">
+ <javac srcdir="${src.main.dir}"
destdir="${build.classes}"
- classpathref="class.path"/>
+ classpathref="test.class.path"/>
</target>
- <target name="build-tests" depends="build">
+ <target name="build-tests" depends="init,build-main">
<javac srcdir="${src.test.dir}"
destdir="${build.test.classes}"
classpathref="test.class.path"/>
</target>
- <target name="jar" depends="build">
- <jar destfile="build/qpid-bdbstore.jar" basedir="build/classes"/>
+ <target name="build-tools" depends="init,build-main">
+ <javac srcdir="${src.tools.dir}"
+ destdir="${build.tools.classes}"
+ classpathref="test.class.path"/>
</target>
-
- <target name="test" depends="build, build-tests">
-
+ <target name="jar" depends="build">
+ <jar destfile="build/qpid-bdbstore.jar" basedir="${build.classes}"/>
+ <jar destfile="build/qpid-tools.jar" basedir="${build.tools.dir}"/>
</target>
-
- <target name="teststuff" depends="build,build-tests" if="module.test.src.exists"
+ <target name="test" depends="build-tests" if="src.test.dir.exists"
unless="${dontruntest}" description="execute unit tests">
<delete file="${module.failed}"/>
@@ -74,22 +92,25 @@
<sysproperty key="test.excludesfile" value="${test.excludesfile}"/>
<sysproperty key="max_prefetch" value ="${max_prefetch}"/>
<sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/>
- <sysproperty key="QPID_EXAMPLE_HOME" value="${project.root}/broker"/>
- <sysproperty key="QPID_HOME" value="${project.root}/broker"/>
+ <sysproperty key="QPID_HOME" value="${project.root}"/>
+ <sysproperty key="QPID_WORK" value="${project.root}/build/test-work"/>
+ <sysproperty key="BDB_HOME" value="${project.root}"/>
+
+
<formatter type="plain"/>
<formatter type="xml"/>
- <classpath refid="module.test.path"/>
+ <classpath refid="test.class.path"/>
- <batchtest fork="${test.fork}" todir="${module.results}">
- <fileset dir="${module.test.src}" excludes="${module.test.excludes}">
+ <batchtest fork="${test.fork}" todir="${build.results}">
+ <fileset dir="${src.test.dir}" excludes="${module.test.excludes}">
<include name="**/${test}.java"/>
</fileset>
</batchtest>
</junit>
- <antcall target="touch-failed"/>
+ <!--antcall target="touch-failed"/-->
<condition property="failed">
<and>
@@ -102,7 +123,6 @@
</target>
- <target name="release" depends="jar"/>
+ <target name="release" depends="jar"/>
-
</project>
Added: store/branches/java/broker-queue-refactor/java/bdbstore/default.testprofile
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/default.testprofile (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/default.testprofile 2008-09-02 14:32:02 UTC (rev 2370)
@@ -0,0 +1,23 @@
+broker.version=0-8
+broker=vm
+broker.clean=${project.root}/clean-dir ${build.data}
+broker.ready=Listening on TCP port
+
+java.naming.provider.url=${project.root}/test-provider.properties
+max_prefetch=1000
+
+log=debug
+amqj.logging.level=${log}
+amqj.protocol.logging.level=${log}
+root.logging.level=${log}
+log4j.configuration=file:///${project.root}/log4j-test.xml
+log4j.debug=false
+
+test.excludes=true
+test.excludesfile=${project.root}/08ExcludeList
+test.fork=no
+test.mem=512M
+test=*Test
+haltonfailure=no
+haltonerror=no
+exclude.modules=none
Added: store/branches/java/broker-queue-refactor/java/bdbstore/log4j-test.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/log4j-test.xml (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/log4j-test.xml 2008-09-02 14:32:02 UTC (rev 2370)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j configuration for unit tests -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%t %d %p [%c{4}] %m%n"/>
+ </layout>
+ </appender>
+
+ <logger name="org.apache.qpid">
+ <level value="${amqj.logging.level}"/>
+ </logger>
+
+ <logger name="qpid.protocol">
+ <level value="${amqj.protocol.logging.level}"/>
+ </logger>
+
+ <logger name="org.apache.qpid.test">
+ <level value="ALL"/>
+ </logger>
+
+ <root>
+ <level value="${root.logging.level}"/>
+ <appender-ref ref="console" />
+ </root>
+</log4j:configuration>
17 years, 8 months
rhmessaging commits: r2369 - in store/branches/java/broker-queue-refactor/java/bdbstore: src and 10 other directories.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-09-02 10:31:35 -0400 (Tue, 02 Sep 2008)
New Revision: 2369
Added:
store/branches/java/broker-queue-refactor/java/bdbstore/etc/config.xml
store/branches/java/broker-queue-refactor/java/bdbstore/etc/jmxremote.access
store/branches/java/broker-queue-refactor/java/bdbstore/etc/passwd
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/DurableSubscriber.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/JNDIHelper.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/Publisher.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/
store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java
Log:
RHM-6 :Create BDBStore Upgrade Tool, provided additional test to validate its functionality.
Added: store/branches/java/broker-queue-refactor/java/bdbstore/etc/config.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/etc/config.xml (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/etc/config.xml 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - 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.
+ -
+ -->
+<broker>
+ <prefix>${QPID_HOME}</prefix>
+ <work>${QPID_WORK}</work>
+ <conf>${prefix}/etc</conf>
+ <connector>
+ <!-- Uncomment out this block and edit the keystorePath and keystorePassword
+ to enable SSL support
+ <ssl>
+ <enabled>true</enabled>
+ <sslOnly>true</sslOnly>
+ <keystorePath>/path/to/keystore.ks</keystorePath>
+ <keystorePassword>keystorepass</keystorePassword>
+ </ssl>-->
+ <qpidnio>false</qpidnio>
+ <protectio>
+ <enabled>false</enabled>
+ </protectio>
+ <transport>nio</transport>
+ <port>5672</port>
+ <sslport>8672</sslport>
+ <socketReceiveBuffer>32768</socketReceiveBuffer>
+ <socketSendBuffer>32768</socketSendBuffer>
+ </connector>
+ <management>
+ <enabled>true</enabled>
+ <jmxport>8999</jmxport>
+ <security-enabled>false</security-enabled>
+ </management>
+ <advanced>
+ <filterchain enableExecutorPool="true"/>
+ <enablePooledAllocator>false</enablePooledAllocator>
+ <enableDirectBuffers>false</enableDirectBuffers>
+ <framesize>65535</framesize>
+ <compressBufferOnQueue>false</compressBufferOnQueue>
+ <enableJMSXUserID>false</enableJMSXUserID>
+ </advanced>
+
+ <security>
+ <principal-databases>
+ <!-- Example use of Base64 encoded MD5 hashes for authentication via CRAM-MD5-Hashed -->
+ <principal-database>
+ <name>passwordfile</name>
+ <class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
+ <attributes>
+ <attribute>
+ <name>passwordFile</name>
+ <value>${conf}/passwd</value>
+ </attribute>
+ </attributes>
+ </principal-database>
+ </principal-databases>
+
+ <access>
+ <class>org.apache.qpid.server.security.access.plugins.AllowAll</class>
+ </access>
+ <jmx>
+ <access>${conf}/jmxremote.access</access>
+ <principal-database>passwordfile</principal-database>
+ </jmx>
+ </security>
+
+ <virtualhosts>
+ <directory>${conf}/virtualhosts</directory>
+
+ <virtualhost>
+ <name>localhost</name>
+ <localhost>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ </store>
+
+ <housekeeping>
+ <expiredMessageCheckPeriod>20000</expiredMessageCheckPeriod>
+ </housekeeping>
+
+ </localhost>
+ </virtualhost>
+
+ <virtualhost>
+ <name>development</name>
+ <development>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ </store>
+ </development>
+ </virtualhost>
+
+ <virtualhost>
+ <name>test</name>
+ <test>
+ <store>
+ <class>org.apache.qpid.server.store.MemoryMessageStore</class>
+ </store>
+ </test>
+ </virtualhost>
+
+ </virtualhosts>
+ <heartbeat>
+ <delay>0</delay>
+ <timeoutFactor>2.0</timeoutFactor>
+ </heartbeat>
+ <queue>
+ <auto_register>true</auto_register>
+ </queue>
+
+ <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
+</broker>
+
+
Added: store/branches/java/broker-queue-refactor/java/bdbstore/etc/jmxremote.access
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/etc/jmxremote.access (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/etc/jmxremote.access 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,23 @@
+#
+# 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.
+
+#Generated by JMX Console : Last edited by user:admin
+#Tue Jun 12 16:46:39 BST 2007
+admin=admin
+guest=readonly
+user=readwrite
Added: store/branches/java/broker-queue-refactor/java/bdbstore/etc/passwd
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/etc/passwd (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/etc/passwd 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+guest:guest
+client:guest
+server:guest
+
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java 2008-09-02 14:30:22 UTC (rev 2368)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java 2008-09-02 14:31:35 UTC (rev 2369)
@@ -69,7 +69,6 @@
private static volatile int _loops;
private String TEST_LOCATION = "bdbTestEnv";
File BDB_DIR = new File(TEST_LOCATION);
-
public void setUp() throws Exception
{
@@ -83,13 +82,13 @@
BDB_DIR.mkdirs();
_store = new BDBMessageStore();
+ _store.configure(BDB_DIR);
- _store.createEnvironment(BDB_DIR);
- _store.openDatabases();
_virtualHost = new VirtualHost("test", _store);
_store.setVirtualHost(_virtualHost);
- _store.startCommitThread();
+ _store.recover();
+
_txnContext = new NonTransactionalContext(_store, _storeContext, null, new LinkedList<RequiredDeliveryException>());
}
@@ -111,24 +110,24 @@
private void reload() throws Exception
{
_virtualHost.close();
-
+
PropertiesConfiguration env = new PropertiesConfiguration();
env.addProperty("store.environment-path", "bdbTestEnv");
env.addProperty("store.class", "org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
_virtualHost = new VirtualHost("test", env);
- _store = (BDBMessageStore)_virtualHost.getMessageStore();
+ _store = (BDBMessageStore) _virtualHost.getMessageStore();
}
public void tearDown() throws Exception
{
_virtualHost.close();
- ApplicationRegistry.removeAll();
+ ApplicationRegistry.remove(1);
}
- public void testExchangePersistence() throws Exception
+ public void testExchangePersistence() throws Exception
{
FieldTable queueArguments = new FieldTable();
Integer priorityLevel = 5;
@@ -332,7 +331,7 @@
{
// pass since exception expected
}
-
+
}
public void testTranCommit() throws Exception
@@ -348,7 +347,7 @@
_store.storeMessageMetaData(_storeContext, 22L, new MessageMetaData(pubBody, chb, 0));
AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(QUEUE1, true, ME, false, _virtualHost, null);
- _store.createQueue(queue, null);
+ _store.createQueue(queue);
_store.beginTran(_storeContext);
_store.enqueueMessage(_storeContext, queue, 20L);
@@ -381,7 +380,7 @@
_store.storeMessageMetaData(_storeContext, 32L, new MessageMetaData(pubBody, chb, 0));
AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(QUEUE1, true, ME, false, _virtualHost, null);
- _store.createQueue(queue, null);
+ _store.createQueue(queue);
_store.beginTran(_storeContext);
_store.enqueueMessage(_storeContext, queue, 30L);
@@ -395,17 +394,16 @@
_store.beginTran(_storeContext);
_store.commitTran(_storeContext);
- enqueuedIds = _store.getEnqueuedMessages(QUEUE1);
+ enqueuedIds = _store.getEnqueuedMessages(QUEUE1);
assertTrue("Last Test Message is still present", !enqueuedIds.contains(20L));
assertEquals("Incorrect Enqueued Message Count:", 2, enqueuedIds.size());
Long val = enqueuedIds.get(0);
assertEquals("First Message is incorrect", 30L, val.longValue());
val = enqueuedIds.get(1);
assertEquals("Second Message is incorrect", 31L, val.longValue());
-
+
}
-
public void testTranRollback2() throws Exception
{
List<Long> enqueuedIds = _store.getEnqueuedMessages(QUEUE1);
@@ -423,7 +421,7 @@
_store.storeMessageMetaData(_storeContext, 32L, new MessageMetaData(pubBody, chb, 0));
AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(QUEUE1, true, ME, false, _virtualHost, null);
- _store.createQueue(queue, null);
+ _store.createQueue(queue);
_store.beginTran(_storeContext);
_store.enqueueMessage(_storeContext, queue, 30L);
@@ -461,8 +459,8 @@
AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(QUEUE1, true, ME, false, _virtualHost, null);
AMQQueue queue2 = AMQQueueFactory.createAMQQueueImpl(QUEUE2, true, HIM, false, _virtualHost, null);
- _store.createQueue(queue, null);
- _store.createQueue(queue2, null);
+ _store.createQueue(queue);
+ _store.createQueue(queue2);
_store.beginTran(_storeContext);
_store.enqueueMessage(_storeContext, queue, 40L);
@@ -504,7 +502,7 @@
_store.storeMessageMetaData(_storeContext, 50L, new MessageMetaData(pubBody, chb, 0));
AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(QUEUE1, true, ME, false, _virtualHost, null);
- _store.createQueue(queue, null);
+ _store.createQueue(queue);
_store.enqueueMessage(_storeContext, queue, 50L);
_store.dequeueMessage(_storeContext, queue, 50L);
@@ -513,7 +511,7 @@
public void testQueueRemove() throws AMQException
{
AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(QUEUE1, true, ME, false, _virtualHost, null);
- _store.createQueue(queue, null);
+ _store.createQueue(queue);
_store.removeQueue(queue);
try
{
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,218 @@
+/*
+ *
+ * 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;
+
+import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.store.berkeleydb.utils.Publisher;
+import org.apache.qpid.server.store.berkeleydb.utils.DurableSubscriber;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.util.FileUtils;
+import org.apache.commons.configuration.Configuration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.IOException;
+
+public class BDBUpgradeTest extends TestCase
+{
+ protected static final Logger _logger = LoggerFactory.getLogger(BDBUpgradeTest.class);
+
+ final String BDBHome = System.getProperty("BDB_HOME");
+ final File _configFile = new File(BDBHome, "etc/config.xml");
+
+ private String VIRTUALHOST = "test";
+
+ private static final String VERSION_1 = "1";
+ private static final String VERSION_2 = "2";
+
+ private String _topic = "MyDurableSubscriptionTestTopic";
+
+ String _fromDir = System.getProperty("QPID_WORK")+"/version1Store";
+ String _toDir = System.getProperty("QPID_WORK")+"/version2Store";
+
+
+ public void setUp() throws IOException
+ {
+ assertNotNull("QPID_WORK must be set", System.getProperty("QPID_WORK"));
+
+ File directory = new File(_toDir);
+
+ if (directory.exists() && directory.isDirectory())
+ {
+ FileUtils.delete(directory, true);
+ }
+
+ directory = new File(_fromDir);
+
+ if (directory.exists() && directory.isDirectory())
+ {
+ FileUtils.delete(directory, true);
+ }
+
+ }
+
+
+ public void testDurababilitySelectors() throws Exception
+ {
+ String broker = "vm://:1";
+
+ startBroker(1, VERSION_1);
+
+ new DurableSubscriber(broker, _topic, null).close();
+
+ sendMessages(broker, _topic, 10);
+
+ sendAndCheckDurableSubscriber(broker, false, true, 5, "odd=true");
+
+ Thread.sleep(2000);
+
+ stopBroker(1);
+
+ upgradeBroker();
+
+ broker = "vm://:2";
+
+ startBroker(2, VERSION_2);
+
+ //Ensure msg were transitioned to new broker
+ sendAndCheckDurableSubscriber(broker, false, false, 5, null);
+
+ //Reset the Selector Pattern
+ new DurableSubscriber(broker, _topic, "odd=true").close();
+
+ stopBroker(2);
+
+ startBroker(2, VERSION_2);
+
+ //Ensure that the selector was preseved on restart and caused all msgs to be removed.
+ sendAndCheckDurableSubscriber(broker, false, false, 0, null);
+ stopBroker(2);
+ }
+
+ public void testDurabability() throws Exception
+ {
+ String broker = "vm://:1";
+
+ startBroker(1, VERSION_1);
+
+ sendAndCheckDurableSubscriber(broker, true, false, 10, null);
+
+ stopBroker(1);
+
+ startBroker(1, VERSION_1);
+
+ sendAndCheckDurableSubscriber(broker, false, true, 10, null);
+
+ stopBroker(1);
+ }
+
+ private void upgradeBroker() throws Exception
+ {
+ new BDBStoreUpgrade(_fromDir, _toDir).upgradeFromVersion(1);
+ }
+
+ private void stopBroker(int port)
+ {
+ TransportConnection.killVMBroker(port);
+ ApplicationRegistry.remove(port);
+ }
+
+ private void startBroker(int port, String version) throws Exception
+ {
+ //Create a Version 1 store
+ ConfigurationFileApplicationRegistry config = new ConfigurationFileApplicationRegistry(_configFile);
+
+ //Disable management on broker.
+ config.getConfiguration().setProperty("management.enabled", "false");
+
+ Configuration testVirtualhost = config.getConfiguration().subset("virtualhosts.virtualhost." + VIRTUALHOST);
+ testVirtualhost.setProperty("store.class", "org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
+ testVirtualhost.setProperty("store." + BDBMessageStore.ENVIRONMENT_PATH_PROPERTY, "${work}/version" + port + "Store");
+ testVirtualhost.setProperty("store.version", version);
+
+ ApplicationRegistry.initialise(config, port);
+ TransportConnection.createVMBroker(port);
+
+ }
+
+ public void sendAndCheckDurableSubscriber(String broker, boolean send, boolean commitRecieved, int count, String selector)
+ throws Exception
+ {
+
+ DurableSubscriber subscriber = new DurableSubscriber(broker, _topic, selector);
+
+ try
+ {
+ if (send)
+ {
+ sendMessages(broker, _topic, count);
+ }
+
+ //Wait for messages to arrive.
+ // 1sec should be enough for delivery of 10 msgs.
+ int loop = 0;
+
+ Thread.sleep(1000);
+
+ while (subscriber.getMessages().size() < count)
+ {
+ assertTrue("Waited more than 5 second for " + count + "messages to be delivered:"
+ + subscriber.getMessages().size(), loop < 5);
+ loop++;
+ Thread.sleep(1000);
+ }
+
+ assertEquals("Incorrect number of messages received", count, subscriber.getMessages().size());
+
+ if (commitRecieved)
+ {
+ subscriber.commit();
+ }
+ }
+ finally
+ {
+ subscriber.close();
+ }
+ }
+
+ private void sendMessages(String broker, String topic, int totalMessages) throws JMSException
+ {
+
+ Publisher publisher = new Publisher(broker, topic);
+
+ for (int i = 0; i < totalMessages; i++)
+ {
+ Message msg = publisher.createTextMessage("message " + i);
+ msg.setBooleanProperty("odd", i % 2 == 0);
+ publisher.send(msg);
+ }
+
+ publisher.commit();
+ }
+
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/DurableSubscriber.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/DurableSubscriber.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/DurableSubscriber.java 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,112 @@
+/*
+ *
+ * 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.utils;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQTopic;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.Session;
+import javax.jms.TopicSubscriber;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageListener;
+import javax.jms.Message;
+import java.util.List;
+import java.util.LinkedList;
+
+public class DurableSubscriber implements MessageListener
+{
+ private static final Logger _logger = LoggerFactory.getLogger(DurableSubscriber.class);
+
+ JNDIHelper _jndiHelper;
+
+ Session _session;
+ TopicSubscriber _subscriber;
+ AMQConnection _connection;
+ private List<Message> _received;
+
+ public static void main(String[] args) throws JMSException
+ {
+ new Publisher();
+ }
+
+ public DurableSubscriber() throws JMSException
+ {
+ this(JNDIHelper.DEFAULT_BROKER, null);
+ }
+
+ public DurableSubscriber(String broker, String topic) throws JMSException
+ {
+ this(broker, topic, null);
+ }
+
+ public DurableSubscriber(String broker, String topicStr, String selector) throws JMSException
+ {
+ _jndiHelper = new JNDIHelper(broker );
+
+ _connection = (AMQConnection) ((ConnectionFactory) _jndiHelper.lookupJNDI(JNDIHelper.CONNECTION_JNDI_NAME)).createConnection();
+
+ _jndiHelper.close();
+
+ AMQTopic topic = new AMQTopic(_connection, topicStr);
+
+ _logger.debug("Create Session");
+ _session = _connection.createSession(true, Session.SESSION_TRANSACTED);
+ _logger.debug("Create Durable Subscriber on Session");
+
+ if (selector != null)
+ {
+ _subscriber = _session.createDurableSubscriber(topic, "MySubscription", selector, false);
+ }
+ else
+ {
+ _subscriber = _session.createDurableSubscriber(topic, "MySubscription");
+ }
+
+ _received = new LinkedList<Message>();
+
+ _subscriber.setMessageListener(this);
+
+ _connection.start();
+ }
+
+ public void close() throws JMSException
+ {
+ _connection.close();
+ }
+
+ public void onMessage(Message message)
+ {
+ _received.add(message);
+ }
+
+ public List<Message> getMessages()
+ {
+ return _received;
+ }
+
+ public void commit() throws JMSException
+ {
+ _session.commit();
+ }
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/JNDIHelper.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/JNDIHelper.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/JNDIHelper.java 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,107 @@
+/*
+ *
+ * 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.utils;
+
+import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import java.util.Properties;
+
+public class JNDIHelper
+{
+ public static final String DEFAULT_BROKER = "tcp://localhost:2345";
+ public static final String CONNECTION_JNDI_NAME = "local";
+
+ public final String INITIAL_CONTEXT_FACTORY = "org.apache.qpid.jndi.PropertiesFileInitialContextFactory";
+ public final String CONNECTION_NAME;
+
+ InitialContext _ctx;
+
+ public JNDIHelper(String broker)
+ {
+ CONNECTION_NAME = "amqp://guest:guest@clientid/test?brokerlist='" + broker + "'";
+ setupJNDI();
+ }
+
+ /**
+ * Lookup the specified name in the JNDI Context.
+ *
+ * @param name The string name of the object to lookup
+ *
+ * @return The object or null if nothing exists for specified name
+ */
+ public Object lookupJNDI(String name)
+ {
+ try
+ {
+ return _ctx.lookup(name);
+ }
+ catch (NamingException e)
+ {
+ System.err.println("Error looking up '" + name + "' in JNDI Context:" + e);
+ }
+
+ return null;
+ }
+
+ /**
+ * Setup the JNDI context.
+ *
+ * In this case we are simply using a Properties object to store the pairing information.
+ *
+ * Further details can be found on the wiki site here:
+ *
+ * @see : http://cwiki.apache.org/qpid/how-to-use-jndi.html
+ */
+ private void setupJNDI()
+ {
+ // Set the properties ...
+ Properties properties = new Properties();
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
+ properties.put("connectionfactory." + CONNECTION_JNDI_NAME, CONNECTION_NAME);
+
+ // Create the initial context
+ Context ctx = null;
+ try
+ {
+ _ctx = new InitialContext(properties);
+ }
+ catch (NamingException e)
+ {
+ System.err.println("Error Setting up JNDI Context:" + e);
+ }
+ }
+
+ /** Close the JNDI Context to keep everything happy. */
+ public void close()
+ {
+ try
+ {
+ _ctx.close();
+ }
+ catch (NamingException e)
+ {
+ System.err.println("Unable to close JNDI Context : " + e);
+ }
+ }
+}
+
+
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/Publisher.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/Publisher.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/Publisher.java 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,108 @@
+/*
+ *
+ * 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.utils;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.client.BasicMessageProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.Session;
+import javax.jms.TopicSubscriber;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageListener;
+import javax.jms.Message;
+import javax.jms.MessageProducer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.Properties;
+import java.util.List;
+import java.util.LinkedList;
+
+public class Publisher
+{
+ private static final Logger _logger = LoggerFactory.getLogger(Publisher.class);
+
+ JNDIHelper _jndiHelper;
+
+ Session _session;
+
+ MessageProducer _publisher;
+
+ AMQConnection _connection;
+
+ public static void main(String[] args) throws JMSException
+ {
+ new Publisher();
+ }
+
+ public Publisher() throws JMSException
+ {
+ this(JNDIHelper.DEFAULT_BROKER, null);
+ }
+
+ public Publisher(String broker, String topicStr) throws JMSException
+ {
+ _jndiHelper= new JNDIHelper(broker);
+
+ _connection = (AMQConnection) ((ConnectionFactory) _jndiHelper.lookupJNDI(JNDIHelper.CONNECTION_JNDI_NAME)).createConnection();
+
+ _jndiHelper.close();
+
+ AMQTopic topic = new AMQTopic(_connection, topicStr);
+
+ _logger.debug("Create Session");
+ _session = _connection.createSession(true, Session.SESSION_TRANSACTED);
+ _logger.debug("Create publisher on Session");
+
+ if (topicStr != null)
+ {
+ _publisher = _session.createProducer(_session.createTopic(topicStr));
+ }
+ else
+ {
+ _publisher = _session.createProducer(null);
+ }
+ }
+
+ public void close() throws JMSException
+ {
+ _connection.close();
+ }
+
+ public void commit() throws JMSException
+ {
+ _session.commit();
+ }
+
+ public Message createTextMessage(String msg) throws JMSException
+ {
+ return _session.createTextMessage(msg);
+ }
+
+ public void send(Message msg) throws JMSException
+ {
+ _publisher.send( msg);
+ }
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/tools/java/org/apache/qpid/server/store/berkeleydb/BDBStoreUpgrade.java 2008-09-02 14:31:35 UTC (rev 2369)
@@ -0,0 +1,244 @@
+/*
+ *
+ * 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;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.qpid.server.store.MemoryMessageStore;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.AMQException;
+
+import java.io.File;
+
+import com.sleepycat.je.DatabaseEntry;
+import com.sleepycat.je.DatabaseException;
+import com.sleepycat.je.Database;
+import com.sleepycat.bind.tuple.TupleBinding;
+import com.sleepycat.bind.tuple.ByteBinding;
+
+/**
+ * This is a simple BerkeleyDB Store upgrade tool that will upgrade a V1 Store to a V2 Store.
+ *
+ * NOTE: No checks are in place to validate that the input is V1.
+ *
+ * Currently upgrade is fixed from v1 -> v2
+ * Only the Queue and Binding databases are migrated all other databases are copied as DB entries.
+ *
+ * Improvments:
+ * - Add List BDBMessageStore.getDatabases(); This can the be iterated to guard against new DBs being added.
+ * - Add a version value into the store so that a quick check can be performed to perform the upgrades.
+ * - A version in the store would allow automated upgrade or later with more available versions interactive upgrade.
+ * - Currently only the Queue and Binding DB are processed for upgrade all the other db data is copied between stores.
+ * - Add process logging and disable all Store and Qpid logging.
+ */
+public class BDBStoreUpgrade
+{
+ private static final String FROM_DIR = "-input";
+ private static final String TO_DIR = "-output";
+
+ private static final Logger _logger = LoggerFactory.getLogger(BDBStoreUpgrade.class);
+ /** The Store Directory that needs upgrading */
+ File _fromDir;
+ /** The Directory that will be made to contain the upgraded store */
+ File _toDir;
+
+ /** The Old Store */
+ BDBMessageStore _oldMessageStore;
+ /** The New Store */
+ BDBMessageStore _newMessageStore;
+ /** A VHost used in the migration of the queues from the old VHost */
+ VirtualHost _newVirtualHost;
+ /** A VHost used in the creation of the queues from the old store */
+ VirtualHost _oldVirtualHost;
+
+ public BDBStoreUpgrade(String fromDir, String toDir)
+ {
+ _fromDir = new File(fromDir);
+ if (!_fromDir.exists())
+ {
+ if (!_fromDir.mkdirs())
+ {
+ throw new IllegalArgumentException("BDBStore path " + fromDir + " could not be read. "
+ + "Ensure the path is correct and that the permissions are correct.");
+ }
+ }
+
+ _toDir = new File(toDir);
+ if (!_toDir.exists())
+ {
+ if (!_toDir.mkdirs())
+ {
+ throw new IllegalArgumentException("Environment path " + toDir + " could not be created. "
+ + "Ensure the path is correct and that the permissions are correct.");
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Environment path " + toDir + " already exists. ");
+
+ }
+
+ }
+
+ /**
+ * Upgrade a Store of a specified version to the latest version.
+ * @param version the version of the current store
+ * @throws Exception
+ */
+ public void upgradeFromVersion(int version) throws Exception
+ {
+ upgradeFromVersion(version, _fromDir, _toDir);
+ }
+
+ /**
+ * Upgrade a Store of a specified version to the latest version.
+ *
+ * @param version the version of the current store
+ * @param fromDir the directory with the old Store
+ * @param toDir the directrory to hold the newly Upgraded Store
+ *
+ * @throws Exception due to Virtualhost/MessageStore.close() being rather poor at exception handling
+ * @throws DatabaseException if there is a problem with the store formats
+ * @throws AMQException if there is an issue creating Qpid data structures
+ */
+ public void upgradeFromVersion(int version, File fromDir, File toDir) throws Exception
+ {
+
+ // Note the name of the Vhosts is not important, the store doesnot record the name of the vhost.
+ _newVirtualHost = new VirtualHost("Upgraded", new MemoryMessageStore());
+ _oldVirtualHost = new VirtualHost("Old", new MemoryMessageStore());
+
+ //Create a new messageStore
+ _newMessageStore = new BDBMessageStore();
+ _newMessageStore.configure(_newVirtualHost, toDir);
+
+ //Load the old MessageStore
+ switch (version)
+ {
+ default:
+ case 1:
+ _oldMessageStore = new BDBMessageStore(1);
+ _oldMessageStore.configure(_oldVirtualHost, fromDir);
+ upgradeFromVersion_1();
+ break;
+ }
+
+ _oldMessageStore.close();
+ _newMessageStore.close();
+
+ _newVirtualHost.close();
+ _oldVirtualHost.close();
+
+ //Shutdown the AR that the Vhosts will have created.
+ ApplicationRegistry.remove(1);
+ }
+
+ private void upgradeFromVersion_1() throws AMQException, DatabaseException
+ {
+ //Migrate _messageMetaDataDb;
+ moveContents(_oldMessageStore.getMetaDataDb(), _newMessageStore.getMetaDataDb());
+
+ //Migrate _messageContentDb;
+ moveContents(_oldMessageStore.getContentDb(), _newMessageStore.getContentDb());
+
+ //Migrate _queueDb;
+ //Get the oldMessageStore Tuple Binding which does the parsing
+ final TupleBinding queueTupleBinding = _oldMessageStore.getQueueTupleBindingFactory().getInstance();
+ _oldMessageStore.visitQueues(new BDBMessageStore.DatabaseVisitor()
+ {
+ public void visit(DatabaseEntry key, DatabaseEntry value) throws AMQException
+ {
+ AMQQueue queue = (AMQQueue) queueTupleBinding.entryToObject(value);
+
+ _newMessageStore.createQueue(queue);
+ //
+ _newMessageStore.getQueueRegistry().registerQueue(queue);
+ //or
+ //queue.stop();
+ // As the queue will create a thread pool message delivery that needs to be shutdown
+ // for the broker to cleanly stop.
+ }
+ });
+
+ //Migrate _deliveryDb;
+ moveContents(_oldMessageStore.getDeliveryDb(), _newMessageStore.getDeliveryDb());
+
+ //Migrate _exchangeDb;
+ moveContents(_oldMessageStore.getExchangesDb(), _newMessageStore.getExchangesDb());
+
+ //Migrate _queueBindingsDb;
+ final TupleBinding bindingTupleBinding = _oldMessageStore.getBindingTupleBindingFactory().getInstance();
+ _oldMessageStore.visitBindings(new BDBMessageStore.DatabaseVisitor()
+ {
+ public void visit(DatabaseEntry key, DatabaseEntry value) throws AMQException, DatabaseException
+ {
+ BindingKey queueBinding = (BindingKey) bindingTupleBinding.entryToObject(key);
+
+ TupleBinding newBindingTupleBinding = _newMessageStore.getBindingTupleBindingFactory().getInstance();
+
+ DatabaseEntry newKey = new DatabaseEntry();
+ newBindingTupleBinding.objectToEntry(queueBinding, newKey);
+
+ ByteBinding.byteToEntry((byte) 0, value);
+ _newMessageStore.getBindingsDb().put(null, newKey, value);
+ }
+ });
+
+ }
+
+ private void moveContents(Database oldDatabase, final Database newDatabase) throws AMQException, DatabaseException
+ {
+ _oldMessageStore.visitDatabase(oldDatabase, new BDBMessageStore.DatabaseVisitor()
+ {
+ public void visit(DatabaseEntry key, DatabaseEntry value) throws AMQException, DatabaseException
+ {
+ newDatabase.put(null, key, value);
+ }
+ });
+
+ }
+
+ private static void usage()
+ {
+ System.out.println("usage: -fromDir <path-to-store-to-upgrade> -toDir <path-to-location-to-write-upgraded-db>");
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ String fromDir, toDir;
+
+ if (args.length < 4 ||
+ (!args[0].equals(FROM_DIR) && !args[2].equals(TO_DIR)))
+ {
+ usage();
+ System.exit(1);
+ }
+
+ fromDir = args[1];
+ toDir = args[3];
+
+ new BDBStoreUpgrade(fromDir, toDir).upgradeFromVersion(1);
+
+ System.out.println("Upgrade complete");
+ }
+}
17 years, 8 months
rhmessaging commits: r2368 - in store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb: tuples and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2008-09-02 10:30:22 -0400 (Tue, 02 Sep 2008)
New Revision: 2368
Added:
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTupleBindingFactory.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_1.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_2.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTupleBindingFactory.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_1.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_2.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/TupleBindingFactory.java
Removed:
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BindingTB.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/QueueTB.java
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
Log:
RHM-5 : Created a version aware tuples to load the two database formats we now have
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2008-08-29 14:36:01 UTC (rev 2367)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -43,9 +43,13 @@
import org.apache.qpid.server.queue.AMQQueueFactory;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.StoreContext;
+import org.apache.qpid.server.store.berkeleydb.tuples.QueueTupleBindingFactory;
+import org.apache.qpid.server.store.berkeleydb.tuples.BindingTupleBindingFactory;
+import org.apache.qpid.server.store.berkeleydb.tuples.QueueTuple;
import org.apache.qpid.server.txn.NonTransactionalContext;
import org.apache.qpid.server.txn.TransactionalContext;
import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.mina.common.TrafficMask;
import java.io.File;
import java.util.ArrayList;
@@ -73,8 +77,12 @@
{
private static final Logger _log = Logger.getLogger(BDBMessageStore.class);
- private static final String ENVIRONMENT_PATH_PROPERTY = "environment-path";
+ private static final int DATABASE_FORMAT_VERSION = 2;
+ private static final String DATABASE_FORMAT_VERSION_PROPERTY = "version";
+
+ public static final String ENVIRONMENT_PATH_PROPERTY = "environment-path";
+
private Environment _environment;
private static final String MESSAGEMETADATADB_NAME = "messageMetaDataDb";
@@ -123,10 +131,19 @@
private Map<AMQShortString, Long> _queueNameToIdMap = new ConcurrentHashMap<AMQShortString, Long>();
+ // Factory Classes to create the TupleBinding objects that relfect the version instance of this BDBStore
+
+ private QueueTupleBindingFactory _queueTupleBindingFactory;
+ private BindingTupleBindingFactory _bindingTupleBindingFactory;
+
+ /** The data version this store should run with */
+ private int _version;
+
private enum State
{
INITIAL,
CONFIGURING,
+ CONFIGURED,
RECOVERING,
STARTED,
CLOSING,
@@ -135,6 +152,16 @@
private State _state = State.INITIAL;
+ public BDBMessageStore()
+ {
+ this(DATABASE_FORMAT_VERSION);
+ }
+
+ public BDBMessageStore(int version)
+ {
+ _version = version;
+ }
+
/**
* Called after instantiation in order to configure the message store. A particular implementation can define
* whatever parameters it wants.
@@ -150,10 +177,6 @@
public void configure(VirtualHost virtualHost, String base, Configuration config) throws Exception
{
- stateTransition(State.INITIAL, State.CONFIGURING);
-
- _log.info("Configuring BDB message store");
-
File environmentPath = new File(config.getString(base + "." + ENVIRONMENT_PATH_PROPERTY, "bdbEnv"));
if (!environmentPath.exists())
{
@@ -164,24 +187,60 @@
}
}
- createEnvironment(environmentPath);
- openDatabases();
- _virtualHost = virtualHost;
+ _version = config.getInt(base + "." + DATABASE_FORMAT_VERSION_PROPERTY, 2);
- _commitThread.start();
+ configure(virtualHost, environmentPath);
+ }
- upgradeIfNecessary();
+ public void configure(File environmentPath) throws AMQException, DatabaseException
+ {
+ configure(null, environmentPath);
+ }
+ public void configure(VirtualHost virtualHost, File environmentPath) throws AMQException, DatabaseException
+ {
+ stateTransition(State.INITIAL, State.CONFIGURING);
+
+ _log.info("Configuring BDB message store");
+
+ if (virtualHost != null)
+ {
+ setVirtualHost(virtualHost);
+ createTupleBindingFactories(_version);
+ }
+
+ setupStore(environmentPath);
+
+ stateTransition(State.CONFIGURING, State.CONFIGURED);
+
// this recovers durable queues and persistent messages
- recover();
+ if (virtualHost != null)
+ {
+ recover();
+ }
+ }
- stateTransition(State.RECOVERING, State.STARTED);
+ private void setupStore(File storePath) throws DatabaseException, AMQException
+ {
+ checkState(State.CONFIGURING);
+
+ createEnvironment(storePath);
+
+ openDatabases();
+
+ _commitThread.start();
}
- private void upgradeIfNecessary()
+ protected void startStore() throws AMQException
{
+ stateTransition(State.CONFIGURED, State.STARTED);
+ }
+ private void createTupleBindingFactories(int version)
+ {
+ _queueTupleBindingFactory = new QueueTupleBindingFactory(version, _virtualHost);
+ _bindingTupleBindingFactory = new BindingTupleBindingFactory(version, _virtualHost);
}
private synchronized void stateTransition(State requiredState, State newState) throws AMQException
@@ -203,7 +262,7 @@
}
}
- void createEnvironment(File environmentPath) throws DatabaseException
+ private void createEnvironment(File environmentPath) throws DatabaseException
{
_log.info("BDB message store using environment path " + environmentPath.getAbsolutePath());
EnvironmentConfig envConfig = new EnvironmentConfig();
@@ -213,7 +272,7 @@
_environment = new Environment(environmentPath, envConfig);
}
- protected void openDatabases() throws DatabaseException
+ private void openDatabases() throws DatabaseException
{
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
@@ -493,16 +552,15 @@
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
- BindingTB binding = new BindingTB(_virtualHost);
-
BindingKey queueBinding =
new BindingKey(exchange.getName(), null, null, null);
- EntryBinding keyBinding = new BindingTB(_virtualHost);
+ EntryBinding<BindingKey> keyBinding = _bindingTupleBindingFactory.getInstance();
keyBinding.objectToEntry(queueBinding, key);
OperationStatus opStatus = cursor.getSearchKeyRange(key, value, LockMode.RMW);
+ TupleBinding binding = _bindingTupleBindingFactory.getInstance();
while (opStatus == OperationStatus.SUCCESS)
{
queueBinding = (BindingKey) binding.entryToObject(key);
@@ -538,7 +596,7 @@
cursor = _exchangeDb.openCursor(null, null);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
- ExchangeTB binding = new ExchangeTB(_virtualHost);
+ TupleBinding binding = new ExchangeTB(_virtualHost);
while (cursor.getNext(key, value, LockMode.RMW) == OperationStatus.SUCCESS)
{
Exchange exchange = (Exchange) binding.entryToObject(value);
@@ -579,8 +637,9 @@
if (_state != State.RECOVERING)
{
DatabaseEntry key = new DatabaseEntry();
- EntryBinding keyBinding = new BindingTB(_virtualHost);
+ EntryBinding keyBinding = _bindingTupleBindingFactory.getInstance();
keyBinding.objectToEntry(new BindingKey(exchange.getName(), queue.getName(), routingKey, args), key);
+
DatabaseEntry value = new DatabaseEntry();
ByteBinding.byteToEntry((byte) 0, value);
@@ -610,7 +669,7 @@
throws AMQException
{
DatabaseEntry key = new DatabaseEntry();
- EntryBinding keyBinding = new BindingTB(_virtualHost);
+ EntryBinding keyBinding = _bindingTupleBindingFactory.getInstance();
keyBinding.objectToEntry(new BindingKey(exchange.getName(), queue.getName(), routingKey, args), key);
try
@@ -652,10 +711,15 @@
_queueNameToIdMap.put(queue.getName(), queueId);
DatabaseEntry key = new DatabaseEntry();
+
EntryBinding keyBinding = new AMQShortStringTB();
keyBinding.objectToEntry(queue.getName(), key);
+
DatabaseEntry value = new DatabaseEntry();
- TupleBinding queueBinding = new QueueTB(_virtualHost, arguments);
+ TupleBinding queueBinding = _queueTupleBindingFactory.getInstance();
+
+ ((QueueTuple) queueBinding).setArguments(arguments);
+
queueBinding.objectToEntry(queue, value);
try
{
@@ -718,7 +782,7 @@
try
{
_queueDb.get(null, key, value, LockMode.RMW);
- QueueTB binding = new QueueTB(_virtualHost, null);
+ TupleBinding binding = _queueTupleBindingFactory.getInstance();
return (AMQQueue) binding.entryToObject(value);
}
@@ -1038,7 +1102,7 @@
public void recover() throws AMQException
{
- stateTransition(State.CONFIGURING, State.RECOVERING);
+ stateTransition(State.CONFIGURED, State.RECOVERING);
_log.info("Recovering persistent state...");
StoreContext context = new StoreContext();
@@ -1057,8 +1121,16 @@
catch (DatabaseException e)
{
abortTran(context);
+
throw new AMQException("Error recovering persistent state: " + e, e);
}
+ catch (Throwable ioobe)
+ {
+ abortTran(context);
+ throw new AMQException("Invalid database format. Please use upgrade tool.", ioobe);
+ }
+
+ stateTransition(State.RECOVERING, State.STARTED);
}
/**
@@ -1254,14 +1326,17 @@
cursor = _queueDb.openCursor(null, null);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry value = new DatabaseEntry();
- QueueTB binding = new QueueTB(_virtualHost, null);
+ TupleBinding binding = _queueTupleBindingFactory.getInstance();
while (cursor.getNext(key, value, LockMode.RMW) == OperationStatus.SUCCESS)
{
AMQQueue queue = (AMQQueue) binding.entryToObject(value);
- _virtualHost.getQueueRegistry().registerQueue(queue);
- queues.put(queue.getName(), queue);
- _log.info("Recovering queue " + queue.getName() + " with owner:"
- + ((queue.getOwner() == null) ? " <<null>> " : (" \"" + queue.getOwner() + "\" ")));
+ if (queue != null)
+ {
+ _virtualHost.getQueueRegistry().registerQueue(queue);
+ queues.put(queue.getName(), queue);
+ _log.info("Recovering queue " + queue.getName() + " with owner:"
+ + ((queue.getOwner() == null) ? " <<null>> " : (" \"" + queue.getOwner() + "\" ")));
+ }
}
return queues;
@@ -1275,6 +1350,117 @@
}
}
+ //public getters for the TupleBindingFactories
+
+ public QueueTupleBindingFactory getQueueTupleBindingFactory()
+ {
+ return _queueTupleBindingFactory;
+ }
+
+ public BindingTupleBindingFactory getBindingTupleBindingFactory()
+ {
+ return _bindingTupleBindingFactory;
+ }
+
+ //Package getters for the various databases used by the Store
+
+ Database getMetaDataDb()
+ {
+ return _messageMetaDataDb;
+ }
+
+ Database getContentDb()
+ {
+ return _messageContentDb;
+ }
+
+ Database getQueuesDb()
+ {
+ return _queueDb;
+ }
+
+ Database getDeliveryDb()
+ {
+ return _deliveryDb;
+ }
+
+ Database getExchangesDb()
+ {
+ return _exchangeDb;
+ }
+
+ Database getBindingsDb()
+ {
+ return _queueBindingsDb;
+ }
+
+ /** Visitor Interface so that each DatabaseEntry for a database can easily be processed. */
+ interface DatabaseVisitor
+ {
+ public void visit(DatabaseEntry entry, DatabaseEntry value) throws AMQException, DatabaseException;
+ }
+
+ void visitMetaDataDb(DatabaseVisitor visitor) throws DatabaseException, AMQException
+ {
+ visitDatabase(_messageMetaDataDb, visitor);
+ }
+
+ void visitContentDb(DatabaseVisitor visitor) throws DatabaseException, AMQException
+ {
+ visitDatabase(_messageContentDb, visitor);
+ }
+
+ void visitQueues(DatabaseVisitor visitor) throws DatabaseException, AMQException
+ {
+ visitDatabase(_queueDb, visitor);
+ }
+
+ void visitDelivery(DatabaseVisitor visitor) throws DatabaseException, AMQException
+ {
+ visitDatabase(_deliveryDb, visitor);
+ }
+
+ void visitExchanges(DatabaseVisitor visitor) throws DatabaseException, AMQException
+ {
+ visitDatabase(_exchangeDb, visitor);
+ }
+
+ void visitBindings(DatabaseVisitor visitor) throws DatabaseException, AMQException
+ {
+ visitDatabase(_queueBindingsDb, visitor);
+ }
+
+ /**
+ * Generic visitDatabase allows iteration through the specified database.
+ *
+ * @param database The database to visit
+ * @param visitor The visitor to give each entry to.
+ *
+ * @throws DatabaseException If there is a problem with the Database structure
+ * @throws AMQException If there is a programming error
+ */
+ void visitDatabase(Database database, DatabaseVisitor visitor) throws DatabaseException, AMQException
+ {
+ Cursor cursor = database.openCursor(null, null);
+
+ try
+ {
+ DatabaseEntry key = new DatabaseEntry();
+ DatabaseEntry value = new DatabaseEntry();
+ while (cursor.getNext(key, value, LockMode.RMW) == OperationStatus.SUCCESS)
+ {
+ visitor.visit(key, value);
+ }
+ }
+ finally
+ {
+ if (cursor != null)
+ {
+ cursor.close();
+ }
+ }
+ }
+
private static final class ProcessAction
{
private final AMQQueue _queue;
@@ -1402,6 +1588,8 @@
void setVirtualHost(VirtualHost virtualHost)
{
_virtualHost = virtualHost;
+
+ createTupleBindingFactories(_version);
}
void commit(Transaction tx) throws DatabaseException
@@ -1623,4 +1811,5 @@
}
}
}
+
}
Deleted: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BindingTB.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BindingTB.java 2008-08-29 14:36:01 UTC (rev 2367)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BindingTB.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -1,59 +0,0 @@
-package org.apache.qpid.server.store.berkeleydb;
-
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
-
-import com.sleepycat.bind.tuple.TupleBinding;
-import com.sleepycat.bind.tuple.TupleInput;
-import com.sleepycat.bind.tuple.TupleOutput;
-import com.sleepycat.je.DatabaseException;
-import org.apache.log4j.Logger;
-
-public class BindingTB extends TupleBinding
-{
- private static final Logger _log = Logger.getLogger(BindingTB.class);
-
- private final VirtualHost _virtualHost;
-
- public BindingTB(VirtualHost virtualHost)
- {
- _virtualHost = virtualHost;
- }
-
- public Object entryToObject(TupleInput tupleInput)
- {
- try
- {
- AMQShortString exchangeName = AMQShortStringEncoding.readShortString(tupleInput);
- AMQShortString queueName = AMQShortStringEncoding.readShortString(tupleInput);
- AMQShortString routingKey = AMQShortStringEncoding.readShortString(tupleInput);
- FieldTable arguments = FieldTableEncoding.readFieldTable(tupleInput);
-
- return new BindingKey(exchangeName, queueName, routingKey, arguments);
- }
- catch (DatabaseException e)
- {
- _log.error("Unable to create binding: " + e, e);
- return null;
- }
- }
-
- public void objectToEntry(Object object, TupleOutput tupleOutput)
- {
- BindingKey binding = (BindingKey) object;
-
- AMQShortStringEncoding.writeShortString(binding.getExchangeName(), tupleOutput);
- AMQShortStringEncoding.writeShortString(binding.getQueueName(), tupleOutput);
- AMQShortStringEncoding.writeShortString(binding.getRoutingKey(), tupleOutput);
- FieldTableEncoding.writeFieldTable(binding.getArguments(), tupleOutput);
-
- binding = (BindingKey) entryToObject(new TupleInput(tupleOutput.getBufferBytes()));
-
- System.err.println(binding.getExchangeName());
- System.err.println(binding.getQueueName());
- System.err.println(binding.getRoutingKey());
- System.err.println(binding.getArguments());
-
- }
-}
Deleted: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/QueueTB.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/QueueTB.java 2008-08-29 14:36:01 UTC (rev 2367)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/QueueTB.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -1,79 +0,0 @@
-/*
- *
- * Copyright (c) 2006 The Apache Software Foundation
- *
- * Licensed 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;
-
-import com.sleepycat.bind.tuple.TupleBinding;
-import com.sleepycat.bind.tuple.TupleInput;
-import com.sleepycat.bind.tuple.TupleOutput;
-import com.sleepycat.je.DatabaseException;
-import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.AMQQueueFactory;
-import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.AMQException;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.framing.FieldTable;
-import org.apache.log4j.Logger;
-
-public class QueueTB extends TupleBinding
-{
- private static final Logger _log = Logger.getLogger(QueueTB.class);
-
- private final VirtualHost _virtualHost;
- private final FieldTable _arguments;
-
- public QueueTB(VirtualHost virtualHost, FieldTable arguments)
- {
- _virtualHost = virtualHost;
- _arguments = arguments;
- }
-
- public Object entryToObject(TupleInput tupleInput)
- {
- try
- {
- AMQShortString name = AMQShortStringEncoding.readShortString(tupleInput);
- AMQShortString owner = AMQShortStringEncoding.readShortString(tupleInput);
- FieldTable arguments = FieldTableEncoding.readFieldTable(tupleInput);
-
- try
- {
- return AMQQueueFactory.createAMQQueueImpl(name, true, owner, false, _virtualHost, arguments);
- }
- catch (AMQException e)
- {
- _log.error("Unable to create queue: " + e, e);
- return null;
- }
- }
- catch (DatabaseException e)
- {
- _log.error("Unable to create binding: " + e, e);
- return null;
- }
- }
-
- public void objectToEntry(Object object, TupleOutput tupleOutput)
- {
- AMQQueue queue = (AMQQueue) object;
-
- AMQShortStringEncoding.writeShortString(queue.getName(), tupleOutput);
- AMQShortStringEncoding.writeShortString(queue.getOwner(), tupleOutput);
- FieldTableEncoding.writeFieldTable(_arguments, tupleOutput);
-
- }
-}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,27 @@
+/*
+ *
+ * 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.tuples;
+
+import org.apache.qpid.framing.FieldTable;
+
+public interface BindingTuple
+{
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTupleBindingFactory.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTupleBindingFactory.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTupleBindingFactory.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.tuples;
+
+import com.sleepycat.bind.tuple.TupleBinding;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+
+public class BindingTupleBindingFactory extends TupleBindingFactory
+{
+ public BindingTupleBindingFactory(int version, VirtualHost virtualhost)
+ {
+ super(version, virtualhost);
+ }
+
+ public TupleBinding getInstance()
+ {
+ switch (_version)
+ {
+ default:
+ case 2:
+ return new BindingTuple_2(_virtualhost);
+ case 1:
+ return new BindingTuple_1(_virtualhost);
+ }
+ }
+}
Copied: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_1.java (from rev 2292, store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BindingTB.java)
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_1.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_1.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,60 @@
+package org.apache.qpid.server.store.berkeleydb.tuples;
+
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding;
+import org.apache.qpid.server.store.berkeleydb.FieldTableEncoding;
+import org.apache.qpid.server.store.berkeleydb.BindingKey;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+
+import com.sleepycat.bind.tuple.TupleBinding;
+import com.sleepycat.bind.tuple.TupleInput;
+import com.sleepycat.bind.tuple.TupleOutput;
+import org.apache.log4j.Logger;
+
+public class BindingTuple_1 extends TupleBinding implements BindingTuple
+{
+ protected static final Logger _log = Logger.getLogger(BindingTuple.class);
+
+ protected VirtualHost _virtualhost;
+
+ public BindingTuple_1(VirtualHost virtualHost)
+ {
+ if (virtualHost == null)
+ {
+ throw new NullPointerException("Virtualhost cannot be null");
+ }
+ _virtualhost = virtualHost;
+ }
+
+ public Object entryToObject(TupleInput tupleInput)
+ {
+ AMQShortString exchangeName = AMQShortStringEncoding.readShortString(tupleInput);
+ AMQShortString queueName = AMQShortStringEncoding.readShortString(tupleInput);
+ AMQShortString routingKey = AMQShortStringEncoding.readShortString(tupleInput);
+
+ return createNewBindingKey(exchangeName, queueName, routingKey);
+ }
+
+ public void objectToEntry(Object object, TupleOutput tupleOutput)
+ {
+ BindingKey binding = (BindingKey) object;
+
+ AMQShortStringEncoding.writeShortString(binding.getExchangeName(), tupleOutput);
+ AMQShortStringEncoding.writeShortString(binding.getQueueName(), tupleOutput);
+ AMQShortStringEncoding.writeShortString(binding.getRoutingKey(), tupleOutput);
+ }
+
+ private Object createNewBindingKey(AMQShortString exchangeName, AMQShortString queueName, AMQShortString routingKey)
+ {
+ return createNewBindingKey(exchangeName, queueName, routingKey, null);
+ }
+
+ // Addition for Version 2 of this table
+ protected Object createNewBindingKey(AMQShortString exchangeName, AMQShortString queueName,
+ AMQShortString routingKey, FieldTable arguments)
+ {
+ return new BindingKey(exchangeName, queueName, routingKey, arguments);
+ }
+
+}
Property changes on: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_1.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_2.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_2.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/BindingTuple_2.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,58 @@
+package org.apache.qpid.server.store.berkeleydb.tuples;
+
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding;
+import org.apache.qpid.server.store.berkeleydb.FieldTableEncoding;
+import org.apache.qpid.server.store.berkeleydb.BindingKey;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+
+import com.sleepycat.bind.tuple.TupleBinding;
+import com.sleepycat.bind.tuple.TupleInput;
+import com.sleepycat.bind.tuple.TupleOutput;
+import com.sleepycat.je.DatabaseException;
+import org.apache.log4j.Logger;
+
+public class BindingTuple_2 extends BindingTuple_1 implements BindingTuple
+{
+
+ public BindingTuple_2(VirtualHost virtualHost)
+ {
+ super(virtualHost);
+ }
+
+ public Object entryToObject(TupleInput tupleInput)
+ {
+ AMQShortString exchangeName = AMQShortStringEncoding.readShortString(tupleInput);
+ AMQShortString queueName = AMQShortStringEncoding.readShortString(tupleInput);
+ AMQShortString routingKey = AMQShortStringEncoding.readShortString(tupleInput);
+
+ FieldTable arguments;
+
+ // Addition for Version 2 of this table
+ try
+ {
+ arguments = FieldTableEncoding.readFieldTable(tupleInput);
+ }
+ catch (DatabaseException e)
+ {
+ _log.error("Unable to create binding: " + e, e);
+ return null;
+ }
+
+ return createNewBindingKey(exchangeName, queueName, routingKey, arguments);
+ }
+
+ public void objectToEntry(Object object, TupleOutput tupleOutput)
+ {
+ BindingKey binding = (BindingKey) object;
+
+ AMQShortStringEncoding.writeShortString(binding.getExchangeName(), tupleOutput);
+ AMQShortStringEncoding.writeShortString(binding.getQueueName(), tupleOutput);
+ AMQShortStringEncoding.writeShortString(binding.getRoutingKey(), tupleOutput);
+
+ // Addition for Version 2 of this table
+ FieldTableEncoding.writeFieldTable(binding.getArguments(), tupleOutput);
+ }
+
+}
\ No newline at end of file
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.tuples;
+
+import org.apache.qpid.framing.FieldTable;
+
+public interface QueueTuple
+{
+ // Addition for Version 2
+ public void setArguments(FieldTable arguments);
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTupleBindingFactory.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTupleBindingFactory.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTupleBindingFactory.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.tuples;
+
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import com.sleepycat.bind.tuple.TupleBinding;
+
+public class QueueTupleBindingFactory extends TupleBindingFactory
+{
+ public QueueTupleBindingFactory(int version, VirtualHost virtualHost)
+ {
+ super(version,virtualHost);
+ }
+
+ public TupleBinding getInstance()
+ {
+ switch (_version)
+ {
+ default:
+ case 2:
+ return new QueueTuple_2(_virtualhost);
+ case 1:
+ return new QueueTuple_1(_virtualhost);
+ }
+ }
+}
Copied: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_1.java (from rev 2292, store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/QueueTB.java)
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_1.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_1.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,87 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.tuples;
+
+import com.sleepycat.bind.tuple.TupleBinding;
+import com.sleepycat.bind.tuple.TupleInput;
+import com.sleepycat.bind.tuple.TupleOutput;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.log4j.Logger;
+
+public class QueueTuple_1 extends TupleBinding implements QueueTuple
+{
+ protected static final Logger _logger = Logger.getLogger(QueueTuple.class);
+
+ protected final VirtualHost _virtualHost;
+
+ public QueueTuple_1(VirtualHost virtualHost)
+ {
+ if (virtualHost == null)
+ {
+ throw new NullPointerException("Virtualhost cannot be null");
+ }
+ _virtualHost = virtualHost;
+ }
+
+ public Object entryToObject(TupleInput tupleInput)
+ {
+ AMQShortString name = AMQShortStringEncoding.readShortString(tupleInput);
+ AMQShortString owner = AMQShortStringEncoding.readShortString(tupleInput);
+
+ return createNewQueue(name, owner);
+ }
+
+ public void objectToEntry(Object object, TupleOutput tupleOutput)
+ {
+ AMQQueue queue = (AMQQueue) object;
+
+ AMQShortStringEncoding.writeShortString(queue.getName(), tupleOutput);
+ AMQShortStringEncoding.writeShortString(queue.getOwner(), tupleOutput);
+ }
+
+ // Addition for Version 2 of this table
+ public void setArguments(FieldTable arguments)
+ {
+ //no-op
+ }
+
+ protected Object createNewQueue(AMQShortString name, AMQShortString owner)
+ {
+ return createNewQueue(name, owner, null);
+ }
+
+ // Addition for Version 2 of this table
+ protected Object createNewQueue(AMQShortString name, AMQShortString owner, FieldTable arguments)
+ {
+ try
+ {
+ return AMQQueueFactory.createAMQQueueImpl(name, true, owner, false, _virtualHost, arguments);
+ }
+ catch (AMQException e)
+ {
+ _logger.error("Unable to create queue: " + e, e);
+ return null;
+ }
+ }
+}
Property changes on: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_1.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_2.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_2.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/QueueTuple_2.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,75 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.tuples;
+
+import com.sleepycat.bind.tuple.TupleInput;
+import com.sleepycat.bind.tuple.TupleOutput;
+import com.sleepycat.je.DatabaseException;
+import org.apache.qpid.server.queue.AMQQueue;
+import org.apache.qpid.server.queue.AMQQueueFactory;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.store.berkeleydb.AMQShortStringEncoding;
+import org.apache.qpid.server.store.berkeleydb.FieldTableEncoding;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.framing.FieldTable;
+
+public class QueueTuple_2 extends QueueTuple_1
+{
+ protected FieldTable _arguments;
+
+ public QueueTuple_2(VirtualHost virtualHost)
+ {
+ super(virtualHost);
+ }
+
+ public Object entryToObject(TupleInput tupleInput)
+ {
+ try
+ {
+ AMQShortString name = AMQShortStringEncoding.readShortString(tupleInput);
+ AMQShortString owner = AMQShortStringEncoding.readShortString(tupleInput);
+ // Addition for Version 2 of this table
+ FieldTable arguments = FieldTableEncoding.readFieldTable(tupleInput);
+
+ return createNewQueue(name, owner, arguments);
+ }
+ catch (DatabaseException e)
+ {
+ _logger.error("Unable to create binding: " + e, e);
+ return null;
+ }
+
+ }
+
+ public void objectToEntry(Object object, TupleOutput tupleOutput)
+ {
+ AMQQueue queue = (AMQQueue) object;
+
+ AMQShortStringEncoding.writeShortString(queue.getName(), tupleOutput);
+ AMQShortStringEncoding.writeShortString(queue.getOwner(), tupleOutput);
+ // Addition for Version 2 of this table
+ FieldTableEncoding.writeFieldTable(_arguments, tupleOutput);
+ }
+
+ // Addition for Version 2 of this table
+ public void setArguments(FieldTable arguments)
+ {
+ _arguments = arguments;
+ }
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/TupleBindingFactory.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/TupleBindingFactory.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/tuples/TupleBindingFactory.java 2008-09-02 14:30:22 UTC (rev 2368)
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.tuples;
+
+import com.sleepycat.bind.tuple.TupleBinding;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+
+public abstract class TupleBindingFactory
+{
+ protected int _version;
+
+ protected VirtualHost _virtualhost;
+
+ public TupleBindingFactory(int version, VirtualHost virtualhost)
+ {
+ if (virtualhost == null)
+ {
+ throw new NullPointerException("Virtualhost cannot be null");
+ }
+
+ _version = version;
+ _virtualhost = virtualhost;
+ }
+
+ public abstract TupleBinding getInstance();
+}
17 years, 8 months