Package com.bank.trading.data
Class LamportClock
java.lang.Object
com.bank.trading.data.LamportClock
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionLamportClock(File logfile, InetSocketAddress address, Map<String, InetSocketAddress> subscribers) Constructor to initialize the Lamport clock service. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Get the alg executable that the system is currently using.byte[]Get the controls executable that the system is currently using.getServiceAddress(String serviceName) Used to get the address of a service.voidremoveSubscriber(InetSocketAddress subscriber) remove subscriber from the Lamport clock service.voidrun()This method is responsible for running the Lamport clock service.voidupdateSubscriber(String name, InetSocketAddress subscriber) add or update a subscriber to the Lamport clock service.
-
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. -
updateSubscriber
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
remove subscriber from the Lamport clock service.- Parameters:
subscriber- the address of the subscriber to remove.
-
getServiceAddress
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.
-