Class LamportClock

java.lang.Object
com.bank.trading.data.LamportClock
All Implemented Interfaces:
Runnable

public class LamportClock extends Object implements Runnable
Lamport clock service to keep track of the logical time of the system. All events that take place on any component of the HFTS are streamed to the LCS which timestamps them with a long starting from 1. The LCS immediately writes it to an in memory log file and adds to queue which will be used by the UDP multicast and Replay services which run on this server as well as the webInterface. The LCS is responsible for sending the most recent log data to the BackupData This service is run as a cluster with one active leader, the others on standby in case of failure. Uses heartbeats to check if the leader is alive.
  • Constructor Details

    • LamportClock

      public LamportClock(File logfile, InetSocketAddress address, Map<String,InetSocketAddress> subscribers)
      Constructor to initialize the Lamport clock service.
      Parameters:
      logfile - the file to write the log data.
      address - the address of this service.
      subscribers - the list of subscribers to this service and their names.
  • Method Details

    • run

      public void run()
      This method is responsible for running the Lamport clock service. This also starts the UDP multicast and Replay services.
      Specified by:
      run in interface Runnable
    • updateSubscriber

      public void updateSubscriber(String name, InetSocketAddress subscriber)
      add or update a subscriber to the Lamport clock service.
      Parameters:
      name - the name of the subscriber.
      subscriber - the address of the subscriber to add.
    • removeSubscriber

      public void removeSubscriber(InetSocketAddress subscriber)
      remove subscriber from the Lamport clock service.
      Parameters:
      subscriber - the address of the subscriber to remove.
    • getServiceAddress

      public InetSocketAddress getServiceAddress(String serviceName)
      Used to get the address of a service.
      Parameters:
      serviceName -
      Returns:
      the address of the service.
    • getCurrentAlgExecutable

      public byte[] getCurrentAlgExecutable()
      Get the alg executable that the system is currently using.
      Returns:
      the alg executable.
    • getCurrentControlsExecutable

      public byte[] getCurrentControlsExecutable()
      Get the controls executable that the system is currently using.
      Returns:
      the controls executable.