`
guibin
  • 浏览: 363888 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

DataServer of AIOTrade

阅读更多
1. How to compare two DataServers?
If the Dataservers' displayNames are same and they have the same hashCode, then they are equal.

2. What the contract for this Dataserver?

3. What is the DataServer's core data structure?
There are three main data Map and a helper Map, the details are:
  a) contractToStorage: Map[C, ArrayList[V]], DataContract -> Storage
  b) subscribedContractToSer: Map[C, T], DataContract -> Tser
  c) serToChainSers: Map[Tser, List[Tser]], Tser -> ChainSers
The helper Map is:
  a) subscribedSymbolToContract: Map[String, DataContract]
It is used to quick search the contract, then to get the Storage or the Tser

All the method and logic are used to support these four Map.

4. What the event will the DataServer publish?
Totally two kinds of event,
the first one is HeartBeat(heartBeatInterval), it is published by a timer in the DataServer every `heartBeatInteval`. The default action when the DataServer received the HeartBeat is to loadFromSource(loadedTime) and postRefresh
loadFromSource will be overrided by the subclass.
The second kind of event is LoadHistory(afterTime). The default action when DataServer received the LoadHistory(afterTime) is also to loadFromSource(loadedTime) and postLoadHistory.

5. What does the postRefresh and postLoadHistory do?
Currently in the TickerServer, the postRefresh will firstly composeSer, then publish TSerEvent.Updated to the Tser. Tser also is a kind of publisher, TODO here.

6. What does the composeSer do?
composeSer will compose the ticker(new ticker copied from the tickerSnapshot) in the subscribedContracts's storage to Tser, that is to say the 1m quoteSer

7. What event  will the TickerServer observer?
TickerServer extends DataServer, that is to say Ticker is a Publisher which will publish the HeartBeat(heartBeatInterval) and LoadHistory(afterTime) event to itself.
TickerServer is a publisher and is also a Reactor, so it will listen to the Exchange.
Exchange will publish Opened(exchange: Exchange) and Closed(exchange: Exchange). TickerServer has not define the action when it received the Opened and Closed event.
TickerServer also implements the traits ChangeObserver, so it will observe the tickerSnapshot. When the tickerSnapshot notifies, the default action is TickerServer will create a new Ticker, copy the tickerSnapshot content to the new ticker, then save this new ticker into the storage(actually a ArrayList) of the DataServer. The tickerSnapshot is the latest tickerSnapshot, which means that it is always changing.
Question: how to track the new tickerSnapshot, observe it and unobserve it?

Ticker will subscribe a tickerContract, then it observe the tickerSnapshot <- Sec.lastData <- contract.symbol <- contract. 
And unsubscribe is vice verse. contract -> contract.symbol -> Sec -> sec.lastData.tickerSnapShot.






分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics