| 661 | } |
| 662 | |
| 663 | int Instance :: ReceiveMsgForLearner(const PaxosMsg & oPaxosMsg) |
| 664 | { |
| 665 | if (oPaxosMsg.msgtype() == MsgType_PaxosLearner_AskforLearn) |
| 666 | { |
| 667 | m_oLearner.OnAskforLearn(oPaxosMsg); |
| 668 | } |
| 669 | else if (oPaxosMsg.msgtype() == MsgType_PaxosLearner_SendLearnValue) |
| 670 | { |
| 671 | m_oLearner.OnSendLearnValue(oPaxosMsg); |
| 672 | } |
| 673 | else if (oPaxosMsg.msgtype() == MsgType_PaxosLearner_ProposerSendSuccess) |
| 674 | { |
| 675 | m_oLearner.OnProposerSendSuccess(oPaxosMsg); |
| 676 | } |
| 677 | else if (oPaxosMsg.msgtype() == MsgType_PaxosLearner_SendNowInstanceID) |
| 678 | { |
| 679 | m_oLearner.OnSendNowInstanceID(oPaxosMsg); |
| 680 | } |
| 681 | else if (oPaxosMsg.msgtype() == MsgType_PaxosLearner_ComfirmAskforLearn) |
| 682 | { |
| 683 | m_oLearner.OnComfirmAskForLearn(oPaxosMsg); |
| 684 | } |
| 685 | else if (oPaxosMsg.msgtype() == MsgType_PaxosLearner_SendLearnValue_Ack) |
| 686 | { |
| 687 | m_oLearner.OnSendLearnValue_Ack(oPaxosMsg); |
| 688 | } |
| 689 | else if (oPaxosMsg.msgtype() == MsgType_PaxosLearner_AskforCheckpoint) |
| 690 | { |
| 691 | m_oLearner.OnAskforCheckpoint(oPaxosMsg); |
| 692 | } |
| 693 | |
| 694 | if (m_oLearner.IsLearned()) |
| 695 | { |
| 696 | BP->GetInstanceBP()->OnInstanceLearned(); |
| 697 | |
| 698 | SMCtx * poSMCtx = nullptr; |
| 699 | bool bIsMyCommit = m_oCommitCtx.IsMyCommit(m_oLearner.GetInstanceID(), m_oLearner.GetLearnValue(), poSMCtx); |
| 700 | |
| 701 | if (!bIsMyCommit) |
| 702 | { |
| 703 | BP->GetInstanceBP()->OnInstanceLearnedNotMyCommit(); |
| 704 | PLGDebug("this value is not my commit"); |
| 705 | } |
| 706 | else |
| 707 | { |
| 708 | int iUseTimeMs = m_oTimeStat.Point(); |
| 709 | BP->GetInstanceBP()->OnInstanceLearnedIsMyCommit(iUseTimeMs); |
| 710 | PLGHead("My commit ok, usetime %dms", iUseTimeMs); |
| 711 | } |
| 712 | |
| 713 | if (!SMExecute(m_oLearner.GetInstanceID(), m_oLearner.GetLearnValue(), bIsMyCommit, poSMCtx)) |
| 714 | { |
| 715 | BP->GetInstanceBP()->OnInstanceLearnedSMExecuteFail(); |
| 716 | |
| 717 | PLGErr("SMExecute fail, instanceid %lu, not increase instanceid", m_oLearner.GetInstanceID()); |
| 718 | m_oCommitCtx.SetResult(PaxosTryCommitRet_ExecuteFail, |
| 719 | m_oLearner.GetInstanceID(), m_oLearner.GetLearnValue()); |
| 720 |
nothing calls this directly
no test coverage detected