void ReplicatedLog::OnRequest(PaxosMessage& imsg) { Log_Trace(); Buffer value; PaxosMessage omsg; if (imsg.paxosID < GetPaxosID()) { // the node is lagging and needs to catch-up context->GetDatabase()->GetAcceptedValue(imsg.paxosID, value); if (value.GetLength() == 0) return; omsg.LearnValue(imsg.paxosID, MY_NODEID, 0, value); context->GetTransport()->SendMessage(imsg.nodeID, omsg); } else if (GetPaxosID() < imsg.paxosID) { // I am lagging and need to catch-up RequestChosen(imsg.nodeID); } }
void ReplicatedLog::Append(Buffer& value) { Log_Trace(); if (proposer.IsActive() || proposer.IsLearnSent()) return; context->OnStartProposing(); proposer.Propose(value); #ifdef RLOG_DEBUG_MESSAGES Log_Debug("Proposing for paxosID = %U", GetPaxosID()); #endif }
bool ReplicatedLog::OnRequestChosen(PaxosMessage& imsg) { Buffer value; PaxosMessage omsg; #ifdef RLOG_DEBUG_MESSAGES Log_Debug("ReplicatedLog::OnRequestChosen, imsg.paxosID = %U, mine = %U", imsg.paxosID, GetPaxosID()); #endif if (imsg.paxosID >= GetPaxosID()) return true; // the node is lagging and needs to catch-up if (context->AlwaysUseDatabaseCatchup() && imsg.paxosID < GetPaxosID()) { omsg.StartCatchup(paxosID, MY_NODEID); } else { context->GetDatabase()->GetAcceptedValue(imsg.paxosID, value); if (value.GetLength() > 0) { Log_Trace("Sending paxosID %d to node %d", imsg.paxosID, imsg.nodeID); omsg.LearnValue(imsg.paxosID, MY_NODEID, 0, value); } else { Log_Trace("Node requested a paxosID I no longer have"); omsg.StartCatchup(paxosID, MY_NODEID); } } context->GetTransport()->SendMessage(imsg.nodeID, omsg); return true; }
void ReplicatedLog::Continue() { if (context->IsLeaseKnown() && context->GetHighestPaxosID() > GetPaxosID()) RequestChosen(context->GetLeaseOwner()); }