Skip to content

Commit

Permalink
client: support create stripe volume from py_client.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
ilixiaocui authored and opencurveadmin committed May 23, 2024
1 parent 55143c1 commit a2f4b1d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions conf/py_client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,9 @@ global.metricDummyServerStartPort=10000
# session map文件,存储打开文件的filename到path的映射
#
global.sessionMapPath=./session_map.json

#
############### 创建文件的配置 #############
#
create.file.stripeUnit=16384
create.file.stripeCount=64
8 changes: 8 additions & 0 deletions src/client/client_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ int ClientConfig::Init(const std::string& configpath) {
LOG_IF(WARNING, ret = false)
<< "config no csBroadCasterOpt.broadCastMaxNum info";

ret = conf_.GetUInt64Value("create.file.stripeUnit",
&stripeUnit_);
LOG_IF(WARNING, ret = false) << "config no create.file.stripeUnit info";

ret = conf_.GetUInt64Value("create.file.stripeCount",
&stripeCount_);
LOG_IF(WARNING, ret = false) << "config no create.file.stripeCount info";

return 0;
}

Expand Down
15 changes: 15 additions & 0 deletions src/client/client_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,24 @@ class ClientConfig {

uint16_t GetDummyserverStartPort();

uint64_t GetStripeUnit() const {
return stripeUnit_;
}

uint64_t GetStripeCount() const {
return stripeCount_;
}

private:
FileServiceOption fileServiceOption_;
common::Configuration conf_;

// TODO: if cinder use old-version client but want stripe-volume feature,
// you can add this parameter in the configuration file.
// But this is not an elegant approach; it would be better if Cinder
// could be upgraded to accommodate this.
uint64_t stripeUnit_ = 0;
uint64_t stripeCount_ = 0;
};

} // namespace client
Expand Down
6 changes: 6 additions & 0 deletions src/client/libcurve_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ int FileClient::Create(const std::string& filename,
ctx.user = userinfo;
ctx.length = size;

if (clientconfig_.GetStripeUnit() > 0 &&
clientconfig_.GetStripeCount() > 0) {
ctx.stripeUnit = clientconfig_.GetStripeUnit();
ctx.stripeCount = clientconfig_.GetStripeCount();
}

ret = mdsClient_->CreateFile(ctx);
LOG_IF(ERROR, ret != LIBCURVE_ERROR::OK)
<< "Create file failed, filename: " << filename << ", ret: " << ret;
Expand Down

0 comments on commit a2f4b1d

Please sign in to comment.