Skip to content

Commit 4b8271c

Browse files
committed
[native] Support specification of node pool type in announcer
1 parent b12e90d commit 4b8271c

File tree

7 files changed

+26
-0
lines changed

7 files changed

+26
-0
lines changed

presto-native-execution/presto_cpp/main/Announcer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ std::string announcementBody(
3030
const std::string& nodeVersion,
3131
const std::string& environment,
3232
const std::string& nodeLocation,
33+
const std::string& nodePoolType,
3334
const bool sidecar,
3435
const std::vector<std::string>& connectorIds) {
3536
std::string id =
@@ -49,6 +50,7 @@ std::string announcementBody(
4950
{"coordinator", false},
5051
{"sidecar", sidecar},
5152
{"connectorIds", folly::join(',', connectorIds)},
53+
{"pool_type", nodePoolType},
5254
{uriScheme,
5355
fmt::format("{}://{}:{}", uriScheme, address, port)}}}}}}};
5456
return body.dump();
@@ -81,6 +83,7 @@ Announcer::Announcer(
8183
const std::string& environment,
8284
const std::string& nodeId,
8385
const std::string& nodeLocation,
86+
const std::string& nodePoolType,
8487
const bool sidecar,
8588
const std::vector<std::string>& connectorIds,
8689
const uint64_t maxFrequencyMs,
@@ -99,6 +102,7 @@ Announcer::Announcer(
99102
nodeVersion,
100103
environment,
101104
nodeLocation,
105+
nodePoolType,
102106
sidecar,
103107
connectorIds)),
104108
announcementRequest_(

presto-native-execution/presto_cpp/main/Announcer.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Announcer : public PeriodicServiceInventoryManager {
3131
const std::string& environment,
3232
const std::string& nodeId,
3333
const std::string& nodeLocation,
34+
const std::string& nodePoolType,
3435
const bool sidecar,
3536
const std::vector<std::string>& connectorIds,
3637
const uint64_t maxFrequencyMs_,

presto-native-execution/presto_cpp/main/PrestoServer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ void PrestoServer::run() {
242242
address_ = fmt::format("[{}]", address_);
243243
}
244244
nodeLocation_ = nodeConfig->nodeLocation();
245+
nodePoolType_ = systemConfig->poolType();
245246
prestoBuiltinFunctionPrefix_ = systemConfig->prestoDefaultNamespacePrefix();
246247
} catch (const velox::VeloxUserError& e) {
247248
PRESTO_STARTUP_LOG(ERROR) << "Failed to start server due to " << e.what();
@@ -577,6 +578,7 @@ void PrestoServer::run() {
577578
environment_,
578579
nodeId_,
579580
nodeLocation_,
581+
nodePoolType_,
580582
systemConfig->prestoNativeSidecar(),
581583
catalogNames,
582584
systemConfig->announcementMaxFrequencyMs(),

presto-native-execution/presto_cpp/main/PrestoServer.h

+1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ class PrestoServer {
290290
std::string nodeId_;
291291
std::string address_;
292292
std::string nodeLocation_;
293+
std::string nodePoolType_;
293294
folly::SSLContextPtr sslContext_;
294295
std::string prestoBuiltinFunctionPrefix_;
295296
};

presto-native-execution/presto_cpp/main/common/Configs.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ SystemConfig::SystemConfig() {
240240
BOOL_PROP(kEnableRuntimeMetricsCollection, false),
241241
BOOL_PROP(kPlanValidatorFailOnNestedLoopJoin, false),
242242
STR_PROP(kPrestoDefaultNamespacePrefix, "presto.default"),
243+
STR_PROP(kPoolType, "DEFAULT"),
243244
};
244245
}
245246

@@ -290,6 +291,17 @@ std::string SystemConfig::prestoVersion() const {
290291
return requiredProperty(std::string(kPrestoVersion));
291292
}
292293

294+
std::string SystemConfig::poolType() const {
295+
static const std::unordered_set<std::string> kPoolTypes = {"LEAF", "INTERMEDIATE", "DEFAULT"};
296+
static constexpr std::string_view kPoolTypeDefault = "DEFAULT";
297+
auto value = optionalProperty<std::string>(kPoolType).value_or(std::string(kPoolTypeDefault));
298+
VELOX_USER_CHECK(
299+
kPoolTypes.count(value),
300+
"{} must be one of 'LEAF', 'INTERMEDIATE', or 'DEFAULT'",
301+
kPoolType);
302+
return value;
303+
}
304+
293305
bool SystemConfig::mutableConfig() const {
294306
return optionalProperty<bool>(kMutableConfig).value();
295307
}

presto-native-execution/presto_cpp/main/common/Configs.h

+5
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ class SystemConfig : public ConfigBase {
659659
static constexpr std::string_view kPrestoDefaultNamespacePrefix{
660660
"presto.default-namespace"};
661661

662+
// Specifies the type of worker pool
663+
static constexpr std::string_view kPoolType{"pool-type"};
664+
662665
SystemConfig();
663666

664667
virtual ~SystemConfig() = default;
@@ -898,6 +901,8 @@ class SystemConfig : public ConfigBase {
898901

899902
bool prestoNativeSidecar() const;
900903
std::string prestoDefaultNamespacePrefix() const;
904+
905+
std::string poolType() const;
901906
};
902907

903908
/// Provides access to node properties defined in node.properties file.

presto-native-execution/presto_cpp/main/tests/AnnouncerTest.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ TEST_P(AnnouncerTestSuite, basic) {
173173
"testing",
174174
"test-node",
175175
"test-node-location",
176+
"DEFAULT",
176177
true,
177178
{"hive", "tpch"},
178179
500 /*milliseconds*/,

0 commit comments

Comments
 (0)