Cosmo 0.6 Morse Code
See
CosmoMorseCode for the full protocol specification.
Code Design
- MorseCodeServlet
- handles network protocol, calls sync API methods on MorseCodeController
- MorseCodeController
- interface that provides sync API to fulfill fundamental operations - publish, update, subscribe, synchronize, delete
- StandardMorseCodeController
- implements MorseCodeController in terms of the Cosmo service and security APIs
- ItemState and ItemStateSet
- model the item states sent to and from the server; an item state is represented as one or more EIM records
- SyncToken
- model the sync token, which is the pair (timestamp in milliseconds , hash of aggregate collection state), serialized over the wire as
<timestamp>-<hash>
Sync Algorithm
On a sync request, StandardMorseCodeController does the following:
- Check to see if the sync token is still valid for the collection by comparing the hash in the token to the hash of the collection's current state - if they are equal, then the token is still valid and no data is returned, but if not, the token is invalid and changes need to be sent back
- For the collection itself, and for each member item (excluding subcollections), check to see if the item has changed since the sync token was generated by comparing the timstamp in the token to the last modified timestamp on the item - if the item has changed, its current state is returned
Possible Performance Improvements
- service method to calculate aggregate collection hash and implement with SQL
- service method to retrieve all child items that have changed since some timestamp and implement with SQL
- binary protocol