MCPcopy Create free account
hub / github.com/Tencent/phxpaxos / OnAskforLearn

Method OnAskforLearn

src/algorithm/learner.cpp:262–310  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

260}
261
262void Learner :: OnAskforLearn(const PaxosMsg & oPaxosMsg)
263{
264 BP->GetLearnerBP()->OnAskforLearn();
265
266 PLGHead("START Msg.InstanceID %lu Now.InstanceID %lu Msg.from_nodeid %lu MinChosenInstanceID %lu",
267 oPaxosMsg.instanceid(), GetInstanceID(), oPaxosMsg.nodeid(),
268 m_poCheckpointMgr->GetMinChosenInstanceID());
269
270 SetSeenInstanceID(oPaxosMsg.instanceid(), oPaxosMsg.nodeid());
271
272 if (oPaxosMsg.proposalnodeid() == m_poConfig->GetMyNodeID())
273 {
274 //Found a node follow me.
275 PLImp("Found a node %lu follow me.", oPaxosMsg.nodeid());
276 m_poConfig->AddFollowerNode(oPaxosMsg.nodeid());
277 }
278
279 if (oPaxosMsg.instanceid() >= GetInstanceID())
280 {
281 return;
282 }
283
284 if (oPaxosMsg.instanceid() >= m_poCheckpointMgr->GetMinChosenInstanceID())
285 {
286 if (!m_oLearnerSender.Prepare(oPaxosMsg.instanceid(), oPaxosMsg.nodeid()))
287 {
288 BP->GetLearnerBP()->OnAskforLearnGetLockFail();
289
290 PLGErr("LearnerSender working for others.");
291
292 if (oPaxosMsg.instanceid() == (GetInstanceID() - 1))
293 {
294 PLGImp("InstanceID only difference one, just send this value to other.");
295 //send one value
296 AcceptorStateData oState;
297 int ret = m_oPaxosLog.ReadState(m_poConfig->GetMyGroupIdx(), oPaxosMsg.instanceid(), oState);
298 if (ret == 0)
299 {
300 BallotNumber oBallot(oState.acceptedid(), oState.acceptednodeid());
301 SendLearnValue(oPaxosMsg.nodeid(), oPaxosMsg.instanceid(), oBallot, oState.acceptedvalue(), 0, false);
302 }
303 }
304
305 return;
306 }
307 }
308
309 SendNowInstanceID(oPaxosMsg.instanceid(), oPaxosMsg.nodeid());
310}
311
312void Learner :: SendNowInstanceID(const uint64_t llInstanceID, const nodeid_t iSendNodeID)
313{

Callers

nothing calls this directly

Calls 3

OnAskforLearnMethod · 0.80
PrepareMethod · 0.80

Tested by

no test coverage detected