| 594 | } |
| 595 | |
| 596 | int Instance :: ReceiveMsgForAcceptor(const PaxosMsg & oPaxosMsg, const bool bIsRetry) |
| 597 | { |
| 598 | if (m_poConfig->IsIMFollower()) |
| 599 | { |
| 600 | PLGErr("I'm follower, skip this message"); |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | ////////////////////////////////////////////////////////////// |
| 605 | |
| 606 | if (oPaxosMsg.instanceid() != m_oAcceptor.GetInstanceID()) |
| 607 | { |
| 608 | BP->GetInstanceBP()->OnReceivePaxosAcceptorMsgInotsame(); |
| 609 | } |
| 610 | |
| 611 | if (oPaxosMsg.instanceid() == m_oAcceptor.GetInstanceID() + 1) |
| 612 | { |
| 613 | //skip success message |
| 614 | PaxosMsg oNewPaxosMsg = oPaxosMsg; |
| 615 | oNewPaxosMsg.set_instanceid(m_oAcceptor.GetInstanceID()); |
| 616 | oNewPaxosMsg.set_msgtype(MsgType_PaxosLearner_ProposerSendSuccess); |
| 617 | |
| 618 | ReceiveMsgForLearner(oNewPaxosMsg); |
| 619 | } |
| 620 | |
| 621 | if (oPaxosMsg.instanceid() == m_oAcceptor.GetInstanceID()) |
| 622 | { |
| 623 | if (oPaxosMsg.msgtype() == MsgType_PaxosPrepare) |
| 624 | { |
| 625 | return m_oAcceptor.OnPrepare(oPaxosMsg); |
| 626 | } |
| 627 | else if (oPaxosMsg.msgtype() == MsgType_PaxosAccept) |
| 628 | { |
| 629 | m_oAcceptor.OnAccept(oPaxosMsg); |
| 630 | } |
| 631 | } |
| 632 | else if ((!bIsRetry) && (oPaxosMsg.instanceid() > m_oAcceptor.GetInstanceID())) |
| 633 | { |
| 634 | //retry msg can't retry again. |
| 635 | if (oPaxosMsg.instanceid() >= m_oLearner.GetSeenLatestInstanceID()) |
| 636 | { |
| 637 | if (oPaxosMsg.instanceid() < m_oAcceptor.GetInstanceID() + RETRY_QUEUE_MAX_LEN) |
| 638 | { |
| 639 | //need retry msg precondition |
| 640 | //1. prepare or accept msg |
| 641 | //2. msg.instanceid > nowinstanceid. |
| 642 | // (if < nowinstanceid, this msg is expire) |
| 643 | //3. msg.instanceid >= seen latestinstanceid. |
| 644 | // (if < seen latestinstanceid, proposer don't need reply with this instanceid anymore.) |
| 645 | //4. msg.instanceid close to nowinstanceid. |
| 646 | m_oIOLoop.AddRetryPaxosMsg(oPaxosMsg); |
| 647 | |
| 648 | BP->GetInstanceBP()->OnReceivePaxosAcceptorMsgAddRetry(); |
| 649 | |
| 650 | //PLGErr("InstanceID not same, get in to retry logic"); |
| 651 | } |
| 652 | else |
| 653 | { |
nothing calls this directly
no test coverage detected