Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Oct 7, 2024
1 parent 253a432 commit 7ec275b
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/fdb5/api/DistFDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class DistFDB : public FDBBase {

ListIterator list(const FDBToolRequest& request) override;

AxesIterator axesIterator(const FDBToolRequest& request, int level=3) override { NOTIMP; }

DumpIterator dump(const FDBToolRequest& request, bool simple) override;

StatusIterator status(const FDBToolRequest& request) override;
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/api/FDBFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class FDBBase : private eckit::NonCopyable {

virtual MoveIterator move(const FDBToolRequest& request, const eckit::URI& dest) = 0;

virtual AxesIterator axesIterator(const FDBToolRequest& request, int axes) { NOTIMP; }
virtual AxesIterator axesIterator(const FDBToolRequest& request, int axes) = 0;

void registerArchiveCallback(ArchiveCallback callback) {callback_ = callback;}

Expand Down
15 changes: 15 additions & 0 deletions src/fdb5/api/RemoteFDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ struct ListHelper : BaseAPIHelper<fdb5::ListElement, fdb5::remote::Message::List
}
};


struct AxesHelper : BaseAPIHelper<fdb5::AxesElement, fdb5::remote::Message::Axes> {
AxesHelper(int level) : level_(level) {}

void encodeExtra(eckit::Stream& s) const {
s << level_;
}
private:
int level_;
};

struct InspectHelper : BaseAPIHelper<fdb5::ListElement, fdb5::remote::Message::Inspect> {

static fdb5::ListElement valueFromStream(eckit::Stream& s, fdb5::RemoteFDB* fdb) {
Expand Down Expand Up @@ -230,6 +241,10 @@ ListIterator RemoteFDB::list(const FDBToolRequest& request) {
return forwardApiCall(ListHelper(), request);
}

AxesIterator RemoteFDB::axesIterator(const FDBToolRequest& request, int level) {
return forwardApiCall(AxesHelper(level), request);
}

ListIterator RemoteFDB::inspect(const metkit::mars::MarsRequest& request) {
return forwardApiCall(InspectHelper(), request);
}
Expand Down
2 changes: 2 additions & 0 deletions src/fdb5/api/RemoteFDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class RemoteFDB : public LocalFDB, public remote::Client {

ListIterator list(const FDBToolRequest& request) override;

AxesIterator axesIterator(const FDBToolRequest& request, int level=3) override;

DumpIterator dump(const FDBToolRequest& request, bool simple) override { NOTIMP; }

StatusIterator status(const FDBToolRequest& request) override { NOTIMP; }
Expand Down
2 changes: 1 addition & 1 deletion src/fdb5/database/Catalogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class CatalogueReader : virtual public Catalogue {
virtual ~CatalogueReader() {}

virtual DbStats stats() const = 0;
virtual bool axis(const std::string& keyword, eckit::StringSet& s) const = 0;
virtual bool axis(const std::string& keyword, eckit::StringSet& s) const { NOTIMP; }
virtual bool retrieve(const Key& key, Field& field) const = 0;
};

Expand Down
1 change: 1 addition & 0 deletions src/fdb5/remote/Messages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ std::ostream& operator<<(std::ostream& s, const Message& m) {
case Message::Read: s << "Read"; break;
case Message::Move: s << "Move"; break;
case Message::Store: s << "Store"; break;
case Message::Axes: s << "Axes"; break;

// Responses
case Message::Received: s << "Received"; break;
Expand Down
1 change: 1 addition & 0 deletions src/fdb5/remote/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ enum class Message : uint16_t {
Read,
Move,
Store,
Axes,

// Responses
Received = 200,
Expand Down
1 change: 0 additions & 1 deletion src/fdb5/remote/client/RemoteCatalogue.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class RemoteCatalogue : public CatalogueReader, public CatalogueWriter, public C

//From CatalogueReader
DbStats stats() const override { return DbStats(); }
bool axis(const std::string& keyword, eckit::StringSet& s) const override { return false; }
bool retrieve(const Key& key, Field& field) const override { return false; }

// From Catalogue
Expand Down
19 changes: 19 additions & 0 deletions src/fdb5/remote/server/CatalogueHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ Handled CatalogueHandler::handleControl(Message message, uint32_t clientID, uint
list(clientID, requestID, std::move(payload));
return Handled::Yes;

case Message::Axes: // list request. Location are sent aynchronously over the data connection
axes(clientID, requestID, std::move(payload));
return Handled::Yes;

case Message::Inspect: // inspect request. Location are sent aynchronously over the data connection
inspect(clientID, requestID, std::move(payload));
return Handled::Yes;
Expand Down Expand Up @@ -216,6 +220,17 @@ struct ListHelper : public BaseHelper<ListElement> {
}
};

struct AxesHelper : public BaseHelper<AxesElement> {
void extraDecode(eckit::Stream& s) {
s >> level_;
}
AxesIterator apiCall(FDB& fdb, const FDBToolRequest& request) const {
return fdb.axesIterator(request, level_);
}
private:
int level_;
};

struct InspectHelper : public BaseHelper<ListElement> {
ListIterator apiCall(FDB& fdb, const FDBToolRequest& request) const {
return fdb.inspect(request.request());
Expand Down Expand Up @@ -283,6 +298,10 @@ void CatalogueHandler::list(uint32_t clientID, uint32_t requestID, eckit::Buffer
forwardApiCall<ListHelper>(clientID, requestID, std::move(payload));
}

void CatalogueHandler::axes(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload) {
forwardApiCall<AxesHelper>(clientID, requestID, std::move(payload));
}

void CatalogueHandler::inspect(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload) {
forwardApiCall<InspectHelper>(clientID, requestID, std::move(payload));
}
Expand Down
1 change: 1 addition & 0 deletions src/fdb5/remote/server/CatalogueHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CatalogueHandler : public ServerConnection {

void flush(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload);
void list(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload);
void axes(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload);
void inspect(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload);
void stats(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload);
void schema(uint32_t clientID, uint32_t requestID, eckit::Buffer&& payload);
Expand Down
8 changes: 7 additions & 1 deletion tests/fdb/api/ApiSpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ class ApiSpy : public fdb5::FDBBase {

struct Counts {
Counts() :
archive(0), inspect(0), list(0), dump(0), status(0), wipe(0),
archive(0), inspect(0), list(0), axes(0), dump(0), status(0), wipe(0),
purge(0), stats(0), flush(0), control(0), move(0) {}
size_t archive;
size_t inspect;
size_t list;
size_t axes;
size_t dump;
size_t status;
size_t wipe;
Expand Down Expand Up @@ -95,6 +96,11 @@ class ApiSpy : public fdb5::FDBBase {
return fdb5::ListIterator(0);
}

fdb5::AxesIterator axesIterator(const fdb5::FDBToolRequest& request, int level=3) override {
counts_.axes += 1;
return fdb5::AxesIterator(0);
}

fdb5::DumpIterator dump(const fdb5::FDBToolRequest& request, bool simple) override {
counts_.dump += 1;
return fdb5::DumpIterator(0);
Expand Down

0 comments on commit 7ec275b

Please sign in to comment.