From 5b24c98ad781747533651c271f77994c1d37f6e9 Mon Sep 17 00:00:00 2001 From: Michael Pivato Date: Thu, 7 Feb 2019 07:00:57 +1030 Subject: [PATCH] Remove paxos decision making. --- DecisionSystem/PaxosDecision/acceptor.py | 26 ------------ DecisionSystem/PaxosDecision/learner.py | 2 - DecisionSystem/PaxosDecision/mqttmessenger.py | 42 ------------------- .../PaxosDecision/paxos_instance.py | 14 ------- .../PaxosDecision/paxosmessenger.py | 37 ---------------- DecisionSystem/PaxosDecision/proposal.py | 32 -------------- DecisionSystem/PaxosDecision/proposer.py | 3 -- 7 files changed, 156 deletions(-) delete mode 100644 DecisionSystem/PaxosDecision/acceptor.py delete mode 100644 DecisionSystem/PaxosDecision/learner.py delete mode 100644 DecisionSystem/PaxosDecision/mqttmessenger.py delete mode 100644 DecisionSystem/PaxosDecision/paxos_instance.py delete mode 100644 DecisionSystem/PaxosDecision/paxosmessenger.py delete mode 100644 DecisionSystem/PaxosDecision/proposal.py delete mode 100644 DecisionSystem/PaxosDecision/proposer.py diff --git a/DecisionSystem/PaxosDecision/acceptor.py b/DecisionSystem/PaxosDecision/acceptor.py deleted file mode 100644 index a9cbe0e..0000000 --- a/DecisionSystem/PaxosDecision/acceptor.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/DecisionSystem/PaxosDecision/learner.py b/DecisionSystem/PaxosDecision/learner.py deleted file mode 100644 index 37955b4..0000000 --- a/DecisionSystem/PaxosDecision/learner.py +++ /dev/null @@ -1,2 +0,0 @@ -class Learner(): - pass \ No newline at end of file diff --git a/DecisionSystem/PaxosDecision/mqttmessenger.py b/DecisionSystem/PaxosDecision/mqttmessenger.py deleted file mode 100644 index fc47ba2..0000000 --- a/DecisionSystem/PaxosDecision/mqttmessenger.py +++ /dev/null @@ -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 \ No newline at end of file diff --git a/DecisionSystem/PaxosDecision/paxos_instance.py b/DecisionSystem/PaxosDecision/paxos_instance.py deleted file mode 100644 index 41d8609..0000000 --- a/DecisionSystem/PaxosDecision/paxos_instance.py +++ /dev/null @@ -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 \ No newline at end of file diff --git a/DecisionSystem/PaxosDecision/paxosmessenger.py b/DecisionSystem/PaxosDecision/paxosmessenger.py deleted file mode 100644 index 47e38a6..0000000 --- a/DecisionSystem/PaxosDecision/paxosmessenger.py +++ /dev/null @@ -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 \ No newline at end of file diff --git a/DecisionSystem/PaxosDecision/proposal.py b/DecisionSystem/PaxosDecision/proposal.py deleted file mode 100644 index ef1424a..0000000 --- a/DecisionSystem/PaxosDecision/proposal.py +++ /dev/null @@ -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") - - \ No newline at end of file diff --git a/DecisionSystem/PaxosDecision/proposer.py b/DecisionSystem/PaxosDecision/proposer.py deleted file mode 100644 index 2bb19b8..0000000 --- a/DecisionSystem/PaxosDecision/proposer.py +++ /dev/null @@ -1,3 +0,0 @@ -class Proposer(): - def propose(self): - pass \ No newline at end of file