Skip to content

Commit

Permalink
[feat]curvefs: change some conf on fly
Browse files Browse the repository at this point in the history
1. use gflag to change mds heartbeatMissTimeOutMs on fly
2. use gflag to change metaserver transh.expiredAfterSec on fly
2. use gflag to change metaserver transh.scanPeriodSec on fly

Signed-off-by: Cyber-SiKu <Cyber-SiKu@outlook.com>
  • Loading branch information
Cyber-SiKu committed Oct 17, 2023
1 parent 5df3d6b commit ab5cafe
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 12 deletions.
22 changes: 21 additions & 1 deletion curvefs/src/mds/heartbeat/metaserver_healthy_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ using ::curvefs::mds::topology::TopoStatusCode;
using ::curve::common::WriteLockGuard;
using std::chrono::milliseconds;

// the maximun peroid that heartbeat is missed without
// setting the metaserver to offline status and alarm.
// scheduling will depend on this status of metaserver
DEFINE_uint64(heartbeat_OffLineTimeOutMs, 1800000,
"the maximun peroid that heartbeat is missed without setting the "
"metaserver to offline status and alarm.");

// network jitter is unavoidable, and for this reason
// background process will alarm during the inspection once it
// finds out that heartbeat is missed after heartbeatMissTimeOut peroid
DEFINE_uint64(
heartbeat_MissTimeOutMs, 30000,
"background process will alarm during the inspection once it finds out "
"that heartbeat is missed after heartbeatMissTimeOut peroid");
static bool pass_uint64(const char*, uint64_t value) {
return value >= FLAGS_heartbeat_MissTimeOutMs;
}
DEFINE_validator(heartbeat_OffLineTimeOutMs, pass_uint64);

namespace curvefs {
namespace mds {
namespace heartbeat {
Expand Down Expand Up @@ -68,7 +87,8 @@ bool MetaserverHealthyChecker::MetaServerStateNeedUpdate(
return false;
}

bool shouldUnstable = (timePass < milliseconds(option_.offLineTimeOutMs));
bool shouldUnstable =
(timePass < milliseconds(FLAGS_heartbeat_OffLineTimeOutMs));
if (shouldUnstable) {
if (OnlineState::UNSTABLE != info.state) {
LOG(WARNING) << "metaserver " << info.msId << " is unstable. "
Expand Down
32 changes: 25 additions & 7 deletions curvefs/src/mds/heartbeat/metaserver_healthy_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,25 @@
#ifndef CURVEFS_SRC_MDS_HEARTBEAT_METASERVER_HEALTHY_CHECKER_H_
#define CURVEFS_SRC_MDS_HEARTBEAT_METASERVER_HEALTHY_CHECKER_H_

#include <chrono> //NOLINT
#include <memory>
#include <gflags/gflags_declare.h>

#include <chrono> //NOLINT
#include <map>
#include "curvefs/src/mds/common/types.h"
#include <memory>

#include "curvefs/proto/topology.pb.h"
#include "curvefs/src/mds/common/mds_define.h"
#include "curvefs/src/mds/common/types.h"
#include "curvefs/src/mds/topology/topology.h"
#include "curvefs/proto/topology.pb.h"

using ::std::chrono::steady_clock;
using ::curvefs::mds::topology::MetaServerIdType;
using ::curvefs::mds::topology::Topology;
using ::curvefs::mds::topology::OnlineState;

DECLARE_uint64(heartbeat_OffLineTimeOutMs);
DECLARE_uint64(heartbeat_MissTimeOutMs);

namespace curvefs {
namespace mds {
namespace heartbeat {
Expand All @@ -45,8 +51,20 @@ struct HeartbeatOption {
uint64_t heartbeatMissTimeout,
uint64_t offLineTimeout) {
this->heartbeatIntervalMs = heartbeatInterval;
this->heartbeatMissTimeOutMs = heartbeatMissTimeout;
this->offLineTimeOutMs = offLineTimeout;
FLAGS_heartbeat_MissTimeOutMs = this->heartbeatMissTimeOutMs =
heartbeatMissTimeout;
FLAGS_heartbeat_OffLineTimeOutMs = this->offLineTimeOutMs =
offLineTimeout;
}

explicit HeartbeatOption(const HeartbeatOption& option)
: heartbeatIntervalMs(option.heartbeatIntervalMs),
heartbeatMissTimeOutMs(option.heartbeatMissTimeOutMs),
offLineTimeOutMs(option.offLineTimeOutMs),
cleanFollowerAfterMs(option.cleanFollowerAfterMs),
mdsStartTime(option.mdsStartTime) {
FLAGS_heartbeat_OffLineTimeOutMs = offLineTimeOutMs;
FLAGS_heartbeat_MissTimeOutMs = heartbeatMissTimeOutMs;
}

// heartbeatIntervalMs: normal heartbeat interval.
Expand Down Expand Up @@ -91,7 +109,7 @@ struct HeartbeatInfo {
class MetaserverHealthyChecker {
public:
MetaserverHealthyChecker(
HeartbeatOption option, const std::shared_ptr<Topology> &topo) :
const HeartbeatOption& option, const std::shared_ptr<Topology> &topo) :
option_(option), topo_(topo) {}
~MetaserverHealthyChecker() {}

Expand Down
12 changes: 11 additions & 1 deletion curvefs/src/metaserver/trash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include "curvefs/src/metaserver/trash.h"
#include "curvefs/src/metaserver/inode_storage.h"
#include "src/common/timeutility.h"
#include "curvefs/proto/mds.pb.h"

Expand All @@ -32,9 +33,18 @@ namespace metaserver {
using ::curvefs::mds::FsInfo;
using ::curvefs::mds::FSStatusCode;

bool pass_uint32(const char*, uint32_t value) { return true; }
DEFINE_uint32(trash_expiredAfterSec, 604800,
"time to delete data in the recycle bin");
DEFINE_uint32(trash_scanPeriodSec, 600, "recycle bin scan interval");
DEFINE_validator(trash_expiredAfterSec, pass_uint32);
DEFINE_validator(trash_scanPeriodSec, pass_uint32);

void TrashOption::InitTrashOptionFromConf(std::shared_ptr<Configuration> conf) {
conf->GetValueFatalIfFail("trash.scanPeriodSec", &scanPeriodSec);
FLAGS_trash_scanPeriodSec = scanPeriodSec;
conf->GetValueFatalIfFail("trash.expiredAfterSec", &expiredAfterSec);
FLAGS_trash_expiredAfterSec = expiredAfterSec;
}

void TrashImpl::Init(const TrashOption &option) {
Expand Down Expand Up @@ -129,7 +139,7 @@ bool TrashImpl::NeedDelete(const TrashItem &item) {
// if fs recycleTimeHour is not 0, return true
uint64_t recycleTimeHour = GetFsRecycleTimeHour(item.fsId);
if (recycleTimeHour == 0) {
return ((now - item.dtime) >= options_.expiredAfterSec);
return ((now - item.dtime) >= FLAGS_trash_expiredAfterSec);
} else {
return true;
}
Expand Down
8 changes: 5 additions & 3 deletions curvefs/src/metaserver/trash_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
namespace curvefs {
namespace metaserver {

DECLARE_uint32(trash_scanPeriodSec);

int TrashManager::Run() {
if (isStop_.exchange(false)) {
recycleThread_ =
Expand All @@ -48,9 +50,9 @@ void TrashManager::Fini() {
}

void TrashManager::ScanLoop() {
while (sleeper_.wait_for(std::chrono::seconds(options_.scanPeriodSec))) {
ScanEveryTrash();
}
while (sleeper_.wait_for(std::chrono::seconds(FLAGS_trash_scanPeriodSec))) {
ScanEveryTrash();
}
}

void TrashManager::ScanEveryTrash() {
Expand Down

0 comments on commit ab5cafe

Please sign in to comment.