Remove paxos decision making.
This commit is contained in:
@@ -1,26 +0,0 @@
|
|||||||
from proposer import Proposer
|
|
||||||
from paxosmessenger import Messenger
|
|
||||||
|
|
||||||
class Acceptor():
|
|
||||||
highest_proposal = None
|
|
||||||
highest_promise = None
|
|
||||||
messenger = None
|
|
||||||
|
|
||||||
def __init__(self, messenger: Messenger):
|
|
||||||
self.messenger = messenger
|
|
||||||
|
|
||||||
def on_message(self, client, userdata, message):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def prepare(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def accept_request(self, fromt_uid, proposal_id, value):
|
|
||||||
'''
|
|
||||||
Called when an accept message is received from a proposer
|
|
||||||
'''
|
|
||||||
if proposal_id >= self.highest_promise:
|
|
||||||
self.highest_promise = proposal_id
|
|
||||||
self.accepted_id = proposal_id
|
|
||||||
self.accepted_value = value
|
|
||||||
self.messenger.send_accepted(proposal_id, self.accepted_value)
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
class Learner():
|
|
||||||
pass
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
from DecisionSystem.PaxosDecision.paxosmessenger import Messenger
|
|
||||||
from
|
|
||||||
|
|
||||||
class MqttMessenger(Messenger):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
|
|
||||||
|
|
||||||
def send_prepare(self, proposal_id):
|
|
||||||
'''
|
|
||||||
Broadcasts a Prepare message to all Acceptors
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def send_promise(self, proposer_id, proposal_id, previous_proposal):
|
|
||||||
'''
|
|
||||||
Sends a Promise message to the specified Proposer
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
|
|
||||||
def send_accept(self, proposal):
|
|
||||||
'''
|
|
||||||
Broadcasts an Accept message to all Acceptors
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
|
|
||||||
def send_accepted(self, proposal):
|
|
||||||
'''
|
|
||||||
Broadcasts an Accepted message to all Learners
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
|
|
||||||
def on_resolution(self, proposal_id, value):
|
|
||||||
'''
|
|
||||||
Called when a resolution is reached
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
'''
|
|
||||||
@author Michael Pivato
|
|
||||||
|
|
||||||
Much thanks to Tom Cocagne by providing basic paxos code
|
|
||||||
which was the basis of this module and algorithm.
|
|
||||||
Check out the original at: https://github.com/cocagne/paxos/blob/master/paxos/essential.py
|
|
||||||
'''
|
|
||||||
|
|
||||||
from learner import Learner
|
|
||||||
from acceptor import Acceptor
|
|
||||||
from proposer import Proposer
|
|
||||||
|
|
||||||
class PaxosInstance():
|
|
||||||
pass
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
from proposal import Proposal
|
|
||||||
|
|
||||||
class Messenger():
|
|
||||||
def send_prepare(self, proposal_id):
|
|
||||||
'''
|
|
||||||
Broadcasts a Prepare message to all Acceptors
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
|
|
||||||
def send_promise(self, proposer_id, proposal_id, previous_proposal):
|
|
||||||
'''
|
|
||||||
Sends a Promise message to the specified Proposer
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
|
|
||||||
def send_accept(self, proposal):
|
|
||||||
'''
|
|
||||||
Broadcasts an Accept message to all Acceptors
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
|
|
||||||
def send_accepted(self, proposal):
|
|
||||||
'''
|
|
||||||
Broadcasts an Accepted message to all Learners
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
|
|
||||||
def on_resolution(self, proposal_id, value):
|
|
||||||
'''
|
|
||||||
Called when a resolution is reached
|
|
||||||
'''
|
|
||||||
|
|
||||||
NotImplementedError
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
from Messaging.messaginginterface import Message
|
|
||||||
import umsgpack
|
|
||||||
|
|
||||||
# Uses MessagePack for message transfer.
|
|
||||||
|
|
||||||
class Proposal(Message):
|
|
||||||
ballot_number = None
|
|
||||||
vote = None
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def serialise(self) -> str:
|
|
||||||
return umsgpack.packb({"ballot": self.ballot_number, "vote": self.vote})
|
|
||||||
|
|
||||||
def deserialise(self, binary: bytearray):
|
|
||||||
'''
|
|
||||||
Deserialises a given proposal message into a proposal object.
|
|
||||||
'''
|
|
||||||
obj = umsgpack.unpackb(binary)
|
|
||||||
old_ballot = self.ballot_number
|
|
||||||
old_vote = self.vote
|
|
||||||
try:
|
|
||||||
self.ballot_number = obj['ballot']
|
|
||||||
self.vote = obj['vote']
|
|
||||||
except:
|
|
||||||
# Reset the values in case they have been changed.
|
|
||||||
self.ballot_number = old_ballot
|
|
||||||
self.vote = old_vote
|
|
||||||
print("Error: binary object is not a proposal")
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
class Proposer():
|
|
||||||
def propose(self):
|
|
||||||
pass
|
|
||||||
Reference in New Issue
Block a user