Skip to content

Commit a2f4b1d

Browse files
ilixiaocuiopencurveadmin
authored andcommitted
client: support create stripe volume from py_client.conf
1 parent 55143c1 commit a2f4b1d

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

conf/py_client.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,9 @@ global.metricDummyServerStartPort=10000
149149
# session map文件,存储打开文件的filename到path的映射
150150
#
151151
global.sessionMapPath=./session_map.json
152+
153+
#
154+
############### 创建文件的配置 #############
155+
#
156+
create.file.stripeUnit=16384
157+
create.file.stripeCount=64

src/client/client_config.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@ int ClientConfig::Init(const std::string& configpath) {
287287
LOG_IF(WARNING, ret = false)
288288
<< "config no csBroadCasterOpt.broadCastMaxNum info";
289289

290+
ret = conf_.GetUInt64Value("create.file.stripeUnit",
291+
&stripeUnit_);
292+
LOG_IF(WARNING, ret = false) << "config no create.file.stripeUnit info";
293+
294+
ret = conf_.GetUInt64Value("create.file.stripeCount",
295+
&stripeCount_);
296+
LOG_IF(WARNING, ret = false) << "config no create.file.stripeCount info";
297+
290298
return 0;
291299
}
292300

src/client/client_config.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,24 @@ class ClientConfig {
4848

4949
uint16_t GetDummyserverStartPort();
5050

51+
uint64_t GetStripeUnit() const {
52+
return stripeUnit_;
53+
}
54+
55+
uint64_t GetStripeCount() const {
56+
return stripeCount_;
57+
}
58+
5159
private:
5260
FileServiceOption fileServiceOption_;
5361
common::Configuration conf_;
62+
63+
// TODO: if cinder use old-version client but want stripe-volume feature,
64+
// you can add this parameter in the configuration file.
65+
// But this is not an elegant approach; it would be better if Cinder
66+
// could be upgraded to accommodate this.
67+
uint64_t stripeUnit_ = 0;
68+
uint64_t stripeCount_ = 0;
5469
};
5570

5671
} // namespace client

src/client/libcurve_file.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ int FileClient::Create(const std::string& filename,
308308
ctx.user = userinfo;
309309
ctx.length = size;
310310

311+
if (clientconfig_.GetStripeUnit() > 0 &&
312+
clientconfig_.GetStripeCount() > 0) {
313+
ctx.stripeUnit = clientconfig_.GetStripeUnit();
314+
ctx.stripeCount = clientconfig_.GetStripeCount();
315+
}
316+
311317
ret = mdsClient_->CreateFile(ctx);
312318
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
313319
<< "Create file failed, filename: " << filename << ", ret: " << ret;

0 commit comments

Comments
 (0)