next up previous contents
Next: Future Improvements Up: The Basic Services Previous: Future Improvements

The HsPersistentObjectService

  Once we have created HDM objects it is vital that we be able to save them persistently to disk and reload them between Haystack sessions. To this end, Haystack provides a HsPersistentObjectService class.

HsPersistentObjectService is built using a very simple model. Within the service a Hashtable is maintained mapping HaystackIDs to Straws. When a new object is created, the method register(...) is invoked by the HsObjectCreatorService. The new Straw is placed in the Hashtable. To save the Straw to disk HsPersistentObjectService makes use of a Java implementation of a standard DBM package developed by the WWW Consortium for a Java based web server [44]. In Haystack we extend the DBM functionality to a handle the serialization of Java objects. HsPersistentObjectService will pass the (key,value) pair of (HaystackID, Straw) to the DBM package. The DBM will serialize the Straw (i.e. transform it into bytes), and save it to disk keyed on the HaystackID. Recall from the discussion of the StrawTies implementation that the Straws ``break'' apart from the HDM structure on serialization. This ensures that objects are saved and loaded independently (rather than in complex subgraphs).

If a service requests an object from the HsPersistentObjectService by means of the getObject(...) method, the HsPersistentObjectService will first check in its cache for the object. If the Straw exists in the hashtable it is immediately returned. Otherwise, an attempt is made to retrieve the object from the DBM database. If that fails, an exception is thrown (ObjectNotFoundException). If the object is loaded from disk and reconstructed, it is placed in the cache and returned to the requesting service.

Because Straws are ``disassembled'' for saving, it is necessary to reconstruct all the pointers once the object is loaded from disk. To do this, Straws contain a boolean variable called loaded. If loaded is set to false, the Straw will repeatedly call the HsPersistentObjectService to obtain all the pointers to its outgoing edges. Recall, this is achievable beacuse Straws always retain the HaystackIDs for outgoing edges.




next up previous contents
Next: Future Improvements Up: The Basic Services Previous: Future Improvements

Copyright 1998, Eytan Adar (eytan@alum.mit.edu)