[rhmessaging-commits] rhmessaging commits: r2431 - in store/branches/java/broker-queue-refactor/java: bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb and 4 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Tue Sep 9 08:19:01 EDT 2008
Author: aidanskinner
Date: 2008-09-09 08:19:01 -0400 (Tue, 09 Sep 2008)
New Revision: 2431
Added:
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/MessageReSendTest.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/QueueDeleteWhilstRoutingTest.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StoreContextRaceConditionTest.java
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/BDBVMTestCase.java
store/branches/java/broker-queue-refactor/java/bdbstore/test-provider.properties
Removed:
store/branches/java/broker-queue-refactor/java/bdbstorebackup/ReadMe.txt
store/branches/java/broker-queue-refactor/java/bdbstorebackup/bin/bdbstorebackup.sh
store/branches/java/broker-queue-refactor/java/bdbstorebackup/pom.xml
store/branches/java/broker-queue-refactor/java/bdbstorebackup/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java
Modified:
store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java
Log:
Merge all changes from M2.x branch and remove common code from tests. Remove dead bdbstorebackup directory.
Modified: store/branches/java/broker-queue-refactor/java/bdbstore/build.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-08 17:09:10 UTC (rev 2430)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/build.xml 2008-09-09 12:19:01 UTC (rev 2431)
@@ -111,10 +111,11 @@
<sysproperty key="example.plugin.target" value="${project.root}/build/lib/plugins"/>
<sysproperty key="QPID_HOME" value="${project.root}"/>
<sysproperty key="QPID_WORK" value="${project.root}/build/test-work"/>
+ <sysproperty key="BDB_WORK" value="${project.root}/build/test-work/bdbstore"/>
<sysproperty key="BDB_HOME" value="${project.root}"/>
+ <sysproperty key="test.excludes" value="false"/>
-
<formatter type="plain"/>
<formatter type="xml"/>
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-08 17:09:10 UTC (rev 2430)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java 2008-09-09 12:19:01 UTC (rev 2431)
@@ -34,6 +34,7 @@
import org.apache.qpid.server.exchange.DirectExchange;
import org.apache.qpid.server.virtualhost.VirtualHost;
import org.apache.qpid.server.store.StoreContext;
+import org.apache.qpid.server.store.berkeleydb.utils.BDBVMTestCase;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.MessageMetaData;
import org.apache.qpid.server.queue.AMQQueueFactory;
@@ -48,12 +49,13 @@
import java.util.LinkedList;
import java.util.List;
-public class BDBStoreTest extends TestCase
+public class BDBStoreTest extends BDBVMTestCase
{
private static final Logger _log = Logger.getLogger(BDBStoreTest.class);
private BDBMessageStore _store;
-
+ private String STORE_LOCATION = System.getProperty("BDB_WORK") + "/bdbTestEnv";
+
private StoreContext _storeContext = new StoreContext();
private VirtualHost _virtualHost;
@@ -67,8 +69,7 @@
private static final AMQShortString EXCHANGE1 = new AMQShortString("exchange1");
private static volatile int _loops;
- private String TEST_LOCATION = "bdbTestEnv";
- File BDB_DIR = new File(TEST_LOCATION);
+ File BDB_DIR = new File(STORE_LOCATION);
public void setUp() throws Exception
{
@@ -79,6 +80,8 @@
ApplicationRegistry.initialise(new NullApplicationRegistry());
+ File bdbDir = new File(STORE_LOCATION);
+ deleteDirectory(bdbDir);
BDB_DIR.mkdirs();
_store = new BDBMessageStore();
@@ -92,28 +95,13 @@
_txnContext = new NonTransactionalContext(_store, _storeContext, null, new LinkedList<RequiredDeliveryException>());
}
- private void deleteDirectory(File path) throws InterruptedException
- {
- if (path.isDirectory())
- {
- for (File file : path.listFiles())
- {
- deleteDirectory(file);
- }
- }
- else
- {
- path.delete();
- }
- }
-
private void reload() throws Exception
{
_virtualHost.close();
PropertiesConfiguration env = new PropertiesConfiguration();
- env.addProperty("store.environment-path", "bdbTestEnv");
+ env.addProperty("store.environment-path", STORE_LOCATION);
env.addProperty("store.class", "org.apache.qpid.server.store.berkeleydb.BDBMessageStore");
_virtualHost = new VirtualHost("test", env);
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/MessageReSendTest.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/MessageReSendTest.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/MessageReSendTest.java 2008-09-09 12:19:01 UTC (rev 2431)
@@ -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;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+
+import org.apache.qpid.server.store.berkeleydb.utils.BDBVMTestCase;
+
+public class MessageReSendTest extends BDBVMTestCase
+{
+ protected static final String MESSAGE_ID_PROPERTY = "MessageIDProperty";
+
+ public void test() throws Exception
+ {
+
+ //Send Message
+ sendMessages(getConnection(), 1);
+ System.err.println("SEND");
+
+ //Create Connection
+ Connection connection = getConnection();
+ System.err.println("RECEIVE");
+
+ //Receive Message
+ checkMessagesOnQueue(connection, _queue, 1);
+ //Close connections
+ connection.close();
+ System.err.println("VALIDATE");
+
+ //Reconnect and ensure message is gone
+ connection = getConnection();
+ checkMessagesOnQueue(connection, _queue, 0);
+ connection.close();
+
+ try
+ {
+ //restart broker
+ stopBroker(1);
+ System.err.println("START");
+ startBroker(1);
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+
+ //reconnect and ensure message is gone
+ connection = getConnection();
+ checkMessagesOnQueue(connection, _queue, 0);
+ connection.close();
+ }
+
+ private void checkMessagesOnQueue(Connection connection, Queue queue, int count)
+ {
+ try
+ {
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer = session.createConsumer(queue);
+
+ connection.start();
+
+ Message msg = consumer.receive(1000);
+
+ if (count > 0)
+ {
+ int received = 1;
+ while (received < count)
+ {
+ assertNotNull(msg);
+ assertEquals(received, msg.getIntProperty(MESSAGE_ID_PROPERTY));
+
+ //get next message
+ msg = consumer.receive(1000);
+ }
+
+ }
+ else
+ {
+ assertNull("Received Message when none expected", msg);
+ }
+ }
+ catch (JMSException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/QueueDeleteWhilstRoutingTest.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/QueueDeleteWhilstRoutingTest.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/QueueDeleteWhilstRoutingTest.java 2008-09-09 12:19:01 UTC (rev 2431)
@@ -0,0 +1,204 @@
+/*
+ *
+ * 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.log4j.Logger;
+import org.apache.qpid.server.store.berkeleydb.utils.BDBVMTestCase;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.NamingException;
+import java.io.File;
+
+public class QueueDeleteWhilstRoutingTest extends BDBVMTestCase
+{
+ private static final Logger _logger = Logger.getLogger(QueueDeleteWhilstRoutingTest.class);
+
+ MessageConsumer _consumer1, _consumer2;
+ Session _clientSession1;
+ Connection _producerConnection, _clientConnection1;
+
+ int brokerID = 2;
+
+ /**
+ * Issue analysis:
+ * When an Exclusive NonDurable queue is created a queueDelete task is added to the sessionCloseTaskList
+ * When the last consumer on an autodelete queue closes queueDelete is called.
+ *
+ * Hence the queue is delted twice. Which would hurt the ref counting of all messages in the consumers
+ * unacked map
+ *
+ * Test Plan:
+ *
+ * Create two subscribers same topic
+ *
+ * Send two messages
+ *
+ * consume one from each consumer to validate that all is good
+ *
+ * Shutdown persistent broker
+ *
+ * restart.
+ *
+ * Expecting failure in broker startup.
+ * @throws Exception
+ */
+ public void test() throws Exception
+ {
+ _logger.debug("Performing receives");
+
+ Message msg1 = _consumer1.receive(1000);
+
+ assertNotNull(msg1);
+
+ //Check message recevied ok
+ assertEquals("Message 1 not received on consumer 1", "Message: 1", ((TextMessage) msg1).getText());
+
+ _consumer1.close();
+
+ _clientConnection1.close();
+
+ _producerConnection.close();
+
+ try
+ {
+ _logger.debug("Shutdown broker in 1 second");
+ Thread.sleep(4000);
+ }
+ catch (InterruptedException e)
+ {
+ fail(e.getMessage());
+ }
+
+ //Stop the broker
+ stopBroker(brokerID);
+
+ try
+ {
+ _logger.debug("Restart broker in 2 second");
+ Thread.sleep(4000);
+ }
+ catch (InterruptedException e)
+ {
+ fail(e.getMessage());
+ }
+
+ //Start the broker
+ try
+ {
+ //FIXME startVMBroker(brokerID, _persistentConfigFile);
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+
+ //Test Connection
+ _clientConnection1 = getConnection();
+
+ _clientConnection1.close();
+ }
+
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ //FIXME startVMBroker(brokerID, _persistentConfigFile);
+
+ // Initialise ACLs.
+
+ //Create Consumers
+ //Create consumer on the temp queue
+ Queue requestQueue = (Queue) getInitialContext().lookup("queue");
+
+ _clientConnection1 = getConnection();
+ _clientSession1 = _clientConnection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ _queue = _clientSession1.createTemporaryQueue();
+
+ _consumer1 = _clientSession1.createConsumer(_queue);
+
+ //Start the connection
+ _clientConnection1.start();
+
+ //Create Producer
+ _producerConnection = getConnection();
+ final Session producerSession = _producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //Create a listener for the messages
+ producerSession.createConsumer(requestQueue).setMessageListener(new MessageListener()
+ {
+ public void onMessage(final Message message)
+ {
+ try
+ {
+ Destination responseQueue = message.getJMSReplyTo();
+
+ //Send a response to the message
+ producerSession.createProducer(responseQueue)
+ .send(producerSession.createTextMessage(((TextMessage) message).getText()));
+ }
+ catch (JMSException e)
+ {
+ fail(e.getMessage());
+ }
+ }
+ });
+ //Start the connection
+ _producerConnection.start();
+
+ //Send two messages
+
+ MessageProducer _clientProducer = _clientSession1.createProducer(requestQueue);
+ Message msg = _clientSession1.createTextMessage("Message: 1");
+ msg.setJMSReplyTo(_queue);
+ _clientProducer.send(msg);
+
+ msg = _clientSession1.createTextMessage("Message: 2");
+ msg.setJMSReplyTo(_queue);
+ _clientProducer.send(msg);
+ }
+
+ public void tearDown() throws Exception
+ {
+ //Stop the broker
+ try
+ {
+ stopBroker(brokerID);
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+
+ super.tearDown();
+ }
+
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StoreContextRaceConditionTest.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StoreContextRaceConditionTest.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/StoreContextRaceConditionTest.java 2008-09-09 12:19:01 UTC (rev 2431)
@@ -0,0 +1,161 @@
+/*
+ *
+ * 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 javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.store.berkeleydb.utils.BDBVMTestCase;
+
+public class StoreContextRaceConditionTest extends BDBVMTestCase
+{
+ private static final Logger _logger = Logger.getLogger(StoreContextRaceConditionTest.class);
+
+ public void test() throws InterruptedException, NamingException, JMSException
+ {
+ Runnable test = new Runnable()
+ {
+ public void run()
+ {
+
+ //Create Consumer
+ Connection connection = null;
+
+ Session session = null;
+ try
+ {
+ try
+ {
+ connection = getConnection();
+ }
+ catch (Exception e)
+ {
+ fail("Unable to obtain connection.");
+ }
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ }
+ catch (JMSException e)
+ {
+ return;
+ }
+
+ try
+ {
+ int run = 0;
+ while (run < 1)
+ {
+ try
+ {
+ //Stop the connection to prevent flow
+ connection.stop();
+ //Create Consumer to receive msgs
+ MessageConsumer consumer = session.createConsumer(_queue);
+
+ //Send one message to hold up the Async Delivery from purging
+ _logger.info("***** CREATED Consumer");
+ _TimeToLive = 0L;
+ sendMessages(1);
+ _logger.info("***** SENT msg 1");
+ //Send 1000 msgs that will time out
+ _TimeToLive = 1000L;
+ sendMessages(50);
+ _logger.info("***** SENT TTL msgs");
+
+ //Timeout Messages - Note that we
+ Thread.sleep(1000);
+ _logger.info("***** SLEEP");
+
+ //Allw the messages to flow to us
+ connection.start();
+ _logger.info("***** START Consumer");
+ //*** Starts Async process
+
+ //Remove the first message so that the async will occcur and start purging.
+ consumer.receive(1000);
+ _logger.info("***** RECEIVE Consumer");
+
+ sendMessages(50);
+ _logger.info("***** SENT TTL msgs");
+
+ //Close the consumer freeing the QHK thread to doing work
+ consumer.close();
+ _logger.info("***** CLOSE Consumer");
+ //** Allows QueueHouskeeping to run.
+ sendMessages(50);
+ _logger.info("***** SENT TTL msgs");
+
+ run++;
+ }
+ catch (JMSException e)
+ {
+
+ }
+ catch (InterruptedException e)
+ {
+ }
+ }
+ }
+ finally
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ _logger.info("***** Test Done");
+ }
+ }
+ };
+
+ int MAX_THREADS = 1;
+
+ Thread[] threads = new Thread[MAX_THREADS];
+
+ for (int concurentClients = 0; concurentClients < MAX_THREADS; concurentClients++)
+ {
+ threads[concurentClients] = new Thread(test);
+ threads[concurentClients].start();
+ }
+
+ for (int concurentClients = 0; concurentClients < MAX_THREADS; concurentClients++)
+ {
+ threads[concurentClients].join();
+ }
+ }
+
+ public static void main(String[] args) throws Exception, InterruptedException
+ {
+ StoreContextRaceConditionTest scrc = new StoreContextRaceConditionTest();
+
+ scrc.setUp();
+ scrc.test();
+// scrc.tearDown();
+ }
+
+}
Added: store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/BDBVMTestCase.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/BDBVMTestCase.java (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/utils/BDBVMTestCase.java 2008-09-09 12:19:01 UTC (rev 2431)
@@ -0,0 +1,170 @@
+/*
+ *
+ * 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 java.io.File;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.log4j.Level;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+import org.apache.qpid.server.registry.ConfigurationFileApplicationRegistry;
+import org.apache.qpid.test.utils.QpidTestCase;
+
+public class BDBVMTestCase extends QpidTestCase
+{
+ public static final String BDB_WORK = "BDB_WORK";
+ public static final String QPID_WORK = "QPID_WORK";
+
+ protected String testWork = null;
+
+ protected String BDB_WORK_PRE_TEST;
+ protected String QPID_WORK_PRE_TEST;
+
+ protected final String QpidHome = System.getProperty("QPID_HOME");
+ protected final File _persistentConfigFile = new File(QpidHome, "etc/persistent_config.xml");
+ protected Queue _queue;
+
+ protected long _TimeToLive = 0L;
+ public static final String MESSAGE_ID_PROPERTY = "MessageIDProperty";
+
+ public void setUp() throws Exception
+ {
+ setupWorkDirectory();
+
+ //Create the Broker
+ super.setUp();
+
+ _queue = new AMQQueue("amq.direct", "BDBTestQ");
+ }
+
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+
+ if (testWork != null)
+ {
+ // Clean up the BDB store
+ deleteDirectory(new File(testWork));
+ testWork = null;
+ }
+
+ //Reset BDB_WORK
+ System.setProperty(BDB_WORK, BDB_WORK_PRE_TEST == null ? "" : BDB_WORK_PRE_TEST);
+
+ //Reset QPID_WORK
+ System.setProperty(QPID_WORK, QPID_WORK_PRE_TEST == null ? "" : QPID_WORK_PRE_TEST);
+ }
+
+ public void setupWorkDirectory()
+ {
+ if (System.getProperty(BDB_WORK) == null)
+ {
+ fail("BDB_WORK required for BDB tests");
+ }
+
+ BDB_WORK_PRE_TEST = System.getProperty(BDB_WORK);
+ QPID_WORK_PRE_TEST = System.getProperty(QPID_WORK);
+
+ //IF BDB_WORK is set but not QPID_WORK then set QPID_WORK to BDB_WORK
+ if (QPID_WORK_PRE_TEST == null && BDB_WORK_PRE_TEST != null)
+ {
+ System.setProperty(QPID_WORK, BDB_WORK_PRE_TEST);
+ }
+ }
+
+ public void startVMBroker(int vmID, ConfigurationFileApplicationRegistry configFile) throws Exception
+ {
+ if (vmID != 1)
+ {
+ testWork = BDB_WORK_PRE_TEST + "-" + vmID;
+ }
+ else
+ {
+ testWork = BDB_WORK_PRE_TEST;
+ }
+ System.setProperty(BDB_WORK, testWork);
+ System.setProperty(QPID_WORK, testWork);
+
+ super.startBroker(vmID, configFile);
+ }
+
+ public boolean deleteDirectory(File dir)
+ {
+ if (dir.isDirectory())
+ {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++)
+ {
+ if (!deleteDirectory(new File(dir, children[i])))
+ {
+ return false;
+ }
+ }
+ }
+
+ return (dir.delete());
+ }
+
+ protected void sendMessages(int num) throws JMSException
+ {
+ Connection producerConnection = null;
+ try
+ {
+ producerConnection = getConnection();
+ }
+ catch (Exception e)
+ {
+ fail("Unable to lookup connection in JNDI.");
+ }
+
+ sendMessages(producerConnection, num);
+ }
+
+ protected void sendMessages(Connection producerConnection, int num) throws JMSException
+ {
+ Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ //Ensure _queue is created
+ producerSession.createConsumer(_queue).close();
+
+ MessageProducer producer = producerSession.createProducer(_queue);
+
+ producer.setTimeToLive(_TimeToLive);
+ producer.setDisableMessageTimestamp(false);
+
+ for (int messsageID = 0; messsageID < num; messsageID++)
+ {
+ TextMessage textMsg = producerSession.createTextMessage("Message " + messsageID);
+ textMsg.setIntProperty(MESSAGE_ID_PROPERTY, messsageID);
+ producer.send(textMsg);
+ }
+
+ producerConnection.close();
+ }
+}
Copied: store/branches/java/broker-queue-refactor/java/bdbstore/test-provider.properties (from rev 2429, store/branches/java/broker-queue-refactor/java/bdbstorebackup/bin/bdbstorebackup.sh)
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstore/test-provider.properties (rev 0)
+++ store/branches/java/broker-queue-refactor/java/bdbstore/test-provider.properties 2008-09-09 12:19:01 UTC (rev 2431)
@@ -0,0 +1,34 @@
+#
+#
+# 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.
+#
+#
+
+connectionfactory.vm = amqp://username:password@clientid/test?brokerlist='vm://:1'
+
+connectionfactory.vmfailover = amqp://username:password@clientid/test?brokerlist='vm://:2;vm://:1'
+connectionfactory.connection1 = amqp://username:password@clientid/test?brokerlist='vm://:1'
+connectionfactory.connection2 = amqp://username:password@clientid/test?brokerlist='vm://:2'
+
+
+#queue.MyQueue = example.MyQueue
+queue.queue = example.queue
+#queue.xaQueue = xaQueue
+
+#topic.xaTopic = xaTopic
+#topic.durableSubscriberTopic = durableSubscriberTopic
Property changes on: store/branches/java/broker-queue-refactor/java/bdbstore/test-provider.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: store/branches/java/broker-queue-refactor/java/bdbstorebackup/ReadMe.txt
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstorebackup/ReadMe.txt 2008-09-08 17:09:10 UTC (rev 2430)
+++ store/branches/java/broker-queue-refactor/java/bdbstorebackup/ReadMe.txt 2008-09-09 12:19:01 UTC (rev 2431)
@@ -1,10 +0,0 @@
-Building with Maven
--------------------
-The BerkeleyDB jar will automatically be installed in to your local repository with maven from the
-local mvn-repo. This will occur when you first try and compile the BDB module.
-
-
-Using with Qpid
----------------
-This can be pluged into BDBMessageStore and also as a standalone utility to take a offline backup
-For a offline back up , run the bdbstorebackup.sh script
Deleted: store/branches/java/broker-queue-refactor/java/bdbstorebackup/bin/bdbstorebackup.sh
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstorebackup/bin/bdbstorebackup.sh 2008-09-08 17:09:10 UTC (rev 2430)
+++ store/branches/java/broker-queue-refactor/java/bdbstorebackup/bin/bdbstorebackup.sh 2008-09-09 12:19:01 UTC (rev 2431)
@@ -1,44 +0,0 @@
-#!/bin/bash
-#
-# 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.
-#
-
-if [ "$JAVA_HOME" == "" ]; then
- echo "The JAVA_HOME environment variable is not defined";
- exit 0;
-fi
-
-if [ $# -lt 2 ]; then
- echo "Usage: bdbstorebackup.sh -bdbpath <bdb env path> [-virtualhost <virtual host name>]"
- exit 1
-fi
-
-## Add these jars in the classpath
-## je-3.1.0.jar
-## qpid-bdbstorebackup-1.0-incubating-M2-SNAPSHOT.jar
-
-
-CP=../target/qpid-bdbstorebackup-1.0-incubating-M2-SNAPSHOT.jar:../target/je-3.1.0.jar
-
-if [ `uname -o` == "Cygwin" ] ; then
- CP=`cygpath --path --windows $CP`
-fi
-
-##echo $CP
-
-"$JAVA_HOME/bin/java" -cp $CP org.apache.qpid.server.store.berkeleydb.BDBBackup $@
Deleted: store/branches/java/broker-queue-refactor/java/bdbstorebackup/pom.xml
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstorebackup/pom.xml 2008-09-08 17:09:10 UTC (rev 2430)
+++ store/branches/java/broker-queue-refactor/java/bdbstorebackup/pom.xml 2008-09-09 12:19:01 UTC (rev 2431)
@@ -1,57 +0,0 @@
-<!--
- 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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.etp.qpid</groupId>
- <artifactId>qpid-bdbstorebackup</artifactId>
- <packaging>jar</packaging>
- <version>1.0-incubating-M2-SNAPSHOT</version>
- <name>Qpid BDB Store Backup</name>
- <url>http://cwiki.apache.org/confluence/display/qpid</url>
-
- <parent>
- <groupId>org.apache.qpid</groupId>
- <artifactId>qpid</artifactId>
- <version>1.0-incubating-M2-SNAPSHOT</version>
- </parent>
-
- <!-- Local repository for the BerkelyDB-je so we don't have to use the installer script -->
- <repositories>
- <repository>
- <id>berkley-je.local</id>
- <name>Local BerkelyDB JE Repository</name>
- <url>file://${basedir}/mvn-repo</url>
- </repository>
- </repositories>
-
- <dependencies>
- <dependency>
- <groupId>sleepycat</groupId>
- <artifactId>berkeleydb-je</artifactId>
- <version>3.1.0</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
Deleted: store/branches/java/broker-queue-refactor/java/bdbstorebackup/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java
===================================================================
--- store/branches/java/broker-queue-refactor/java/bdbstorebackup/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java 2008-09-08 17:09:10 UTC (rev 2430)
+++ store/branches/java/broker-queue-refactor/java/bdbstorebackup/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBBackup.java 2008-09-09 12:19:01 UTC (rev 2431)
@@ -1,199 +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.je.util.DbBackup;
-import com.sleepycat.je.EnvironmentConfig;
-import com.sleepycat.je.Environment;
-import com.sleepycat.je.DatabaseException;
-
-import java.io.*;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-
-/**
- * This class uses the DbBackup class to take a backup of bdb logfiles.
- */
-public class BDBBackup
-{
- private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");//("yyyyMMddHHmmss");
- //TODO : to be decided what should be the root dir. It can be another parameter in the broker config
- private static String _backupRootDir = System.getProperty("user.home") + File.separator + "BDBbackup";
- // Directory for a particular virtual host
- // It is of the form backupRootDir/time/envName
- private String _backupDir = null;
- // This is bdb env dir
- private String _envDir = null;
- // This file contains the information about the last logfile name in previous backup
- private String iniFile = "bdbbackup.ini";
- // bdb environment
- private Environment _env;
- // This represents the dir name specific to a virtual host. This is
- private String _envName = null;
- // helper class for backup
- private DbBackup _backupHelper;
-
- /**
- * Creates the backup utility instance for backup
- * @param env bdb environment for particular virtual host
- * @param virtualHostName
- * @throws Exception
- */
- public BDBBackup(Environment env, String virtualHostName) throws Exception
- {
- _env = env;
- _envDir = _env.getHome().getAbsolutePath();
- _envName = (virtualHostName != null) ? virtualHostName : _env.getHome().getName();
- _backupHelper = new DbBackup(_env);
- }
-
- public static void main(String[] args) throws Exception
- {
- if (args.length < 2 || (!args[0].equals("-bdbpath")) )
- {
- usage();
- System.exit(1);
- }
- String envName = null;
- if (args.length >= 4 && (args[2].equals("-virtualhost")))
- {
- envName = args[3];
- }
-
- File environmentPath = new File(args[1]);
- EnvironmentConfig envConfig = new EnvironmentConfig();
- Environment env = new Environment(environmentPath, envConfig);
-
- BDBBackup bdbBackup= new BDBBackup(env, envName);
- bdbBackup.takeBackup();
- }
-
- /**
- * It takes the backup by copying all the logfiles into the backup dir
- * @throws DatabaseException
- */
- public void takeBackup() throws DatabaseException
- {
- try
- {
- long lastFileCopiedInPrevBackup = getLastFileNoCopiedInPreviousBackup();
-
- _backupHelper.startBackup();
- String[] filesForBackup = _backupHelper.getLogFilesInBackupSet(lastFileCopiedInPrevBackup);
-
- // Inside the destination dir, a dir with current time will be created for this backup
- _backupDir = _backupRootDir + File.separator + sdf.format(new Date()) + File.separator + _envName;
- // Create the backup directories
- File destFile = new File(_backupDir);
- if (!(destFile.exists()))
- {
- destFile.mkdirs();
- }
-
- // Copy the files to archival storage.
- for (int i = 0; i < filesForBackup.length; i++)
- {
-
- File sourceFile = new File(_envDir + File.separator + filesForBackup[i]);
- destFile = new File(_backupDir + File.separator + filesForBackup[i]);
- copy(sourceFile, destFile);
- }
- // Update our knowlege of the last file saved in the backup set,
- // so we can copy less on the next backup
- long lastFileCopiedInBackup = _backupHelper.getLastFileInBackupSet();
- saveLastFileInformation(lastFileCopiedInBackup);
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- // Remember to exit backup mode, or all log files won't be cleaned and disk usage will bloat.
- if (_backupHelper != null)
- {
- _backupHelper.endBackup();
- }
- }
- }
-
- /**
- * Copies src file to dst file. If the dst file does not exist, it is created
- * @param src file name
- * @param dst file name
- * @throws IOException
- */
- private synchronized static void copy(File src, File dst) throws IOException
- {
- InputStream in = new FileInputStream(src);
- if (!dst.exists())
- {
- dst.createNewFile();
- }
- OutputStream out = new FileOutputStream(dst);
-
- // Transfer bytes from in to out
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0)
- {
- out.write(buf, 0, len);
- }
- in.close();
- out.close();
- }
-
- private void saveLastFileInformation(long fileNo) throws IOException
- {
- File file = new File(_envDir + File.separator + iniFile);
- file.delete();
- file.createNewFile();
-
- BufferedWriter out = new BufferedWriter(new FileWriter(file, true));
- out.write(fileNo + "\n");
- out.close();
-
- // Copy the ini file in the destination dir also
- copy(file, new File(_backupDir + File.separator + iniFile));
- }
-
- private long getLastFileNoCopiedInPreviousBackup() throws IOException
- {
- File file = new File(_envDir + File.separator + iniFile);
- if (!file.exists())
- return -1;
-
- BufferedReader in = new BufferedReader(new FileReader(file));;
- String str = in.readLine();
- in.close();
-
- if (str != null)
- {
- return Long.parseLong(str);
- }
-
- return -1;
- }
-
- private static void usage()
- {
- System.out.println("bdb env path is not specified. \n -bdbpath <bdb env path> " +
- "\n [-virtualhost <virtual host name> ]");
- }
-}
More information about the rhmessaging-commits
mailing list