Skip to content

Commit

Permalink
[feat]curvefs/mds: change MissTimeOutMs on fly
Browse files Browse the repository at this point in the history
use gflag to change heartbeatMissTimeOutMs on fly

Signed-off-by: Cyber-SiKu <Cyber-SiKu@outlook.com>
  • Loading branch information
Cyber-SiKu committed Oct 17, 2023
1 parent 5df3d6b commit bb66c12
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 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

0 comments on commit bb66c12

Please sign in to comment.