diff options
author | Tor Brede Vekterli <vekterli@yahoo-inc.com> | 2017-10-20 13:36:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-20 13:36:16 +0200 |
commit | 5fd803fe826569265db2f76d327610ac829ed7ea (patch) | |
tree | d7a341f9f71afe98c2704218a88a5cf47a93374b /storageapi | |
parent | c29d5f06c591d303ef37ae75ab6e306ea3314bd5 (diff) | |
parent | 5b37d8b706055661ab68e8b2dee96cdedeaf0c72 (diff) |
Merge pull request #3808 from vespa-engine/toregge/add-bucket-space-to-storage-commands-pass4
Adjust constructors for more storage commands to use document::Bucket
Diffstat (limited to 'storageapi')
4 files changed, 2 insertions, 226 deletions
diff --git a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp index f03c59f0887..bfd657c2f05 100644 --- a/storageapi/src/tests/mbusprot/storageprotocoltest.cpp +++ b/storageapi/src/tests/mbusprot/storageprotocoltest.cpp @@ -15,6 +15,7 @@ #include <vespa/document/document.h> #include <vespa/document/repo/documenttyperepo.h> #include <vespa/document/update/fieldpathupdates.h> +#include <vespa/document/test/make_document_bucket.h> #include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/vespalib/util/growablebytebuffer.h> #include <vespa/vespalib/objects/nbostream.h> @@ -28,21 +29,13 @@ using document::Document; using document::DocumentId; using document::DocumentType; using document::DocumentTypeRepo; +using document::test::makeDocumentBucket; using storage::lib::ClusterState; using vespalib::string; namespace storage { namespace api { -namespace { - -document::Bucket makeDocumentBucket(document::BucketId bucketId) -{ - return document::Bucket(BucketSpace::placeHolder(), bucketId); -} - -} - struct StorageProtocolTest : public CppUnit::TestFixture { document::TestDocMan _docMan; document::Document::SP _testDoc; diff --git a/storageapi/src/vespa/storageapi/message/datagram.cpp b/storageapi/src/vespa/storageapi/message/datagram.cpp index c2fc347c597..66b753185a4 100644 --- a/storageapi/src/vespa/storageapi/message/datagram.cpp +++ b/storageapi/src/vespa/storageapi/message/datagram.cpp @@ -7,58 +7,11 @@ using document::BucketSpace; namespace storage { namespace api { -IMPLEMENT_COMMAND(DocBlockCommand, DocBlockReply) -IMPLEMENT_REPLY(DocBlockReply) IMPLEMENT_COMMAND(MapVisitorCommand, MapVisitorReply) IMPLEMENT_REPLY(MapVisitorReply) -IMPLEMENT_COMMAND(DocumentListCommand, DocumentListReply) -IMPLEMENT_REPLY(DocumentListReply) IMPLEMENT_COMMAND(EmptyBucketsCommand, EmptyBucketsReply) IMPLEMENT_REPLY(EmptyBucketsReply) -DocBlockCommand::DocBlockCommand(const document::BucketId& bucketId, - const vdslib::DocumentList& block, - const std::shared_ptr<void>& buffer) - : StorageCommand(MessageType::DOCBLOCK), - _bucket(BucketSpace::placeHolder(), bucketId), - _docBlock(block), - _buffer(buffer), - _keepTimeStamps(false) -{ -} - -DocBlockCommand::~DocBlockCommand() {} - -void -DocBlockCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const -{ - out << "DocBlockCommand(" - << "size " << _docBlock.getBufferSize() << ", used space " - << (_docBlock.getBufferSize() - _docBlock.countFree()) << ", doccount " - << _docBlock.size() << ")"; - if (verbose) { - out << " : "; - StorageCommand::print(out, verbose, indent); - } -} - -DocBlockReply::DocBlockReply(const DocBlockCommand& cmd) - : StorageReply(cmd) -{ -} - -void -DocBlockReply::print(std::ostream& out, bool verbose, - const std::string& indent) const -{ - out << "DocBlockReply()"; - if (verbose) { - out << " : "; - StorageReply::print(out, verbose, indent); - } -} - MapVisitorCommand::MapVisitorCommand() : StorageCommand(MessageType::MAPVISITOR) { @@ -99,52 +52,6 @@ MapVisitorReply::print(std::ostream& out, bool verbose, } } -DocumentListCommand::DocumentListCommand(const document::BucketId& bid) - : StorageCommand(MessageType::DOCUMENTLIST), - _bucket(BucketSpace::placeHolder(), bid), - _documents() -{ -} - -void -DocumentListCommand::print(std::ostream& out, bool verbose, - const std::string& indent) const -{ - out << "DocumentList(" << _bucket.getBucketId(); - if (_documents.empty()) { - out << ", empty"; - } else if (verbose) { - out << ","; - for (uint32_t i=0; i<_documents.size(); ++i) { - out << "\n" << indent << " "; - out << ":" << _documents[i]; - } - } else { - out << ", " << _documents.size() << " documents"; - } - out << ")"; - if (verbose) { - out << " : "; - StorageCommand::print(out, verbose, indent); - } -} - -DocumentListReply::DocumentListReply(const DocumentListCommand& cmd) - : StorageReply(cmd) -{ -} - -void -DocumentListReply::print(std::ostream& out, bool verbose, - const std::string& indent) const -{ - out << "DocumentListReply()"; - if (verbose) { - out << " : "; - StorageReply::print(out, verbose, indent); - } -} - EmptyBucketsCommand::EmptyBucketsCommand( const std::vector<document::BucketId>& buckets) : StorageCommand(MessageType::EMPTYBUCKETS), @@ -188,13 +95,5 @@ EmptyBucketsReply::print(std::ostream& out, bool verbose, } } -std::ostream& operator<<(std::ostream& out, const DocumentListCommand::Entry& e) -{ - out << e._doc->getId(); - if (e._removeEntry) out << " - removed"; - out << ", last modified at " << e._lastModified; - return out; -} - } // api } // storage diff --git a/storageapi/src/vespa/storageapi/message/datagram.h b/storageapi/src/vespa/storageapi/message/datagram.h index 272ba72364e..64649b43068 100644 --- a/storageapi/src/vespa/storageapi/message/datagram.h +++ b/storageapi/src/vespa/storageapi/message/datagram.h @@ -10,53 +10,6 @@ namespace storage::api { /** - * @class DocBlockCommand - * @ingroup message - * - * @brief Sends a docblock to a visitor or subscriber. - */ -class DocBlockCommand : public StorageCommand { - document::Bucket _bucket; - vdslib::DocumentList _docBlock; - std::shared_ptr<void> _buffer; // Owns data in docblock - bool _keepTimeStamps; // Used for recovery/synchronization where we want to - // keep the timestamps of the origin. - -public: - DocBlockCommand(const document::BucketId& bucketId, - const vdslib::DocumentList& block, - const std::shared_ptr<void>& buffer); - ~DocBlockCommand(); - - vdslib::DocumentList& getDocumentBlock() - { assert(_docBlock.getBufferSize() > 0); return _docBlock; } - const vdslib::DocumentList& getDocumentBlock() const - { assert(_docBlock.getBufferSize() > 0); return _docBlock; } - void setDocumentBlock(vdslib::DocumentList& block) { _docBlock = block; } - - document::Bucket getBucket() const override { return _bucket; } - bool hasSingleBucketId() const override { return true; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; - bool keepTimeStamps() const { return _keepTimeStamps; } - void keepTimeStamps(bool keepTime) { _keepTimeStamps = keepTime; } - - DECLARE_STORAGECOMMAND(DocBlockCommand, onDocBlock) -}; - -/** - * @class DocBlockReply - * @ingroup message - * - * @brief Confirm that a given docblock have been received. - */ -class DocBlockReply : public StorageReply { -public: - explicit DocBlockReply(const DocBlockCommand&); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; - DECLARE_STORAGEREPLY(DocBlockReply, onDocBlockReply) -}; - -/** * @class MapStorageCommand * @ingroup message * @@ -90,58 +43,6 @@ public: }; /** - * @class DocumentListCommand - * @ingroup message - * - * @brief Sends a list of documents to the visitor data handler. - * - * This is used in synchronization in order to transfer minimal amount of data - * to the synchronization agent. - */ -class DocumentListCommand : public StorageCommand { -public: - struct Entry { - document::Document::SP _doc; - int64_t _lastModified; - bool _removeEntry; - - Entry() : _doc(), _lastModified(0), _removeEntry(false) {} - Entry(const document::Document::SP& doc, int64_t lastModified, - bool removeEntry) - : _doc(doc), - _lastModified(lastModified), - _removeEntry(removeEntry) - { } - }; - -private: - document::Bucket _bucket; - std::vector<Entry> _documents; -public: - DocumentListCommand(const document::BucketId& bid); - document::Bucket getBucket() const override { return _bucket; } - std::vector<Entry>& getDocuments() { return _documents; } - const std::vector<Entry>& getDocuments() const { return _documents; } - void print(std::ostream& out, bool verbose, const std::string& indent) const override; - DECLARE_STORAGECOMMAND(DocumentListCommand, onDocumentList) -}; - -std::ostream& operator<<(std::ostream& out, const DocumentListCommand::Entry& e); - -/** - * @class DocumentListReply - * @ingroup message - * - * @brief Confirm that a given visitorstatisticscommand has been received. - */ -class DocumentListReply : public StorageReply { -public: - explicit DocumentListReply(const DocumentListCommand&); - void print(std::ostream& out, bool verbose, const std::string& indent) const override; - DECLARE_STORAGEREPLY(DocumentListReply, onDocumentListReply) -}; - -/** * @class EmptyBucketsCommand * @ingroup message * diff --git a/storageapi/src/vespa/storageapi/messageapi/messagehandler.h b/storageapi/src/vespa/storageapi/messageapi/messagehandler.h index 8f571ff0f40..de8af718bcf 100644 --- a/storageapi/src/vespa/storageapi/messageapi/messagehandler.h +++ b/storageapi/src/vespa/storageapi/messageapi/messagehandler.h @@ -32,7 +32,6 @@ class BatchDocumentUpdateCommand; class CreateVisitorCommand; // Create a new visitor class DestroyVisitorCommand; // Destroy a running visitor class VisitorInfoCommand; // Sends visitor info to visitor controller -class DocBlockCommand; // A block of documents visited class MapVisitorCommand; class SearchResultCommand; class DocumentSummaryCommand; @@ -73,7 +72,6 @@ class BatchDocumentUpdateReply; class CreateVisitorReply; class DestroyVisitorReply; class VisitorInfoReply; -class DocBlockReply; class MapVisitorReply; class SearchResultReply; class DocumentSummaryReply; @@ -105,9 +103,6 @@ class StatBucketReply; class GetBucketListCommand; class GetBucketListReply; -class DocumentListCommand; -class DocumentListReply; - class EmptyBucketsCommand; class EmptyBucketsReply; @@ -188,12 +183,6 @@ public: virtual bool onVisitorInfoReply( const std::shared_ptr<api::VisitorInfoReply>&) { return false; } - virtual bool onDocBlock( - const std::shared_ptr<api::DocBlockCommand>&) - { return false; } - virtual bool onDocBlockReply( - const std::shared_ptr<api::DocBlockReply>&) - { return false; } virtual bool onMapVisitor( const std::shared_ptr<api::MapVisitorCommand>&) { return false; } @@ -218,12 +207,6 @@ public: virtual bool onDocumentSummaryReply( const std::shared_ptr<api::DocumentSummaryReply>&) { return false; } - virtual bool onDocumentList( - const std::shared_ptr<api::DocumentListCommand>&) - { return false; } - virtual bool onDocumentListReply( - const std::shared_ptr<api::DocumentListReply>&) - { return false; } virtual bool onEmptyBuckets( const std::shared_ptr<api::EmptyBucketsCommand>&) { return false; } |