Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion presto-native-execution/etc/node.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node.environment=testing
node.id=e4901aae-a1c9-4ff7-97a9-5687835ad54c
node.internal-address=127.0.0.1
node.location=testing-location
12 changes: 11 additions & 1 deletion presto-native-execution/presto_cpp/main/common/Configs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "presto_cpp/main/common/Utils.h"
#include "velox/core/QueryConfig.h"

#include <boost/lexical_cast.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#if __has_include("filesystem")
#include <filesystem>
namespace fs = std::filesystem;
Expand Down Expand Up @@ -648,7 +651,14 @@ std::string NodeConfig::nodeEnvironment() const {
}

std::string NodeConfig::nodeId() const {
return requiredProperty(kNodeId);
auto resultOpt = optionalProperty(kNodeId);
if (resultOpt.hasValue()) {
return resultOpt.value();
}
// Generate the nodeId which must be a UUID. nodeId must be a singleton.
static auto nodeId =
boost::lexical_cast<std::string>(boost::uuids::random_generator()());
return nodeId;
}

std::string NodeConfig::nodeLocation() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_executable(
presto_server_test
AnnouncerTest.cpp
CoordinatorDiscovererTest.cpp
ConfigsTest.cpp
HttpServerWrapper.cpp
MutableConfigs.cpp
PeriodicMemoryCheckerTest.cpp
Expand Down
31 changes: 31 additions & 0 deletions presto-native-execution/presto_cpp/main/tests/ConfigsTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "presto_cpp/main/common/Configs.h"

#include <gtest/gtest.h>

namespace facebook::presto {
namespace {

TEST(NodeConfig, optionalNodeId) {
NodeConfig config;
auto nodeId = config.nodeId();
// Same value must be returned.
EXPECT_EQ(nodeId, config.nodeId());
EXPECT_EQ(nodeId, config.nodeId());
}

} // namespace
} // namespace facebook::presto