Skip to content

Commit

Permalink
Merge branch 'release/0.6.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisspyB committed Oct 8, 2024
2 parents 3c401b4 + cf4bb50 commit 7d42251
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
23 changes: 17 additions & 6 deletions src/gribjump/Config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,27 @@ Config::Config() {
}

Config::Config(const eckit::PathName path) :
eckit::LocalConfiguration(eckit::YAMLConfiguration(path)) {
eckit::LocalConfiguration(eckit::YAMLConfiguration(path)),
serverMap_{loadServerMap()} {
}

std::map<std::string, std::string> Config::getMap(const std::string& key) const {

std::map<std::string, std::string> Config::loadServerMap() const {
// e.g. yaml
// servermap:
// - fdb: "host1:port1"
// gribjump: "host2:port2"
// - fdb: "host3:port3"
// gribjump: "host4:port4"
// becomes map:
// { "host1:port1": "host2:port2", "host3:port3": "host4:port4" }
std::map<std::string, std::string> map;
eckit::LocalConfiguration conf = getSubConfiguration(key);
for (const auto& k : conf.keys()) {
map[k] = conf.getString(k);
eckit::LocalConfiguration conf = getSubConfiguration("servermap");
std::vector<eckit::LocalConfiguration> serverList = conf.getSubConfigurations();

for (const auto& server : serverList) {
map[server.getString("fdb")] = server.getString("gribjump");
}

return map;
}

Expand Down
10 changes: 8 additions & 2 deletions src/gribjump/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,23 @@

#pragma once

#include <map>
#include "eckit/config/LocalConfiguration.h"


namespace gribjump {

class Config : public eckit::LocalConfiguration {
public:
Config();
Config(const eckit::PathName);

std::map<std::string, std::string> getMap(const std::string& key) const;
const std::map<std::string, std::string>& serverMap() const { return serverMap_; }

private:
std::map<std::string, std::string> loadServerMap() const;

private:
std::map<std::string, std::string> serverMap_;
};

} // namespace gribjump
2 changes: 1 addition & 1 deletion src/gribjump/Engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void Engine::forwardRemoteExtraction(filemap_t& filemap) {
// get servermap from config, which maps fdb remote uri to gribjump server uri
// format: fdbhost:port -> gjhost:port
/// @todo: dont parse servermap every request
std::map<std::string, std::string> servermap_str = LibGribJump::instance().config().getMap("servermap");
const std::map<std::string, std::string>& servermap_str = LibGribJump::instance().config().serverMap();
ASSERT(!servermap_str.empty());

for (auto& [fdb, gj] : servermap_str) {
Expand Down

0 comments on commit 7d42251

Please sign in to comment.