-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
curvefs metaserver supports external services #974
Conversation
recheck |
1 similar comment
recheck |
curvefs/src/metaserver/register.h
Outdated
@@ -36,7 +36,8 @@ struct RegisterOptions { | |||
std::string mdsListenAddr; | |||
std::string metaserverInternalIp; | |||
std::string metaserverExternalIp; | |||
int metaserverPort; | |||
uint32_t metaserverPort; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metaserverInternalPort?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -87,6 +89,8 @@ void Metaserver::InitRegisterOptions() { | |||
conf_->GetValueFatalIfFail("global.external_ip", | |||
®isterOptions_.metaserverExternalIp); | |||
conf_->GetValueFatalIfFail("global.port", ®isterOptions_.metaserverPort); | |||
conf_->GetValueFatalIfFail("global.external_port", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conf->GetBoolValue("global.enable_external_server",
&options_.enableExternalServer);
if enable is false, can you still get external port?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conf->GetBoolValue("global.enable_external_server", &options_.enableExternalServer);
if enable is false, can you still get external port?
Default the switch is off and external ip and port is same as internal ip and port. The metaserve.conf and topology.json created by curveamd will support and I have reached a consensus with @Wine93.
If you want to turn on this switch, you need set enable to true and available external ip and port in topology.yaml(curveamd).
<< "start internal brpc server error"; | ||
|
||
// add external server | ||
externalServer_ = absl::make_unique<brpc::Server>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this in if ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this in if ?
fixed.
uint16_t internalPort = csl.port(); | ||
std::string internalIp = csl.hostip(); | ||
csinfo.peerID = csl.metaserverid(); | ||
uint16_t externalPort = internalPort; | ||
std::string externalIp = internalIp; | ||
if (csl.has_externalport()) { | ||
externalPort = csl.externalport(); | ||
} | ||
if (csl.has_externalip()) { | ||
externalIp = csl.externalip(); | ||
} | ||
|
||
butil::EndPoint internal; | ||
butil::str2endpoint(internalIp.c_str(), port, &internal); | ||
butil::str2endpoint(internalIp.c_str(), internalPort, | ||
&internal); | ||
butil::EndPoint external; | ||
butil::str2endpoint(externalIp.c_str(), port, &external); | ||
butil::str2endpoint(externalIp.c_str(), externalPort, | ||
&external); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic is almost the same as above, try to extract this into a single function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic is almost the same as above, try to extract this into a single function.
fixed
@@ -64,6 +64,8 @@ void Metaserver::InitOptions(std::shared_ptr<Configuration> conf) { | |||
conf_ = conf; | |||
conf_->GetValueFatalIfFail("global.ip", &options_.ip); | |||
conf_->GetValueFatalIfFail("global.port", &options_.port); | |||
conf->GetBoolValue("global.enable_external_server", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use conf_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
conf_
fixed
butil::EndPoint listenAddr(ip, registerOptions_.metaserverExternalPort); | ||
|
||
// add raft-related service | ||
copysetNodeManager_->AddService(externalServer_.get(), listenAddr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raft-related services should only be added to the internal server.
previous ChunkServer implementation adds raft-related service because it has compatible problem, there're lots of old clients that can upgrade.
and in CopysetNodeManager::AddService
,
void CopysetNodeManager::AddService(brpc::Server* server, |
you should add
RaftCliService2
into external server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raft-related services should only be added to the internal server.
previous ChunkServer implementation adds raft-related service because it has compatible problem, there're lots of old clients that can upgrade.
and in
CopysetNodeManager::AddService
,
void CopysetNodeManager::AddService(brpc::Server* server, you should add
RaftCliService2
into external server.
fixed
brpc::ServerOptions option; | ||
if (options_.bthreadWorkerCount != -1) { | ||
option.num_threads = options_.bthreadWorkerCount; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use above option is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use above option is enough.
done
if (options_.bthreadWorkerCount != -1) { | ||
option.num_threads = options_.bthreadWorkerCount; | ||
} | ||
LOG_IF(FATAL, externalServer_->Start(listenAddr, &option) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you didn't stop external server when Stop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you didn't stop external server when Stop.
fixed
9e79c77
to
2f698f9
Compare
curvefs/proto/topology.proto
Outdated
@@ -328,6 +328,7 @@ message MetaServerLocation { | |||
required string hostIp = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here change it to internal ip, internal port
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here change it to internal ip, internal port
Change to internalIp and internalPort on all the related interfces.
@@ -810,6 +810,7 @@ void TopologyManager::GetMetaServerListInCopysets( | |||
location->set_hostip(metaserver.GetInternalHostIp()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
fixed
f6f1d97
to
86a17a1
Compare
curvefs/proto/topology.proto
Outdated
required string InternalIp = 3; | ||
required uint32 InternalPort = 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable name should starts with lowercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable name should starts with lowercase
fixed
curvefs/proto/topology.proto
Outdated
required string InternalIp = 2; | ||
required uint32 InternalPort = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
curvefs/proto/topology.proto
Outdated
required string InternalIp = 2; | ||
required uint32 Internalport = 3; | ||
optional string externalIp = 4; | ||
optional uint32 externalPort = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
template<typename T> | ||
void GetEndPoint(const T &info, butil::EndPoint *internal, | ||
butil::EndPoint *external); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to define it as member functions, define in cpp file and as free template function is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to define it as member functions, define in cpp file and as free template function is enough.
fixed
brpc::SERVER_DOESNT_OWN_SERVICE) != 0) | ||
<< "add raftCliService2 error"; | ||
LOG_IF(FATAL, externalServer_->AddService(&raftStatService, | ||
brpc::SERVER_DOESNT_OWN_SERVICE) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
externalServer_->AddService(new braft::RaftStatImpl{},
brpc::SERVER_OWN_SERVICE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new braft::RaftStatImpl{}
fixed
@@ -222,6 +256,8 @@ void Metaserver::Stop() { | |||
|
|||
LOG(INFO) << "MetaServer is going to quit"; | |||
|
|||
externalServer_->Stop(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should check whether external ip is enabled otherwise, externalServer_ is null, this can cause segment fault.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should check whether external ip is enabled otherwise, externalServer_ is null, this can cause segment fault.
fixed
std::string internalIp = info.internalip(); | ||
std::string externalIp = internalIp; | ||
if (info.has_externalip()) { | ||
externalIp = info.externalip(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const std::string& internalIp = info.internalip();
const std::string externalIp = [&info]() {
if (info.has_externalip()) {
return info.externapIp();
} else {
return info.internalIp();
}
}();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const std::string& internalIp = info.internalip(); const std::string externalIp = [&info]() { if (info.has_externalip()) { return info.externapIp(); } else { return info.internalIp(); } }();
fixed
uint32_t internalPort = info.internalport(); | ||
uint32_t externalPort = internalPort; | ||
if (info.has_externalport()) { | ||
externalPort = info.externalport(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
d7c568e
to
ac2c254
Compare
…cluster communicate itself and some external services support for client and management tools. If all the services start on the same ip+port will affect the communication within the cluster when the heavy stress from client. Start the services needed by outsied on another ip+port as a external server.
recheck |
What problem does this PR solve?
Issue Number: close #xxx
#973
Problem Summary:
What is changed and how it works?
What's Changed:
How it Works:
Side effects(Breaking backward compatibility? Performance regression?):
Check List