diff options
| author | Alan Conway <aconway@apache.org> | 2012-06-12 21:19:48 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2012-06-12 21:19:48 +0000 |
| commit | c9fc98ae80a5d8c4f58541f9738aa975723ff3d6 (patch) | |
| tree | 0d10d97ca0e884db6106870b503b2d044cd77a88 /cpp/src/qpid/ha/ReplicationTest.cpp | |
| parent | acb2762118591c4f26d189fa4c0c284026222ccd (diff) | |
| download | qpid-python-c9fc98ae80a5d8c4f58541f9738aa975723ff3d6.tar.gz | |
QPID-3603: Separate QueueGuard from ReplicatingSubscription.
QueueGuard: implements QueueObserver to delay completion of new messages.
ReplicatingSubscription: Implements subscription, sends messages & events to backup.
These were previously combined as one. QueueGuard is now separated out
so that it can be created before the ReplicatingSubscription, in
anticipation of an expected backup connecting. This is needed for 2 reasons:
- new queues must be guarded until they are backuped up.
- after a failover, all queues must be guarded until backups are ready.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1349538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/ha/ReplicationTest.cpp')
| -rw-r--r-- | cpp/src/qpid/ha/ReplicationTest.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/cpp/src/qpid/ha/ReplicationTest.cpp b/cpp/src/qpid/ha/ReplicationTest.cpp new file mode 100644 index 0000000000..1db101dc94 --- /dev/null +++ b/cpp/src/qpid/ha/ReplicationTest.cpp @@ -0,0 +1,70 @@ +/* + * + * 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 "ReplicationTest.h" +#include "qpid/broker/Queue.h" +#include "qpid/framing/FieldTable.h" + +namespace qpid { +namespace ha { + +using types::Variant; + +ReplicateLevel ReplicationTest::replicateLevel(const std::string& str) { + Enum<ReplicateLevel> rl; + if (rl.parseNoThrow(str)) return ReplicateLevel(rl.get()); + else return replicateDefault; +} + +ReplicateLevel ReplicationTest::replicateLevel(const framing::FieldTable& f) { + if (f.isSet(QPID_REPLICATE)) + return replicateLevel(f.getAsString(QPID_REPLICATE)); + else + return replicateDefault; +} + +ReplicateLevel ReplicationTest::replicateLevel(const Variant::Map& m) { + Variant::Map::const_iterator i = m.find(QPID_REPLICATE); + if (i != m.end()) + return replicateLevel(i->second.asString()); + else + return replicateDefault; +} + +namespace { +const std::string AUTO_DELETE_TIMEOUT("qpid.auto_delete_timeout"); +} + +bool ReplicationTest::isReplicated(const Variant::Map& args, bool autodelete, bool exclusive) { + bool ignore = autodelete && exclusive && args.find(AUTO_DELETE_TIMEOUT) == args.end(); + return replicateLevel(args) && !ignore; +} + +bool ReplicationTest::isReplicated(const framing::FieldTable& args, bool autodelete, bool exclusive) { + bool ignore = autodelete && exclusive && !args.isSet(AUTO_DELETE_TIMEOUT); + return replicateLevel(args) && !ignore; +} + +bool ReplicationTest::isReplicated(const broker::Queue& q) { + return isReplicated(q.getSettings(), q.isAutoDelete(), q.hasExclusiveOwner()); +} + + +}} // namespace qpid::ha |
