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

Method CheckNewValue

src/algorithm/instance.cpp:290–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288////////////////////////////////////////////////
289
290void Instance :: CheckNewValue()
291{
292 if (!m_oCommitCtx.IsNewCommit())
293 {
294 return;
295 }
296
297 if (!m_oLearner.IsIMLatest())
298 {
299 return;
300 }
301
302 if (m_poConfig->IsIMFollower())
303 {
304 PLGErr("I'm follower, skip this new value");
305 m_oCommitCtx.SetResultOnlyRet(PaxosTryCommitRet_Follower_Cannot_Commit);
306 return;
307 }
308
309 if (!m_poConfig->CheckConfig())
310 {
311 PLGErr("I'm not in membership, skip this new value");
312 m_oCommitCtx.SetResultOnlyRet(PaxosTryCommitRet_Im_Not_In_Membership);
313 return;
314 }
315
316 if ((int)m_oCommitCtx.GetCommitValue().size() > MAX_VALUE_SIZE)
317 {
318 PLGErr("value size %zu to large, skip this new value",
319 m_oCommitCtx.GetCommitValue().size());
320 m_oCommitCtx.SetResultOnlyRet(PaxosTryCommitRet_Value_Size_TooLarge);
321 return;
322 }
323
324 m_oCommitCtx.StartCommit(m_oProposer.GetInstanceID());
325
326 if (m_oCommitCtx.GetTimeoutMs() != -1)
327 {
328 m_oIOLoop.AddTimer(m_oCommitCtx.GetTimeoutMs(), Timer_Instance_Commit_Timeout, m_iCommitTimerID);
329 }
330
331 m_oTimeStat.Point();
332
333 if (m_poConfig->GetIsUseMembership()
334 && (m_oProposer.GetInstanceID() == 0 || m_poConfig->GetGid() == 0))
335 {
336 //Init system variables.
337 PLGHead("Need to init system variables, Now.InstanceID %lu Now.Gid %lu",
338 m_oProposer.GetInstanceID(), m_poConfig->GetGid());
339
340 uint64_t llGid = OtherUtils::GenGid(m_poConfig->GetMyNodeID());
341 string sInitSVOpValue;
342 int ret = m_poConfig->GetSystemVSM()->CreateGid_OPValue(llGid, sInitSVOpValue);
343 assert(ret == 0);
344
345 m_oSMFac.PackPaxosValue(sInitSVOpValue, m_poConfig->GetSystemVSM()->SMID());
346 m_oProposer.NewValue(sInitSVOpValue);
347 }

Callers

nothing calls this directly

Calls 3

sizeMethod · 0.80
NewValueMethod · 0.80
SMIDMethod · 0.45

Tested by

no test coverage detected