next up previous contents
Next: ServerMeasure Up: Server Classes Previous: SynchronisedObject   Contents

UserDatabase

This class encapsulates the user information and contact list databases. Because this module contains a great deal of stored state, to aid in the debugging of this module, every operation is logged to a separate log file.

Originally this log file was also to be used to synchronise the user databases when a server connected to the network. However without a global time, comparing log files from two different hosts is meaningless. Sending the entire database is inefficient if only a few records have changed, so the solution adopted was to have the server joining the network send a complete list of (userid, timestamp) tuples to the other server which then parses its database and returns all the records that have a later timestamp.

One implication of this system was that each time a server received a connection from another server, it was parsing its entire database in order to compare the timestamp for each user with the one it received. This process was made much more efficient by changing the database file format to:

userid1 eventcount <UserInfo><UserID>userid1</UserID>...</UserInfo>\n
userid2 eventcount <UserInfo><UserID>userid2</UserID>...</UserInfo>\n
This format allows the (userid, timestamp) tuple to be extracted without parsing the XML, and is therefore much quicker when processing a large number of records.


next up previous contents
Next: ServerMeasure Up: Server Classes Previous: SynchronisedObject   Contents
Nathan Dimmock 2001-06-20