DataServer of AIOTrade

本文详细探讨了数据服务器的比较方法、核心合同、数据结构、事件发布机制及核心组件的功能,包括心跳事件、历史加载事件、刷新与加载历史后的操作流程。同时介绍了数据服务器如何订阅与监听事件,以及在不同场景下的具体行为。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 [b]compose[/b] the ticker(new ticker copied from the tickerSnapshot) in the subscribedContracts's storage [b]to Tser, that is to say the 1m quoteSer[/b]

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 [b]itself[/b].
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). [b]TickerServer has not define the action when it received the Opened and Closed event.[/b]
TickerServer also implements the traits ChangeObserver, so it will observe the tickerSnapshot. [b]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.[/b] The tickerSnapshot is the latest tickerSnapshot, which means that it is always changing.
[I]Question: how to track the new tickerSnapshot, observe it and unobserve it?[/I]

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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值