Skip to content

Commit

Permalink
mds/metaserver: Add idle_timeout_sec option
Browse files Browse the repository at this point in the history
Signed-off-by: swj <[email protected]>
  • Loading branch information
201341 authored and wuhongsong committed Jun 27, 2023
1 parent 597e5bc commit 44949da
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions curvefs/conf/mds.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ mds.listen.addr=127.0.0.1:6700 #__CURVEADM_TEMPLATE__ ${service_addr}:${service
mds.dummy.port=7700 # __CURVEADM_TEMPLATE__ ${service_dummy_port} __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ curvefs_mds_listen_dummy_port }} __ANSIBLE_TEMPLATE__
mds.common.logDir=/tmp/curvefs/mds # __CURVEADM_TEMPLATE__ ${prefix}/logs __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ /tmp/{{ inventory_hostname }}/curvefs/mds __ANSIBLE_TEMPLATE__
mds.loglevel=0
# If a connection does not read or write,it's treated as "idle" and will be closed by server soon.
# Default value is -1 which disables the feature.
mds.server.idleTimeoutSec=-1

#
# space options
Expand Down
4 changes: 4 additions & 0 deletions curvefs/conf/metaserver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ applyqueue.read_queue_depth=1
# it is recommended to set it to |auto| unless there is a significant performance improvement
bthread.worker_count=auto

# If a connection does not read or write, it's treated as "idle" and will be closed by server soon.
# Default value is -1 which disables the feature.
server.idleTimeoutSec=-1

### Braft related flags
### These configurations are ignored if the command line startup options are set
# Call fsync when need
Expand Down
3 changes: 3 additions & 0 deletions curvefs/src/mds/mds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void MDS::InitOptions(std::shared_ptr<Configuration> conf) {
conf_ = std::move(conf);
conf_->GetValueFatalIfFail("mds.listen.addr", &options_.mdsListenAddr);
conf_->GetValueFatalIfFail("mds.dummy.port", &options_.dummyPort);
conf_->GetValueFatalIfFail("mds.server.idleTimeoutSec",
&options_.idleTimeoutSec);

InitMetaServerOption(&options_.metaserverOptions);
InitTopologyOption(&options_.topologyOptions);
Expand Down Expand Up @@ -275,6 +277,7 @@ void MDS::Run() {

// start rpc server
brpc::ServerOptions option;
option.idle_timeout_sec = options_.idleTimeoutSec;
LOG_IF(FATAL, server.Start(options_.mdsListenAddr.c_str(), &option) != 0)
<< "start brpc server error";
running_ = true;
Expand Down
2 changes: 2 additions & 0 deletions curvefs/src/mds/mds.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ using ::curvefs::mds::space::MdsProxyOptions;
struct MDSOptions {
int dummyPort;
std::string mdsListenAddr;
int idleTimeoutSec;

MetaserverOptions metaserverOptions;
// TODO(add EtcdConf): add etcd configure

Expand Down
4 changes: 4 additions & 0 deletions curvefs/src/metaserver/metaserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ void Metaserver::InitOptions(std::shared_ptr<Configuration> conf) {
<< "Parse bthread.worker_count to int failed, string value: "
<< value;
}
conf_->GetValueFatalIfFail("server.idleTimeoutSec",
&options_.idleTimeoutSec);


InitBRaftFlags(conf);
}
Expand Down Expand Up @@ -455,6 +458,7 @@ void Metaserver::Run() {
if (options_.bthreadWorkerCount != -1) {
option.num_threads = options_.bthreadWorkerCount;
}
option.idle_timeout_sec = options_.idleTimeoutSec;
LOG_IF(FATAL, server_->Start(listenAddr, &option) != 0)
<< "start internal brpc server error";

Expand Down
1 change: 1 addition & 0 deletions curvefs/src/metaserver/metaserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ struct MetaserverOptions {
std::string externalIp;
int externalPort;
int bthreadWorkerCount = -1;
int idleTimeoutSec = -1;
bool enableExternalServer;
};

Expand Down

0 comments on commit 44949da

Please sign in to comment.