Skip to content

Commit

Permalink
Merge branch 'develop' into feature/grib-jump
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisspyB committed Feb 19, 2024
2 parents eb378e8 + 6683a17 commit 64e7f9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
19 changes: 14 additions & 5 deletions src/metkit/mars/DHSProtocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace {
return selectProxyHost(config.getStringVector("proxyHosts"));
}

throw UserError("Neither proxyHost nor proxyPort specified in configuration");
throw UserError("Neither proxyHosts nor proxyHost specified in configuration");
}
}

Expand Down Expand Up @@ -278,9 +278,12 @@ const ClassSpec& BaseCallbackConnection::classSpec() {
return spec;
}

BaseCallbackConnection* BaseCallbackConnection::build(const Configuration& config) {
if (config.has("proxyHost") || config.has("proxyHosts")) {
BaseCallbackConnection* BaseCallbackConnection::build(const Configuration& config, const std::string& host) {
if (config.has("proxyHost") || config.has("proxyHosts") || (config.getBool("passiveProxy", true) && config.getBool("useHostAsProxy", false))) {
if (config.getBool("passiveProxy", true)) {
if (config.getBool("useHostAsProxy", false)) {
return new PassiveProxyCallback{unpackHostPort(host)};
}
return new PassiveProxyCallback{config};
}
return new ProxyCallback{config};
Expand Down Expand Up @@ -319,15 +322,21 @@ DHSProtocol::DHSProtocol(const std::string& name,

DHSProtocol::DHSProtocol(const Configuration& params):
BaseProtocol(params),
callback_(BaseCallbackConnection::build(params)),
name_(params.getString("name")),
host_(params.getString("host")),
port_(params.getInt("port", 9000)),
done_(false),
error_(false),
sending_(false),
forward_(false)
{
if (params.has("hosts")) {
std::vector<std::string> hosts = params.getStringVector("hosts");
host_ = hosts.at(std::rand() % hosts.size());
} else {
ASSERT(params.has("host"));
host_ = params.getString("host");
}
callback_.reset(BaseCallbackConnection::build(params, host_));
}

DHSProtocol::DHSProtocol(Stream& s):
Expand Down
2 changes: 1 addition & 1 deletion src/metkit/mars/DHSProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class BaseCallbackConnection : public eckit::Streamable {
BaseCallbackConnection() {}
virtual ~BaseCallbackConnection() {}

static BaseCallbackConnection* build(const eckit::Configuration& config);
static BaseCallbackConnection* build(const eckit::Configuration& config, const std::string& host = "");

virtual const eckit::net::Endpoint& endpoint() const = 0;

Expand Down
15 changes: 6 additions & 9 deletions src/metkit/mars/TypeParam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ bool Matcher::match(const metkit::mars::MarsRequest& request, bool partial) cons
return partial;
}

// std::cout << vals << std::endl;


for (size_t i = 0; i < values_.size(); i++) {
std::string v = values_[i];

Expand Down Expand Up @@ -258,16 +255,12 @@ std::string Rule::lookup(const MarsExpandContext& ctx, const std::string & s, bo
}
}

// std::cout << "OK " << ok << " " << param << std::endl;

if (ok && param > 0) {
std::ostringstream oss;
if (table == 128) {
table = 0;
}

// std::cerr << "Param " << param << " " << table << std::endl;

oss << table * 1000 + param;
// return metkit::mars::MarsLanguage::bestMatch(oss.str(), values_, fail, false, mapping_, this);

Expand Down Expand Up @@ -308,9 +301,14 @@ static void init() {
const eckit::Value ids = eckit::YAMLParser::decodeFile(LibMetkit::paramIDYamlFile());
ASSERT(ids.isOrderedMap());

bool metkitRawParam = eckit::Resource<bool>("metkitRawParam;$METKIT_RAW_PARAM", false);
if (metkitRawParam) {
(*rules).push_back(Rule(eckit::Value::makeMap(), ids.keys(), ids));
return;
}

eckit::Value r = eckit::YAMLParser::decodeFile(LibMetkit::paramYamlFile());
ASSERT(r.isList());
// r.dump(std::cout) << std::endl;

const eckit::Value rs = eckit::YAMLParser::decodeFile(LibMetkit::paramStaticYamlFile());
ASSERT(rs.isList());
Expand Down Expand Up @@ -459,7 +457,6 @@ bool TypeParam::expand(const MarsExpandContext& ctx, const MarsRequest& request,


void TypeParam::pass2(const MarsExpandContext& ctx, MarsRequest& request) {
// std::cout << request << std::endl;
std::vector<std::string> values = request.values(name_, true);
expand(ctx, request, values, true);
request.setValuesTyped(this, values);
Expand Down

0 comments on commit 64e7f9f

Please sign in to comment.