Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

SeanHai
Copy link
Contributor

@SeanHai SeanHai commented Jan 11, 2022

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

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@SeanHai SeanHai changed the title curvefs: The curvefs cluster has some internal service which support … curvefs metaserver supports external services Jan 11, 2022
@SeanHai SeanHai linked an issue Jan 11, 2022 that may be closed by this pull request
@YunhuiChen
Copy link
Contributor

recheck

1 similar comment
@SeanHai
Copy link
Contributor Author

SeanHai commented Jan 13, 2022

recheck

@@ -36,7 +36,8 @@ struct RegisterOptions {
std::string mdsListenAddr;
std::string metaserverInternalIp;
std::string metaserverExternalIp;
int metaserverPort;
uint32_t metaserverPort;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metaserverInternalPort?

Copy link
Contributor Author

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",
&registerOptions_.metaserverExternalIp);
conf_->GetValueFatalIfFail("global.port", &registerOptions_.metaserverPort);
conf_->GetValueFatalIfFail("global.external_port",
Copy link
Contributor

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?

Copy link
Contributor Author

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>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this in if ?

Copy link
Contributor Author

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.

Comment on lines 336 to 353
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);
Copy link
Contributor

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.

Copy link
Contributor Author

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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use conf_

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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

Comment on lines 229 to 232
brpc::ServerOptions option;
if (options_.bthreadWorkerCount != -1) {
option.num_threads = options_.bthreadWorkerCount;
}
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

@SeanHai SeanHai force-pushed the externalIp branch 2 times, most recently from 9e79c77 to 2f698f9 Compare January 13, 2022 07:40
@@ -328,6 +328,7 @@ message MetaServerLocation {
required string hostIp = 2;
Copy link
Contributor

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

Copy link
Contributor Author

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

fixed

@SeanHai SeanHai force-pushed the externalIp branch 2 times, most recently from f6f1d97 to 86a17a1 Compare January 14, 2022 02:15
Comment on lines 118 to 119
required string InternalIp = 3;
required uint32 InternalPort = 4;
Copy link
Contributor

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

Copy link
Contributor Author

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

Comment on lines 129 to 130
required string InternalIp = 2;
required uint32 InternalPort = 3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines 328 to 331
required string InternalIp = 2;
required uint32 Internalport = 3;
optional string externalIp = 4;
optional uint32 externalPort = 5;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines 165 to 167
template<typename T>
void GetEndPoint(const T &info, butil::EndPoint *internal,
butil::EndPoint *external);
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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)

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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

Comment on lines 262 to 266
std::string internalIp = info.internalip();
std::string externalIp = internalIp;
if (info.has_externalip()) {
externalIp = info.externalip();
}
Copy link
Contributor

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();
    }
}();

Copy link
Contributor Author

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

Comment on lines 268 to 272
uint32_t internalPort = info.internalport();
uint32_t externalPort = internalPort;
if (info.has_externalport()) {
externalPort = info.externalport();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@SeanHai SeanHai force-pushed the externalIp branch 3 times, most recently from d7c568e to ac2c254 Compare January 20, 2022 07:48
…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.
@SeanHai
Copy link
Contributor Author

SeanHai commented Jan 21, 2022

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

curvefs metaserver supports external services
4 participants