Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chunkserver: do not init and expose walpool when not use curve protoc… #291

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

@cw123 cw123 Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is useChunkFilePoolAsWalPool mean?

Copy link
Member Author

@xu-chaojie xu-chaojie Mar 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use chunkfile pool as wal pool

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outputs info log if succeeds

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<< "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