Skip to content

Commit

Permalink
fix(remoteFDB): cleanup remote/client
Browse files Browse the repository at this point in the history
  • Loading branch information
mcakircali committed Jan 16, 2025
1 parent 59f6bc9 commit 1c573a6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/fdb5/remote/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
3 changes: 2 additions & 1 deletion src/fdb5/remote/client/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::pair<eckit::net::Endpoint, std::string>>& endpoints);
Expand Down
19 changes: 7 additions & 12 deletions src/fdb5/remote/client/RemoteCatalogue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

//----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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<Payload> payloads;
PayloadList payloads;
payloads.emplace_back(stream.position(), buffer.data());

dataWrite(Message::Blob, id, payloads);
Expand Down Expand Up @@ -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_;

Expand Down Expand Up @@ -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<RemoteCatalogue> reader("remote");
static CatalogueWriterBuilder<RemoteCatalogue> writer("remote");
static CatalogueReaderBuilder<RemoteCatalogue> reader(RemoteCatalogue::typeName());
static CatalogueWriterBuilder<RemoteCatalogue> writer(RemoteCatalogue::typeName());

//----------------------------------------------------------------------------------------------------------------------

Expand Down
12 changes: 7 additions & 5 deletions src/fdb5/remote/client/RemoteCatalogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const FieldLocation> fieldLocation) override;
Expand Down Expand Up @@ -59,8 +59,10 @@ class RemoteCatalogue : public CatalogueReader, public CatalogueWriter, public C
std::vector<fdb5::Index> indexes(bool sorted=false) const override;
void maskIndexEntry(const Index& index) const override;
void allMasked(std::set<std::pair<eckit::URI, eckit::Offset>>& metadata, std::set<eckit::URI>& 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;
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/remote/client/RemoteStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void RemoteStore::archive(const Key& key, const void *data, eckit::Length length
keyStream << dbKey_;
keyStream << key;

std::vector<Payload> payloads;
PayloadList payloads;
payloads.emplace_back(keyStream.position(), keyBuffer.data());
payloads.emplace_back(length, data);

Expand Down

0 comments on commit 1c573a6

Please sign in to comment.