Issue
I want to implement TransparencyChecker Interface which would verify that from any exchange in the network all trading information from other exchanges is available.
Q: How would TransparencyChecker Inferface implemented ?
Problem Background
Stock exchanges decided to share trading information with each other. If one exchange wants to share information with another exchange, it
installs an outgoing network link to dump all transactions. The network links are one-way and the exchange also shares transactions, which have
been received from incoming network links.
Code
interface Exchange {
/**
* Returns list of names of exchanges which receive all trading information
* from this exchange.
* @return list of exchanges
*/
Set<String> getOutgoingConnections ();
/**
* Name of the exchange
* @return name
*/
String getName ();
}
interface TransparencyChecker {
/**
* Checks the transparency of the network. The network is the
* collection of exchanges and each of them has a unique name.
* @param exchanges list of exchanges in the network
* @return true if all trading information is available for every exchange
*/
boolean isTransparent (Set<Exchange> exchanges);
}
Problem: Verify that all trading information from other exchanges is available
There are several problems here, I’m going to focus on one: “All Information is Available”, but briefly, mention two other problems
And the brings me to the primary question: what does “Available” mean? Let’s just focus on ExchangeA and ExchangeB (if A and B can agree then what ever rules we use we can extend to A->C, A->D, B->C etc.) We could consider several different meanings for A deciding whether B is available: Can A ping B at a network level? Has A received a recent (how recent?) message from B, Can A understand the message it received from B? Perhaps B needs to send several messages to describe its state, did we receive them all? Are the messages sensible?
I suggest that A can determine B’s availability by receiving messages from B at some agreed interval. These messages may be as simple as
or more complex
Now A has to then interpret these “Hearbeats”. Suppose messages are due every 5 minutes and one hasn’t arrived for 8 minutes – is that bad? Suppose one message misses, but all the rest are delivered? Suppose some are delivered out of order? You need to define your rules. You need to assume that networks do have the occasional glitch, small delays will happen.
Following from this there are various questions such as how does B know to tell A its available. Perhaps a Pub/Sub approach is appropriate? Or should there be some central registry that all exchnages talk to, and each exchasge just asks the registry “is everybody up?”