diff options
author | Tor Egge <Tor.Egge@oath.com> | 2018-03-07 15:48:52 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@oath.com> | 2018-03-07 15:48:52 +0000 |
commit | f8ef471309f9c3c39c46bf4aaeadeab48fbfeab6 (patch) | |
tree | b04f23caa29ac2fd8f9e0736a1102406f5ea08ff /storage/src | |
parent | 6d57bce6d57f1f71ce84510d1bd321daa858c3dc (diff) |
Factor out common code into new method to print xml tag for
pending or delayed single bucket requests.
Diffstat (limited to 'storage/src')
-rw-r--r-- | storage/src/vespa/storage/distributor/bucketdbupdater.cpp | 35 | ||||
-rw-r--r-- | storage/src/vespa/storage/distributor/bucketdbupdater.h | 6 |
2 files changed, 23 insertions, 18 deletions
diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp index 82eb7b9f6eb..39e21772547 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp @@ -540,6 +540,21 @@ const vespalib::string BUCKETDB_UPDATER = "Bucket Database Updater"; } +void +BucketDBUpdater::BucketRequest::print_xml_tag(vespalib::xml::XmlOutputStream &xos, const vespalib::xml::XmlAttribute ×tampAttribute) const +{ + using namespace vespalib::xml; + xos << XmlTag("storagenode") + << XmlAttribute("index", targetNode); + xos << XmlAttribute("bucketspace", bucket.getBucketSpace().getId(), XmlAttribute::HEX); + if (bucket.getBucketId().getRawId() == 0) { + xos << XmlAttribute("bucket", ALL); + } else { + xos << XmlAttribute("bucket", bucket.getBucketId().getId(), XmlAttribute::HEX); + } + xos << timestampAttribute << XmlEndTag(); +} + bool BucketDBUpdater::reportStatus(std::ostream& out, const framework::HttpUrlPath& path) const @@ -581,29 +596,13 @@ BucketDBUpdater::reportXmlStatus(vespalib::xml::XmlOutputStream& xos, << XmlTag("single_bucket_requests"); for (const auto & entry : _sentMessages) { - xos << XmlTag("storagenode") - << XmlAttribute("index", entry.second.targetNode); - if (entry.second.bucket.getBucketId().getRawId() == 0) { - xos << XmlAttribute("bucket", ALL); - } else { - xos << XmlAttribute("bucket", entry.second.bucket.getBucketId().getId(), XmlAttribute::HEX); - } - xos << XmlAttribute("sendtimestamp", entry.second.timestamp) - << XmlEndTag(); + entry.second.print_xml_tag(xos, XmlAttribute("sendtimestamp", entry.second.timestamp)); } xos << XmlEndTag() << XmlTag("delayed_single_bucket_requests"); for (const auto & entry : _delayedRequests) { - xos << XmlTag("storagenode") - << XmlAttribute("index", entry.second.targetNode); - if (entry.second.bucket.getBucketId().getRawId() == 0) { - xos << XmlAttribute("bucket", ALL); - } else { - xos << XmlAttribute("bucket", entry.second.bucket.getBucketId().getId(), XmlAttribute::HEX); - } - xos << XmlAttribute("resendtimestamp", entry.first.getTime()) - << XmlEndTag(); + entry.second.print_xml_tag(xos, XmlAttribute("resendtimestamp", entry.first.getTime())); } xos << XmlEndTag() << XmlEndTag(); return ""; diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.h b/storage/src/vespa/storage/distributor/bucketdbupdater.h index a85ee6fe4f7..89c5000b542 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.h +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.h @@ -17,6 +17,11 @@ #include <vespa/storageapi/messageapi/messagehandler.h> #include <list> +namespace vespalib::xml { +class XmlOutputStream; +class XmlAttribute; +} + namespace storage::distributor { class Distributor; @@ -89,6 +94,7 @@ private: timestamp(currentTime), _mergeReplyGuard(guard) {}; + void print_xml_tag(vespalib::xml::XmlOutputStream &xos, const vespalib::xml::XmlAttribute ×tampAttribute) const; uint16_t targetNode; document::Bucket bucket; uint64_t timestamp; |