MCPcopy Create free account
hub / github.com/Tencent/phxqueue / DoRun

Method DoRun

phxqueue/lock/cleanthread.cpp:77–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77void CleanThread::DoRun() {
78 if (nullptr == impl_->lock || nullptr == impl_->lock->GetNode()) {
79 QLErr("lock %p", impl_->lock);
80
81 return;
82 }
83
84 while (true) {
85 if (impl_->stop) return;
86
87 int nr_key{0};
88 int nr_clean_key{0};
89 const uint64_t now{comm::utils::Time::GetSteadyClockMS()};
90
91 bool need_clean_key{false};
92 if (now > last_clean_lock_ms_ + impl_->lock->GetLockOption()->clean_interval_s * 1000) {
93 need_clean_key = true;
94 last_clean_lock_ms_ = now;
95 }
96
97 bool need_write_restart_checkpoint{false};
98 if (now > last_write_restart_checkpoint_ms_ +
99 impl_->lock->GetLockOption()->idle_write_checkpoint_interval_s * 1000) {
100 need_write_restart_checkpoint = true;
101 last_write_restart_checkpoint_ms_ = now;
102 }
103
104 for (int paxos_group_id{0}; impl_->lock->GetLockOption()->nr_group > paxos_group_id;
105 ++paxos_group_id) {
106
107 if (need_clean_key) {
108 int nr_group_key{0};
109 int nr_group_clean_key{0};
110 CleanLock(paxos_group_id, now, nr_group_key, nr_group_clean_key);
111 nr_key += nr_group_key;
112 nr_clean_key += nr_group_clean_key;
113 }
114
115 if (need_write_restart_checkpoint) {
116 WriteRestartCheckpoint(paxos_group_id, now);
117 }
118 } // foreach group
119
120 QLInfo("now %llu nr_key %d nr_clean_key %d", now, nr_key, nr_clean_key);
121 comm::LockCleanThreadBP::GetThreadInstance()->
122 OnNrKey(impl_->lock->GetTopicID(), nr_key);
123 comm::LockCleanThreadBP::GetThreadInstance()->
124 OnNrCleanKey(impl_->lock->GetTopicID(), nr_clean_key);
125
126 sleep(1);
127 }
128}
129
130void CleanThread::CleanLock(const int paxos_group_id, const uint64_t now,
131 int &nr_group_key, int &nr_group_clean_key) {

Callers

nothing calls this directly

Calls 5

GetLockOptionMethod · 0.80
OnNrKeyMethod · 0.80
OnNrCleanKeyMethod · 0.80
GetNodeMethod · 0.45
GetTopicIDMethod · 0.45

Tested by

no test coverage detected