@@ -45,9 +45,6 @@ using ::curve::common::BLOCKSIZEKEY;
45
45
using ::curve::common::CHUNKSIZEKEY;
46
46
47
47
MDS::~MDS () {
48
- if (etcdEndpoints_) {
49
- delete etcdEndpoints_;
50
- }
51
48
if (fileLockManager_) {
52
49
delete fileLockManager_;
53
50
}
@@ -202,14 +199,23 @@ void MDS::Stop() {
202
199
}
203
200
204
201
void MDS::InitEtcdConf (EtcdConf* etcdConf) {
205
- std::string endpoint;
206
- conf_->GetValueFatalIfFail (" mds.etcd.endpoint" , &endpoint);
207
- etcdEndpoints_ = new char [endpoint.size ()];
208
- etcdConf->Endpoints = etcdEndpoints_;
209
- std::memcpy (etcdConf->Endpoints , endpoint.c_str (), endpoint.size ());
210
- etcdConf->len = endpoint.size ();
202
+ conf_->GetValueFatalIfFail (" mds.etcd.endpoint" , &etcdEndpoints_);
203
+ etcdConf->len = etcdEndpoints_.size ();
204
+ etcdConf->Endpoints = &etcdEndpoints_[0 ];
211
205
conf_->GetValueFatalIfFail (
212
206
" mds.etcd.dailtimeoutMs" , &etcdConf->DialTimeout );
207
+ // etcd auth config
208
+ bool authEnable = false ;
209
+ conf_->GetBoolValue (" etcd.auth.enable" , &authEnable);
210
+ etcdConf->authEnable = authEnable ? 1 : 0 ;
211
+ if (authEnable) {
212
+ conf_->GetValueFatalIfFail (" etcd.auth.username" , &etcdUsername_);
213
+ etcdConf->username = &etcdUsername_[0 ];
214
+ etcdConf->usernameLen = etcdUsername_.size ();
215
+ conf_->GetValueFatalIfFail (" etcd.auth.password" , &etcdPassword_);
216
+ etcdConf->password = &etcdPassword_[0 ];
217
+ etcdConf->passwordLen = etcdPassword_.size ();
218
+ }
213
219
}
214
220
215
221
void MDS::StartServer () {
@@ -261,7 +267,8 @@ void MDS::InitEtcdClient(const EtcdConf& etcdConf,
261
267
<< " , etcdaddr len: " << etcdConf.len
262
268
<< " , etcdtimeout: " << etcdConf.DialTimeout
263
269
<< " , operation timeout: " << etcdTimeout
264
- << " , etcd retrytimes: " << retryTimes;
270
+ << " , etcd retrytimes: " << retryTimes
271
+ << " , auth enable = " << etcdConf.authEnable ;
265
272
266
273
267
274
std::string out;
@@ -275,7 +282,8 @@ void MDS::InitEtcdClient(const EtcdConf& etcdConf,
275
282
<< " , etcdaddr len: " << etcdConf.len
276
283
<< " , etcdtimeout: " << etcdConf.DialTimeout
277
284
<< " , operation timeout: " << etcdTimeout
278
- << " , etcd retrytimes: " << retryTimes;
285
+ << " , etcd retrytimes: " << retryTimes
286
+ << " , auth enable = " << etcdConf.authEnable ;
279
287
}
280
288
281
289
void MDS::InitLeaderElection (const LeaderElectionOptions& leaderElectionOp) {
0 commit comments