6 – Overlay Layer
3.3.2 Key Overlay Functions
3.3.2 Key Overlay Functions
Following are list of functions that you may need to modify based on how you want to implement your overlay.
- Constructor – Can be use to set message to NULL. Better not to skip defining the constructor.
- Destructor – Clear/delete messages in destructor using cancelAndDelete(). Resent OverSim versions seem to be motivating to use a destructor so better not to skip.
- void initializeOverlay(int stage) – Can be used to initialize an overlay node, read parameter values, set key, set statistic collectors, start timers, etc.
- stage - set to either MIN_STAGE_APP (indicate that module is being created) or MAX_STAGE_APP (indicate that all modules were created). We typically use MIN_STAGE_APP to initialize application functions & variables.
- void finishOverlay() – Called when module is being terminated. Can be used to summarize statistics. New OverSim versions seem to be motivating developers to delete messages in the destructor.
- void joinOverlay() – Define what to do when a new node is added to system. Can be used to establish connections with other overlay nodes, e.g., successor/predecessor & identify fingers in Chord. Also indicate to the simulator that overlay is now ready.
- NodeVector* findNode(const OverlayKey& key, int numRedundantNodes, int numSiblings) – Is called by message forwarding function to determine potential next hops, e.g., finger node selection in Chord can be implemented here. If asking node is a sibling (i.e., root) for the key, it will reply with list of siblings ordered according their closeness to the given key.
- key – key to search for
- numRedundantNodes – Maximum number of next hop nodes to return
- numSibling – Number of siblings (potential nodes that could store the key) to return
- bool isSiblingFor(const NodeHandle& node, const OverlayKey& key, int numSiblings, bool* err) – Am I the root, i.e.., node responsible for storing the given key?
- node – Nodehandler of the node method is suppose to be called
- key – key to search
- numSibling – Number of siblings (potential nodes that could store key) being requested
- err – Return false if the range could not be determined
- int getMaxNumSiblings() – Get maximum number of siblings (nodes close to a key) that are maintained by this overlay. Used by isSiblingFor() method.