From 1c573a650d59109b372271903794e31b2a277f33 Mon Sep 17 00:00:00 2001 From: Metin Cakircali Date: Thu, 16 Jan 2025 11:24:18 +0100 Subject: [PATCH] fix(remoteFDB): cleanup remote/client --- src/fdb5/remote/client/Client.cc | 2 +- src/fdb5/remote/client/Client.h | 3 ++- src/fdb5/remote/client/RemoteCatalogue.cc | 19 +++++++------------ src/fdb5/remote/client/RemoteCatalogue.h | 12 +++++++----- src/fdb5/remote/client/RemoteStore.cc | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/fdb5/remote/client/Client.cc b/src/fdb5/remote/client/Client.cc index 44257edb9..728f8ae9d 100644 --- a/src/fdb5/remote/client/Client.cc +++ b/src/fdb5/remote/client/Client.cc @@ -90,7 +90,7 @@ eckit::Buffer Client::controlWriteReadResponse(const Message msg, return eckit::Buffer{f.get()}; } -void Client::dataWrite(remote::Message msg, uint32_t requestID, PayloadList payloads) { +void Client::dataWrite(Message msg, uint32_t requestID, PayloadList payloads) { connection_.dataWrite(*this, msg, requestID, std::move(payloads)); } diff --git a/src/fdb5/remote/client/Client.h b/src/fdb5/remote/client/Client.h index 360daa72b..72594a405 100644 --- a/src/fdb5/remote/client/Client.h +++ b/src/fdb5/remote/client/Client.h @@ -34,9 +34,10 @@ class RemoteFDBException : public eckit::RemoteException { //---------------------------------------------------------------------------------------------------------------------- class Client : eckit::NonCopyable { +public: // types using PayloadList = Connection::PayloadList; -public: +public: // methods Client(const eckit::net::Endpoint& endpoint, const std::string& defaultEndpoint); Client(const std::vector>& endpoints); diff --git a/src/fdb5/remote/client/RemoteCatalogue.cc b/src/fdb5/remote/client/RemoteCatalogue.cc index 0b813102b..fcde73a82 100644 --- a/src/fdb5/remote/client/RemoteCatalogue.cc +++ b/src/fdb5/remote/client/RemoteCatalogue.cc @@ -30,9 +30,8 @@ namespace fdb5::remote { namespace { -constexpr size_t archivePayloadSize = 8192; -constexpr size_t keyPayloadSize = 4096; - +constexpr size_t archiveBufferSize = 8192; +constexpr size_t keyBufferSize = 4096; } //---------------------------------------------------------------------------------------------------------------------- @@ -66,13 +65,13 @@ void RemoteCatalogue::archive(const Key& idxKey, const Key& datumKey, std::share numLocations_++; } - Buffer buffer(archivePayloadSize); + Buffer buffer(archiveBufferSize); MemoryStream stream(buffer); stream << idxKey; stream << datumKey; stream << *fieldLocation; - std::vector payloads; + PayloadList payloads; payloads.emplace_back(stream.position(), buffer.data()); dataWrite(Message::Blob, id, payloads); @@ -141,7 +140,7 @@ void RemoteCatalogue::loadSchema() { LOG_DEBUG_LIB(LibFdb5) << "RemoteCatalogue::loadSchema()" << std::endl; // send dbkey to remote. - eckit::Buffer keyBuffer(keyPayloadSize); + eckit::Buffer keyBuffer(keyBufferSize); eckit::MemoryStream keyStream(keyBuffer); keyStream << dbKey_; @@ -180,18 +179,14 @@ void RemoteCatalogue::print( std::ostream &out ) const { out << "RemoteCatalogue(endpoint=" << controlEndpoint() << ",clientID=" << clientId() << ")"; } -std::string RemoteCatalogue::type() const { - return "remote"; -} - bool RemoteCatalogue::open() { return true; } //---------------------------------------------------------------------------------------------------------------------- -static CatalogueReaderBuilder reader("remote"); -static CatalogueWriterBuilder writer("remote"); +static CatalogueReaderBuilder reader(RemoteCatalogue::typeName()); +static CatalogueWriterBuilder writer(RemoteCatalogue::typeName()); //---------------------------------------------------------------------------------------------------------------------- diff --git a/src/fdb5/remote/client/RemoteCatalogue.h b/src/fdb5/remote/client/RemoteCatalogue.h index 29631dab5..b51009780 100644 --- a/src/fdb5/remote/client/RemoteCatalogue.h +++ b/src/fdb5/remote/client/RemoteCatalogue.h @@ -24,13 +24,13 @@ namespace fdb5::remote { class RemoteCatalogue : public CatalogueReader, public CatalogueWriter, public CatalogueImpl, public Client { -public: +public: // types + static const char* typeName() { return "remote"; } +public: // methods RemoteCatalogue(const Key& key, const Config& config); RemoteCatalogue(const eckit::URI& uri, const Config& config); - ~RemoteCatalogue() override = default; - // From CatalogueWriter const Index& currentIndex() override; void archive(const Key& idxKey, const Key& datumKey, std::shared_ptr fieldLocation) override; @@ -59,8 +59,10 @@ class RemoteCatalogue : public CatalogueReader, public CatalogueWriter, public C std::vector indexes(bool sorted=false) const override; void maskIndexEntry(const Index& index) const override; void allMasked(std::set>& metadata, std::set& data) const override; - void print( std::ostream &out ) const override; - std::string type() const override; + void print(std::ostream& out) const override; + + std::string type() const override { return typeName(); } + bool open() override; void flush(size_t archivedFields) override; void clean() override; diff --git a/src/fdb5/remote/client/RemoteStore.cc b/src/fdb5/remote/client/RemoteStore.cc index 4f2fcec2d..524a90337 100644 --- a/src/fdb5/remote/client/RemoteStore.cc +++ b/src/fdb5/remote/client/RemoteStore.cc @@ -270,7 +270,7 @@ void RemoteStore::archive(const Key& key, const void *data, eckit::Length length keyStream << dbKey_; keyStream << key; - std::vector payloads; + PayloadList payloads; payloads.emplace_back(keyStream.position(), keyBuffer.data()); payloads.emplace_back(length, data);