Author: Not specified Language: text
Description: Not specified Timestamp: 2017-09-22 21:08:04 +0000
View raw paste Reply
  1.  
  2. class Olympus :
  3.         # Setup class variables
  4.         configuration_size = 100 # Number of replicas in a configuration
  5.         pending_replicas = Replica_List # List of pending replicas
  6.         configuration = generate_new_configuration() # List of replicas in current config
  7.         olympus_keys = (public_key, private_key) # Public key private key tuple
  8.         message_handler = OlympusMessageHandler(olympus_keys)
  9.         history = []
  10.         history_candidate = []
  11.         quorum_size = 20 #
  12.         init_hist(configuration)
  13.  
  14.         # Reconfiguration
  15.         def reconfigure() :
  16.                 # Send wedge
  17.                 for replica in configuration :
  18.                         message_handler.send(receiver = replica, message = wedge_message('Wedge'))
  19.                 # Await response from quorum
  20.                 q_history = []
  21.                 for q in Quorum :
  22.                         q_history.add(await receive_wedged())
  23.                 # Rebuild longest history
  24.                 maximal_history = select_maximal_history(q_history)
  25.                 # Send catch up message and wait for replicas to catch up
  26.                 catchup_replicas = []
  27.                 for q in Quorum :
  28.                         if len(q.history) < len(maximal_history) :
  29.                                 message_handler.send(receiver = q, message = catch_up_message(maximal_history - q.history))
  30.                                 catchup_replicas.add(q)
  31.  
  32.                 # Wait for replicas to catch up
  33.                 caughtup_running_state_hash = None
  34.                 for q in catchup_replicas :
  35.                         # We assume all replicas in this set have the same running state at this point and return the same hash
  36.                         caughtup_running_state_hash = await caught_up()
  37.  
  38.                 # Compute the hash of running state from replicas who caught up
  39.                 quorum_running_state = None
  40.                 while quorum_running_state == None :
  41.                         # If matches hash (matches the one who caught up) that's the correct running state
  42.                         # Else ask another replica
  43.                         q = Quorum[random] # For random q in Quorum
  44.                         running_state = message_handler.send(receiver = q, message = get_running_state_message())
  45.                         if hash(running_state) == caughtup_running_state_hash :
  46.                                 quorum_running_state = running_state
  47.                 # Allocate new configuration
  48.                 new_config = generate_new_configuration(new_replicas)
  49.                 # init_hist
  50.                 for replica in new_config :
  51.                         # Send the quorum running state achieved above in the init hist message to new replicas
  52.                         replica.init_hist(quorum_running_state, history)
  53.                
  54.         # Receive handler for wedged response
  55.         def receive_wedged(message) :
  56.                 # Form the maximal history set
  57.                 for order_statement in message :
  58.                         if order_statement.slot in history :
  59.                                 if order_statement.operation != history[slot] : # We had another operation in this slot, this node is faulty so we ignore all of its history
  60.                                         return
  61.                         else :
  62.                                 if order_statement not in history :
  63.                                         ...
  64.         # Handle message time out
  65.         def message_timeout(message) :
  66.                 # Connection from/to olympus should be reliable, but if this case happened try to make the replica immutable
  67.                 # If message timed out to a node, try to make it immutable
  68.                 message_handler.send(receiver = message.receiver, message = make_immutable_message())
  69.  
  70.         # On reconfiguration message received
  71.         def receive_reconfiguration_request(message) :
  72.                 # We assume the client/replica had a valid reason to request a reconfiguration
  73.                 if message.sender in configuration or message.sender is Client : # If node is in current configuration or is client
  74.                         reconfigure()
  75.  
  76.         # Sends current configuration
  77.         def get_current_configuration(target) :
  78.                 message_handler.send(target, configuration)
  79.        
  80.         # Generates new configuration (initial setup for new nodes)
  81.         def generate_new_configuration() :
  82.                 # Allocate new nodes & their keys
  83.                 # Select replicas from pending list and remove them from pending list
  84.                 new_replicas = pending_replicas[0:100]
  85.                 pending_replicas.remove(100)
  86.                 for replica in new_replicas :
  87.                         message_handler.send(receiver = replica, message = set_keys_message(public_key, private_key))
  88.                         new_config.add(replica)
  89.                 return new_config
  90.  
  91.         # Initialize history of new nodes and their running state
  92.         def init_hist(configuration) :

This paste is large and only partially shown.
View full paste

View raw paste Reply