Skip to content

Commit 1b83952

Browse files
authored
Merge branch 'master' into fix_build
2 parents cb1f003 + be4f199 commit 1b83952

File tree

11 files changed

+32
-14
lines changed

11 files changed

+32
-14
lines changed

src/clients/meta/MetaClient.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ bool MetaClient::isMetadReady() {
125125
return ready_;
126126
}
127127

128-
bool MetaClient::waitForMetadReady(int count, int retryIntervalSecs) {
128+
bool MetaClient::waitForMetadReady(const std::string& handshakeKey,
129+
int count,
130+
int retryIntervalSecs) {
129131
if (!options_.skipConfig_) {
130132
std::string gflagsJsonPath;
131133
GflagsManager::getGflagsModule(gflagsModule_);
@@ -145,7 +147,7 @@ bool MetaClient::waitForMetadReady(int count, int retryIntervalSecs) {
145147
}
146148

147149
// Verify the graph server version
148-
auto status = verifyVersion();
150+
auto status = verifyVersion(handshakeKey);
149151
if (!status.ok()) {
150152
LOG(ERROR) << status;
151153
return false;
@@ -3845,10 +3847,12 @@ bool MetaClient::checkIsPlanKilled(SessionID sessionId, ExecutionPlanID planId)
38453847
return metadata_.load()->killedPlans_.count({sessionId, planId});
38463848
}
38473849

3848-
Status MetaClient::verifyVersion() {
3850+
Status MetaClient::verifyVersion(const std::string& handshakeKey) {
38493851
memory::MemoryCheckOffGuard g;
38503852
auto req = cpp2::VerifyClientVersionReq();
3851-
req.build_version_ref() = getOriginVersion();
3853+
if (!handshakeKey.empty()) {
3854+
req.build_version_ref() = handshakeKey;
3855+
}
38523856
req.host_ref() = options_.localHost_;
38533857
folly::Promise<StatusOr<cpp2::VerifyClientVersionResp>> promise;
38543858
auto future = promise.getFuture();

src/clients/meta/MetaClient.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ class MetaClient : public BaseMetaClient {
248248

249249
bool isMetadReady();
250250

251-
bool waitForMetadReady(int count = -1, int retryIntervalSecs = FLAGS_heartbeat_interval_secs);
251+
bool waitForMetadReady(const std::string& handshakeKey = "",
252+
int count = -1,
253+
int retryIntervalSecs = FLAGS_heartbeat_interval_secs);
252254

253255
void notifyStop();
254256

@@ -752,7 +754,7 @@ class MetaClient : public BaseMetaClient {
752754

753755
// Checks if the client version is compatible with the server version by checking the
754756
// whitelist in meta.
755-
Status verifyVersion();
757+
Status verifyVersion(const std::string& handshakeKey);
756758

757759
// Save the version of the graph service into meta so that it could be looked up.
758760
// This method should be only called in the internal client.

src/graph/service/GraphFlags.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ DEFINE_bool(enable_optimizer, false, "Whether to enable optimizer");
6363
#ifndef BUILD_STANDALONE
6464
DEFINE_uint32(ft_request_retry_times, 3, "Retry times if fulltext request failed");
6565
DEFINE_bool(enable_client_white_list, true, "Turn on/off the client white list.");
66+
DEFINE_string(
67+
handshakeKey,
68+
"",
69+
"set handshakeKey for graph, please make the handshakeKey is in meta's client_white_list");
6670
DEFINE_string(client_white_list,
6771
nebula::getOriginVersion() + ":3.0.0",
6872
"A white list for different client handshakeKey, separate with colon.");

src/graph/service/GraphFlags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ DECLARE_bool(enable_experimental_feature);
6161
DECLARE_bool(enable_data_balance);
6262

6363
DECLARE_bool(enable_client_white_list);
64+
DECLARE_string(handshakeKey);
6465
DECLARE_string(client_white_list);
6566

6667
DECLARE_int32(num_rows_to_check_memory);

src/graph/service/GraphService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Status GraphService::init(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecuto
4343
metaClient_ = std::make_unique<meta::MetaClient>(ioExecutor, std::move(addrs.value()), options);
4444

4545
// Load data try 3 time
46-
bool loadDataOk = metaClient_->waitForMetadReady(3);
46+
bool loadDataOk = metaClient_->waitForMetadReady(FLAGS_handshakeKey, 3);
4747
if (!loadDataOk) {
4848
// Resort to retrying in the background
4949
LOG(ERROR) << "Failed to wait for meta service ready synchronously.";

src/meta/test/MetaClientTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,23 +1712,23 @@ TEST(MetaClientTest, VerifyClientTest) {
17121712
FLAGS_enable_client_white_list = true;
17131713
{
17141714
FLAGS_client_white_list = nebula::cpp2::common_constants::version();
1715-
auto status = client->verifyVersion();
1715+
auto status = client->verifyVersion("");
17161716
EXPECT_TRUE(status.ok());
17171717
}
17181718
{
17191719
FLAGS_client_white_list = "";
1720-
auto status = client->verifyVersion();
1720+
auto status = client->verifyVersion("");
17211721
EXPECT_FALSE(status.ok());
17221722
}
17231723
{
17241724
FLAGS_client_white_list = "1.0.0:1.2.0:";
1725-
auto status = client->verifyVersion();
1725+
auto status = client->verifyVersion("");
17261726
EXPECT_FALSE(status.ok());
17271727
}
17281728
{
17291729
FLAGS_enable_client_white_list = false;
17301730
FLAGS_client_white_list = "1.0.0:1.2.0:";
1731-
auto status = client->verifyVersion();
1731+
auto status = client->verifyVersion("");
17321732
EXPECT_TRUE(status.ok());
17331733
}
17341734
FLAGS_enable_client_white_list = false;

src/storage/StorageFlags.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
#include "storage/StorageFlags.h"
77

8+
DEFINE_string(
9+
handshakeKey,
10+
"",
11+
"set handshakeKey for storage, please make the handshakeKey is in meta's client_white_list");
12+
813
DEFINE_string(store_type,
914
"nebula",
1015
"Which type of KVStore to be used by the storage daemon."

src/storage/StorageFlags.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include "common/base/Base.h"
1010

11+
DECLARE_string(handshakeKey);
12+
1113
DECLARE_string(store_type);
1214

1315
DECLARE_int32(waiting_catch_up_retry_times);

src/storage/StorageServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ bool StorageServer::start() {
233233
}
234234
#endif
235235

236-
if (!metaClient_->waitForMetadReady()) {
236+
if (!metaClient_->waitForMetadReady(FLAGS_handshakeKey)) {
237237
LOG(ERROR) << "waitForMetadReady error!";
238238
return false;
239239
}

src/tools/db-dump/DbDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Status DbDumper::initMeta() {
5656
meta::MetaClientOptions options;
5757
options.skipConfig_ = true;
5858
metaClient_ = std::make_unique<meta::MetaClient>(ioExecutor, std::move(addrs.value()), options);
59-
if (!metaClient_->waitForMetadReady(1)) {
59+
if (!metaClient_->waitForMetadReady("", 1)) {
6060
return Status::Error("Meta is not ready: '%s'.", FLAGS_meta_server.c_str());
6161
}
6262
schemaMng_ = std::make_unique<meta::ServerBasedSchemaManager>();

src/tools/db-upgrade/DbUpgraderTool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ int main(int argc, char* argv[]) {
153153
auto metaClient =
154154
std::make_unique<nebula::meta::MetaClient>(ioExecutor, std::move(addrs.value()), options);
155155
CHECK_NOTNULL(metaClient);
156-
if (!metaClient->waitForMetadReady(1)) {
156+
if (!metaClient->waitForMetadReady("", 1)) {
157157
LOG(ERROR) << "Meta is not ready: " << FLAGS_upgrade_meta_server;
158158
return EXIT_FAILURE;
159159
}

0 commit comments

Comments
 (0)