Package com.bank.trading.data
Class UDPMulticast
java.lang.Object
com.bank.trading.data.UDPMulticast
- All Implemented Interfaces:
Runnable
This class is responsible for the UDP multicast.
The UDP multicast is used to stream data to all parts of the system.
This is run as a thread on the Lamport service.
-
Constructor Summary
ConstructorsConstructorDescriptionUDPMulticast(List<InetSocketAddress> subscribers, LinkedBlockingQueue<Event> queue) Constructor to initialize the UDP multicast with a list of subscribers. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSubscriber(InetSocketAddress subscriber) Add a new subscriber to the list of subscribers.voidremoveSubscriber(InetSocketAddress subscriber) Remove a subscriber from the list of subscribers.voidrun()This method is responsible for running the UDP multicast service.voidshutdown()
-
Constructor Details
-
UDPMulticast
Constructor to initialize the UDP multicast with a list of subscribers.- Parameters:
subscribers- The list of subscribers to send the data to.queue- The queue to get the data from the Lamport Clock.
-
-
Method Details
-
addSubscriber
Add a new subscriber to the list of subscribers.- Parameters:
subscriber- The address of the new subscriber.
-
removeSubscriber
Remove a subscriber from the list of subscribers.- Parameters:
subscriber- The address of the subscriber to be removed.
-
run
public void run()This method is responsible for running the UDP multicast service. It continuously polls the queue for new events and sends them to all subscribers. -
shutdown
public void shutdown()
-