Author: cctrieloff
Date: Fri Nov  2 18:00:03 2007
New Revision: 591526

URL: http://svn.apache.org/viewvc?rev=591526&view=rev
Log:
- support for store to abort init / force
- there is an issue exiting via exception not related to this fix, but uncovered
by this fix - JIRA 671

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStore.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.h
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.cpp
    incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.h

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp?rev=591526&r1=591525&r2=591526&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.cpp Fri Nov  2 
18:00:03 2007
@@ -63,6 +63,7 @@
     stagingThreshold(5000000),
     storeDir("/var"),
     storeAsync(false),
+    storeForce(false),
     enableMgmt(0),
     mgmtPubInterval(10),
     ack(100)
@@ -84,6 +85,8 @@
          "Store directory location for persistence.")
         ("store-async", optValue(storeAsync,"yes|no"),
          "Use async persistence storage - if store supports it, enable AIO 
0-DIRECT.")
+        ("store-force", optValue(storeForce,"yes|no"),
+         "Force changing modes of store, will delete all existing data if mode 
is change. Be SHURE you want to do this")
         ("mgmt,m", optValue(enableMgmt,"yes|no"),
          "Enable Management")
         ("mgmt-pub-interval", optValue(mgmtPubInterval, "SECONDS"),
@@ -138,10 +141,14 @@
         QPID_LOG(info, "Management not enabled");
 
     if(store.get()) {
-        store->init(conf.storeDir, conf.storeAsync);
-        RecoveryManagerImpl recoverer(queues, exchanges, dtxManager, 
+        if (!store->init(conf.storeDir, conf.storeAsync, conf.storeForce)){
+              throw Exception( "Existing Journal in different mode, 
backup/move existing data \
+                         before changing modes. Or use --store-force yes to 
blow existing data away.");
+               }else{
+             RecoveryManagerImpl recoverer(queues, exchanges, dtxManager, 
                                       conf.stagingThreshold);
-        store->recover(recoverer);
+             store->recover(recoverer);
+        }
     }
 
     // Initialize plugins

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h?rev=591526&r1=591525&r2=591526&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Broker.h Fri Nov  2 18:00:03 
2007
@@ -69,6 +69,7 @@
         long stagingThreshold;
         string storeDir;
         bool storeAsync;
+        bool storeForce;
         bool enableMgmt;
         uint16_t mgmtPubInterval;
         uint32_t ack;

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStore.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStore.h?rev=591526&r1=591525&r2=591526&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStore.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStore.h Fri Nov  2 
18:00:03 2007
@@ -44,8 +44,9 @@
      * 
      * @param dir the directory to create logs/db's
      * @param async true, enable async, false, enable sync
+     * @param force true, delete data on mode change, false, error on mode 
change
         */
-       virtual void init(const std::string& dir, const bool async) = 0;
+       virtual bool init(const std::string& dir, const bool async, const bool 
force) = 0;
 
     /**
      * Record the existence of a durable queue

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp?rev=591526&r1=591525&r2=591526&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp 
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.cpp Fri 
Nov  2 18:00:03 2007
@@ -28,9 +28,10 @@
 {
 }
 
-void MessageStoreModule::init(const std::string& dir, const bool async)
+bool MessageStoreModule::init(const std::string& dir, const bool async, const 
bool force)
 {
-       store->init(dir, async);
+       store->init(dir, async, force);
+       return true;
 }
 
 void MessageStoreModule::create(PersistableQueue& queue)

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.h?rev=591526&r1=591525&r2=591526&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.h 
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/MessageStoreModule.h Fri Nov  
2 18:00:03 2007
@@ -38,7 +38,7 @@
 public:
     MessageStoreModule(const std::string& name);
 
-       void init(const std::string& dir, const bool async);
+       bool init(const std::string& dir, const bool async, const bool force);
     std::auto_ptr<TransactionContext> begin();
     std::auto_ptr<TPCTransactionContext> begin(const std::string& xid);
     void prepare(TPCTransactionContext& txn);

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.cpp?rev=591526&r1=591525&r2=591526&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.cpp 
(original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.cpp Fri Nov  
2 18:00:03 2007
@@ -49,7 +49,7 @@
 
 NullMessageStore::NullMessageStore(bool _warn) : warn(_warn){}
 
-void NullMessageStore::init(const std::string& /*dir*/, const bool /*async*/) 
{}
+bool NullMessageStore::init(const std::string& /*dir*/, const bool /*async*/, 
const bool /*force*/) {return true;}
 
 void NullMessageStore::create(PersistableQueue& queue)
 {

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.h
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.h?rev=591526&r1=591525&r2=591526&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/NullMessageStore.h Fri Nov  2 
18:00:03 2007
@@ -38,7 +38,7 @@
 public:
     NullMessageStore(bool warn = false);
 
-       virtual void init(const std::string& dir, const bool async);
+       virtual bool init(const std::string& dir, const bool async, const bool 
force);
     virtual std::auto_ptr<TransactionContext> begin();
     virtual std::auto_ptr<TPCTransactionContext> begin(const std::string& xid);
     virtual void prepare(TPCTransactionContext& txn);


Reply via email to