diff options
author | Carl C. Trieloff <cctrieloff@apache.org> | 2008-10-03 15:01:55 +0000 |
---|---|---|
committer | Carl C. Trieloff <cctrieloff@apache.org> | 2008-10-03 15:01:55 +0000 |
commit | 25c373622b86747b1e9360e677f9c1997950428e (patch) | |
tree | fbb5577d8103f6cf196d356716ccf397fb74ba06 /cpp/src | |
parent | fa3f3064159d8109a1c0cf485a9959337397cd95 (diff) | |
download | qpid-python-25c373622b86747b1e9360e677f9c1997950428e.tar.gz |
QPID 1306
- added QueueOptions helper
- added tests for Queue Options helper.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@701397 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Makefile.am | 2 | ||||
-rw-r--r-- | cpp/src/qpid/client/QueueOptions.cpp | 121 | ||||
-rw-r--r-- | cpp/src/qpid/client/QueueOptions.h | 113 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FieldTable.cpp | 8 | ||||
-rw-r--r-- | cpp/src/qpid/framing/FieldTable.h | 2 | ||||
-rw-r--r-- | cpp/src/tests/Makefile.am | 1 | ||||
-rw-r--r-- | cpp/src/tests/QueueTest.cpp | 1 |
7 files changed, 243 insertions, 5 deletions
diff --git a/cpp/src/Makefile.am b/cpp/src/Makefile.am index c15e2139bc..c489af901b 100644 --- a/cpp/src/Makefile.am +++ b/cpp/src/Makefile.am @@ -382,6 +382,7 @@ libqpidclient_la_SOURCES = \ qpid/client/LocalQueue.cpp \ qpid/client/Message.cpp \ qpid/client/MessageListener.cpp \ + qpid/client/QueueOptions.cpp \ qpid/client/Results.cpp \ qpid/client/SessionBase_0_10.cpp \ qpid/client/SessionBase_0_10.h \ @@ -506,6 +507,7 @@ nobase_include_HEADERS = \ qpid/client/FutureCompletion.h \ qpid/client/FutureResult.h \ qpid/client/LocalQueue.h \ + qpid/client/QueueOptions.h \ qpid/client/Message.h \ qpid/client/MessageListener.h \ qpid/client/Results.h \ diff --git a/cpp/src/qpid/client/QueueOptions.cpp b/cpp/src/qpid/client/QueueOptions.cpp new file mode 100644 index 0000000000..d0fd6f1e5c --- /dev/null +++ b/cpp/src/qpid/client/QueueOptions.cpp @@ -0,0 +1,121 @@ +/* + * + * 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. + * + */ + +#include "QueueOptions.h" + +namespace qpid { +namespace client { + + +QueueOptions::QueueOptions() +{} + +const std::string QueueOptions::strMaxCountKey("qpid.max_count"); +const std::string QueueOptions::strMaxSizeKey("qpid.max_size"); +const std::string QueueOptions::strTypeKey("qpid.policy_type"); +const std::string QueueOptions::strREJECT("reject"); +const std::string QueueOptions::strFLOW_TO_DISK("flow_to_disk"); +const std::string QueueOptions::strRING("ring"); +const std::string QueueOptions::strRING_STRICT("ring_strict"); +const std::string QueueOptions::strLastValueQueue("qpid.last_value_queue"); +const std::string QueueOptions::strOptimisticConsume("qpid.optimistic_consume"); +const std::string QueueOptions::strPersistLastNode("qpid.persist_last_node"); + + +QueueOptions::~QueueOptions() +{} + +void QueueOptions::setSizePolicy(QueueSizePolicy sp, uint64_t maxSize, uint32_t maxCount) +{ + if (maxCount) setInt(strMaxCountKey, maxCount); + if (maxSize) setInt(strMaxSizeKey, maxSize); + if (maxSize || maxCount){ + switch (sp) + { + case REJECT: + setString(strTypeKey, strREJECT); + break; + case FLOW_TO_DISK: + setString(strTypeKey, strFLOW_TO_DISK); + break; + case RING: + setString(strTypeKey, strRING); + break; + case RING_STRICT: + setString(strTypeKey, strRING_STRICT); + break; + case NONE: + clearSizePolicy(); + break; + } + } +} + + +void QueueOptions::setOptimisticConsume() +{ + setInt(strOptimisticConsume, 1); +} + +void QueueOptions::setPersistLastNode() +{ + setInt(strPersistLastNode, 1); +} + +void QueueOptions::setOrdering(QueueOrderingPolicy op) +{ + if (op == LVQ){ + // TODO, add and test options with LVQ patch. + // also set the key match for LVQ + //setString(LastValueQueue, 1); + + }else{ + clearOrdering(); + } +} + +void QueueOptions::clearSizePolicy() +{ + erase(strMaxCountKey); + erase(strMaxSizeKey); + erase(strTypeKey); +} + +void QueueOptions::clearOptimisticConsume() +{ + erase(strOptimisticConsume); +} + +void QueueOptions::clearPersistLastNode() +{ + erase(strPersistLastNode); +} + +void QueueOptions::clearOrdering() +{ + erase(strLastValueQueue); +} + + +} +} + + diff --git a/cpp/src/qpid/client/QueueOptions.h b/cpp/src/qpid/client/QueueOptions.h new file mode 100644 index 0000000000..21333794ac --- /dev/null +++ b/cpp/src/qpid/client/QueueOptions.h @@ -0,0 +1,113 @@ +/* + * + * 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. + * + */ +#include "qpid/framing/FieldTable.h" + +#ifndef _QueueOptions_ +#define _QueueOptions_ + +namespace qpid { +namespace client { + +enum QueueSizePolicy {NONE, REJECT, FLOW_TO_DISK, RING, RING_STRICT}; +enum QueueOrderingPolicy {FIFO, LVQ}; + +/** + * A help class to set options on the Queue. Create a configured args while + * still allowing any custom configuration via the FieldTable base class + */ +class QueueOptions: public framing::FieldTable +{ + public: + QueueOptions(); + virtual ~QueueOptions(); + + /** + * Sets the queue sizing plocy + * + * @param sp SizePolicy + * REJECT - reject if queue greater than size/count + * FLOW_TO_DISK - page messages to disk from this point is greater than size/count + * RING - limit the queue to size/count and over-write old messages round a ring + * RING_STRICT - limit the queue to size/count and reject is head == tail + * NONE - Use default broker sizing policy + * @param maxSize Set the max number of bytes for the sizing policies + * @param setMaxCount Set the max number of messages for the sizing policies + */ + void setSizePolicy(QueueSizePolicy sp, uint64_t maxSize, uint32_t maxCount ); + + /** + * Enables optimistic consume allowing the consumer to dequeue the message before the + * broker has safe stored it. + */ + void setOptimisticConsume(); + + /** + * Enables the persisting of a queue to the store module when a cluster fails down to it's last + * node. Does so optimistically. Will start persisting when cluster count >1 again. + */ + void setPersistLastNode(); + + /** + * Sets the odering policy on the Queue, default ordering is FIFO. + */ + void setOrdering(QueueOrderingPolicy op); + + /** + * Use broker defualt sizing ploicy + */ + void clearSizePolicy(); + + /** + * Clear Optimistic Consume Policy + */ + void clearOptimisticConsume(); + + /** + * Clear Persist Last Node Policy + */ + void clearPersistLastNode(); + + /** + * Use default odering policy + */ + void clearOrdering(); + + static const std::string strMaxCountKey; + static const std::string strMaxSizeKey; + static const std::string strTypeKey; + static const std::string strREJECT; + static const std::string strFLOW_TO_DISK; + static const std::string strRING; + static const std::string strRING_STRICT; + static const std::string strLastValueQueue; + static const std::string strOptimisticConsume; + static const std::string strPersistLastNode; + private: + + + +}; + +} +} + + +#endif diff --git a/cpp/src/qpid/framing/FieldTable.cpp b/cpp/src/qpid/framing/FieldTable.cpp index cf8f1b5eed..1658a0bf9b 100644 --- a/cpp/src/qpid/framing/FieldTable.cpp +++ b/cpp/src/qpid/framing/FieldTable.cpp @@ -199,10 +199,10 @@ bool FieldTable::operator==(const FieldTable& x) const { return true; } -//void FieldTable::erase(const std::string& name) -//{ -// values.erase(values.find(name)); -//} +void FieldTable::erase(const std::string& name) +{ + values.erase(values.find(name)); +} } } diff --git a/cpp/src/qpid/framing/FieldTable.h b/cpp/src/qpid/framing/FieldTable.h index 3c56d1e81a..b56e3ce3ba 100644 --- a/cpp/src/qpid/framing/FieldTable.h +++ b/cpp/src/qpid/framing/FieldTable.h @@ -78,7 +78,7 @@ class FieldTable bool getFloat(const std::string& name, float& value) const; bool getDouble(const std::string& name, double& value) const; // //void getDecimal(string& name, xxx& value); -// //void erase(const std::string& name); + void erase(const std::string& name); bool operator==(const FieldTable& other) const; diff --git a/cpp/src/tests/Makefile.am b/cpp/src/tests/Makefile.am index 7188b6c168..b1f5eaeb3f 100644 --- a/cpp/src/tests/Makefile.am +++ b/cpp/src/tests/Makefile.am @@ -37,6 +37,7 @@ unit_test_SOURCES= unit_test.cpp unit_test.h \ SessionState.cpp Blob.cpp logging.cpp \ Url.cpp Uuid.cpp \ Shlib.cpp FieldValue.cpp FieldTable.cpp Array.cpp \ + QueueOptionsTest.cpp \ InlineAllocator.cpp \ InlineVector.cpp \ ClientSessionTest.cpp \ diff --git a/cpp/src/tests/QueueTest.cpp b/cpp/src/tests/QueueTest.cpp index d634429fd2..dd8b9e4a79 100644 --- a/cpp/src/tests/QueueTest.cpp +++ b/cpp/src/tests/QueueTest.cpp @@ -26,6 +26,7 @@ #include "qpid/broker/QueueRegistry.h" #include "qpid/broker/NullMessageStore.h" #include "qpid/framing/MessageTransferBody.h" +#include "qpid/client/QueueOptions.h" #include <iostream> #include "boost/format.hpp" |