You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by cc...@apache.org on 2008/10/03 17:01:55 UTC
svn commit: r701397 - in /incubator/qpid/trunk/qpid/cpp/src: Makefile.am
qpid/client/QueueOptions.cpp qpid/client/QueueOptions.h
qpid/framing/FieldTable.cpp qpid/framing/FieldTable.h tests/Makefile.am
tests/QueueTest.cpp
Author: cctrieloff
Date: Fri Oct 3 08:01:55 2008
New Revision: 701397
URL: http://svn.apache.org/viewvc?rev=701397&view=rev
Log:
QPID 1306
- added QueueOptions helper
- added tests for Queue Options helper.
Added:
incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.h
Modified:
incubator/qpid/trunk/qpid/cpp/src/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp
incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.h
incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp
Modified: incubator/qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/Makefile.am?rev=701397&r1=701396&r2=701397&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/Makefile.am Fri Oct 3 08:01:55 2008
@@ -382,6 +382,7 @@
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 @@
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 \
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.cpp?rev=701397&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.cpp (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.cpp Fri Oct 3 08:01:55 2008
@@ -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);
+}
+
+
+}
+}
+
+
Added: incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.h?rev=701397&view=auto
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.h (added)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/client/QueueOptions.h Fri Oct 3 08:01:55 2008
@@ -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
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp?rev=701397&r1=701396&r2=701397&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.cpp Fri Oct 3 08:01:55 2008
@@ -199,10 +199,10 @@
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));
+}
}
}
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.h?rev=701397&r1=701396&r2=701397&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/framing/FieldTable.h Fri Oct 3 08:01:55 2008
@@ -78,7 +78,7 @@
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;
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am?rev=701397&r1=701396&r2=701397&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/Makefile.am Fri Oct 3 08:01:55 2008
@@ -37,6 +37,7 @@
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 \
Modified: incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp?rev=701397&r1=701396&r2=701397&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/tests/QueueTest.cpp Fri Oct 3 08:01:55 2008
@@ -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"