Skip to content

Commit

Permalink
chunkserver: do not init and expose walpool when not use curve protoc…
Browse files Browse the repository at this point in the history
…ol in raftLogUri
  • Loading branch information
xu-chaojie authored and ilixiaocui committed Mar 16, 2021
1 parent 25e8c00 commit 557b9f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
40 changes: 25 additions & 15 deletions src/chunkserver/chunkserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ DEFINE_string(walFilePoolDir, "./0/", "WAL filepool location");
DEFINE_string(walFilePoolMetaPath, "./walfilepool.meta",
"WAL filepool meta path");

const char* kProtocalCurve = "curve";

namespace curve {
namespace chunkserver {

Expand Down Expand Up @@ -138,20 +140,26 @@ int ChunkServer::Run(int argc, char** argv) {


// Init Wal file pool
bool useChunkFilePool = true;
LOG_IF(FATAL, !conf.GetBoolValue(
"walfilepool.use_chunk_file_pool",
&useChunkFilePool));

if (!useChunkFilePool) {
FilePoolOptions walFilePoolOptions;
InitWalFilePoolOptions(&conf, &walFilePoolOptions);
kWalFilePool = std::make_shared<FilePool>(fs);
LOG_IF(FATAL, false == kWalFilePool->Initialize(walFilePoolOptions))
<< "Failed to init wal file pool";
} else {
kWalFilePool = chunkfilePool;
LOG(INFO) << "initialize to use chunkfilePool as walpool success.";
std::string raftLogUri;
LOG_IF(FATAL, !conf.GetStringValue("copyset.raft_log_uri", &raftLogUri));
std::string raftLogProtocol = UriParser::GetProtocolFromUri(raftLogUri);
bool useChunkFilePoolAsWalPool = true;
if (raftLogProtocol == kProtocalCurve) {
LOG_IF(FATAL, !conf.GetBoolValue(
"walfilepool.use_chunk_file_pool",
&useChunkFilePoolAsWalPool));

if (!useChunkFilePoolAsWalPool) {
FilePoolOptions walFilePoolOptions;
InitWalFilePoolOptions(&conf, &walFilePoolOptions);
kWalFilePool = std::make_shared<FilePool>(fs);
LOG_IF(FATAL, false == kWalFilePool->Initialize(walFilePoolOptions))
<< "Failed to init wal file pool";
LOG(INFO) << "initialize walpool success.";
} else {
kWalFilePool = chunkfilePool;
LOG(INFO) << "initialize to use chunkfilePool as walpool success.";
}
}

// 远端拷贝管理模块选项
Expand Down Expand Up @@ -260,7 +268,9 @@ int ChunkServer::Run(int argc, char** argv) {
// 监控部分模块的metric指标
metric->MonitorTrash(trash_.get());
metric->MonitorChunkFilePool(chunkfilePool.get());
metric->MonitorWalFilePool(kWalFilePool.get());
if (raftLogProtocol == kProtocalCurve && !useChunkFilePoolAsWalPool) {
metric->MonitorWalFilePool(kWalFilePool.get());
}
metric->ExposeConfigMetric(&conf);

// ========================添加rpc服务===============================//
Expand Down
2 changes: 1 addition & 1 deletion src/chunkserver/trash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ bool Trash::RecycleChunkfile(

bool Trash::RecycleWAL(
const std::string &filepath, const std::string &filename) {
if (0 != walPool_->RecycleFile(filepath)) {
if (walPool_ != nullptr && 0 != walPool_->RecycleFile(filepath)) {
LOG(ERROR) << "Trash failed recycle WAL " << filepath
<< " to WALPool";
return false;
Expand Down

0 comments on commit 557b9f2

Please sign in to comment.