ZG  "1.00
 All Classes Namespaces Files Functions Variables Enumerator Friends Macros Pages
Public Member Functions | List of all members
ZGPeerSettings Class Reference

This immutable class holds various read-only settings that will be used to define the peer's behavior. More...

#include <ZGPeerSettings.h>

Public Member Functions

 ZGPeerSettings (const String &systemName, uint8 numDatabases, bool systemIsOnLocalhostOnly, uint16 peerType=PEER_TYPE_FULL_PEER)
 Constructor. More...
 
const String & GetSystemName () const
 Returns the ZG system's system name (as specified in our constructor) More...
 
uint8 GetNumDatabases () const
 Returns the number of databases that will be present in this ZG system (as specified by our constructor) More...
 
bool IsSystemOnLocalhostOnly () const
 Returns true iff this ZG system is meant to be contained entirely within a single host computer (as specified in our constructor) More...
 
const ConstMessageRef & GetPeerAttributes () const
 Returns a reference to this peer's peer-attributes Message (as specified earlier via SetPeerAttributes()). More...
 
uint16 GetPeerType () const
 Returns the PEER_TYPE_* value of this peer (currently only PEER_TYPE_FULL_PEER is supported) More...
 
uint32 GetHeartbeatsPerSecond () const
 Returns the heartbeats-per-second value for htis peer (currently defaults to 6) More...
 
uint32 GetMaxNumMissingHeartbeats () const
 Returns the max-missing-heartbeats-before-a-peer-is-declared-offline value for this peer (currently defaults to 4) More...
 
uint32 GetHeartbeatsBeforeFullyAttached () const
 Returns the num-heartbeats-before-peer-considers-itself-fully-attached value this peer (currently defaults to 4) More...
 
uint32 GetBeaconsPerSecond () const
 Returns the number-of-beacon-packets-to-send-per-second value for this peer (currently defaults to 4) More...
 
void SetPeerAttributes (const ConstMessageRef &peerAttributes)
 Set the peer attributes that should be associated with this peer. More...
 
void SetHeartbeatsPerSecond (uint32 hps)
 Set the number of times we should send a "heartbeat" multicast packet per second. More...
 
void SetHeartbeatsBeforeFullyAttached (uint32 hb)
 Sets the number of heartbeat-periods that must elapse after our startup, before we declare ourselves fully part of the peers group. More...
 
void SetMaxNumMissingHeartbeats (uint32 hb)
 Sets the number of heartbeat-periods that must go by without hearing any heartbeats from a source, before we will decide that that source has gone offline. More...
 
void SetBeaconsPerSecond (uint32 bps)
 Set the number of times we should send a "beacon" multicast packet per second, if we are the senior peer. More...
 
void SetMaximumUpdateLogSizeForDatabase (uint32 whichDB, uint64 maxNumBytes)
 Call this to set the maximum number of bytes of RAM the specified database should be allowed to use for its database-update-log records. More...
 
uint64 GetMaximumUpdateLogSizeForDatabase (uint32 whichDB) const
 Returns the maximum number of bytes of RAM we should be allowed to use for the update-log of the specified database. More...
 

Detailed Description

This immutable class holds various read-only settings that will be used to define the peer's behavior.

These settings are not allowed to change during the lifetime of the peer.

Definition at line 25 of file ZGPeerSettings.h.

Constructor & Destructor Documentation

ZGPeerSettings ( const String &  systemName,
uint8  numDatabases,
bool  systemIsOnLocalhostOnly,
uint16  peerType = PEER_TYPE_FULL_PEER 
)
inline

Constructor.

Parameters
systemNameName of the system this peer will participate in. All peers in a system by definition use the same system name.
numDatabasesThe number of replicated databases this system should maintain.
systemIsOnLocalhostOnlyIf true, we'll send/receive multicast packets on loopback interfaces only. If false, we'll use all interfaces.
peerTypeOne of the PEER_TYPE_* values. Defaults to PEER_TYPE_FULL_PEER, meaning that this peer is willing to handle both junior-peer and senior-peer duties, if necessary.

Definition at line 35 of file ZGPeerSettings.h.

Member Function Documentation

uint32 GetBeaconsPerSecond ( ) const
inline

Returns the number-of-beacon-packets-to-send-per-second value for this peer (currently defaults to 4)

Definition at line 76 of file ZGPeerSettings.h.

uint32 GetHeartbeatsBeforeFullyAttached ( ) const
inline

Returns the num-heartbeats-before-peer-considers-itself-fully-attached value this peer (currently defaults to 4)

Definition at line 73 of file ZGPeerSettings.h.

uint32 GetHeartbeatsPerSecond ( ) const
inline

Returns the heartbeats-per-second value for htis peer (currently defaults to 6)

Definition at line 67 of file ZGPeerSettings.h.

uint64 GetMaximumUpdateLogSizeForDatabase ( uint32  whichDB) const
inline

Returns the maximum number of bytes of RAM we should be allowed to use for the update-log of the specified database.

Parameters
whichDBThe database you want to retreive the RAM-usage limit for

Definition at line 126 of file ZGPeerSettings.h.

uint32 GetMaxNumMissingHeartbeats ( ) const
inline

Returns the max-missing-heartbeats-before-a-peer-is-declared-offline value for this peer (currently defaults to 4)

Definition at line 70 of file ZGPeerSettings.h.

uint8 GetNumDatabases ( ) const
inline

Returns the number of databases that will be present in this ZG system (as specified by our constructor)

Definition at line 53 of file ZGPeerSettings.h.

const ConstMessageRef& GetPeerAttributes ( ) const
inline

Returns a reference to this peer's peer-attributes Message (as specified earlier via SetPeerAttributes()).

May return a NULL reference if no peer-attributes were ever specified.

Definition at line 61 of file ZGPeerSettings.h.

uint16 GetPeerType ( ) const
inline

Returns the PEER_TYPE_* value of this peer (currently only PEER_TYPE_FULL_PEER is supported)

Definition at line 64 of file ZGPeerSettings.h.

const String& GetSystemName ( ) const
inline

Returns the ZG system's system name (as specified in our constructor)

Definition at line 50 of file ZGPeerSettings.h.

bool IsSystemOnLocalhostOnly ( ) const
inline

Returns true iff this ZG system is meant to be contained entirely within a single host computer (as specified in our constructor)

Definition at line 56 of file ZGPeerSettings.h.

void SetBeaconsPerSecond ( uint32  bps)
inline

Set the number of times we should send a "beacon" multicast packet per second, if we are the senior peer.

Beacon packets are used by the junior peers to verify that they haven't missed an update. They are sent only by the senior peer. Default value is 4 (i.e. one beacon packet every 250 milliseconds)

Parameters
bpsThe number of beacons per second to send (only if we are the senior peer).

Definition at line 113 of file ZGPeerSettings.h.

void SetHeartbeatsBeforeFullyAttached ( uint32  hb)
inline

Sets the number of heartbeat-periods that must elapse after our startup, before we declare ourselves fully part of the peers group.

During this initial period we simply listen to find out who else is currently out there and passively gather data about them, without trying to interfere with the operation of the existing system. Default value is 4 (i.e. we will wait for four heartbeat-intervals before trying to act as a full member of the system)

Parameters
hbThe number of heartbeat intervals to wait for during our startup phase.

Definition at line 99 of file ZGPeerSettings.h.

void SetHeartbeatsPerSecond ( uint32  hps)
inline

Set the number of times we should send a "heartbeat" multicast packet per second.

This value will also be used as the number of heartbeats we expect other peers in our group to send, so it is important that this value be the same on all peers in the sysetm Default value is 4 (i.e. one heartbeat every 250 milliseconds)

Parameters
hpsThe number of heartbeats per second to send, and to expect to receive. If set to 0, we'll act as if it was set to 1.

Definition at line 90 of file ZGPeerSettings.h.

void SetMaximumUpdateLogSizeForDatabase ( uint32  whichDB,
uint64  maxNumBytes 
)
inline

Call this to set the maximum number of bytes of RAM the specified database should be allowed to use for its database-update-log records.

If not specified for a given database, a default limit of two megabytes will be used.

Parameters
whichDBThe database you want to specify a new limit for
maxNumBytesThe new limit, in bytes. If set to 0, then the default limit will be reinstated for that database.

Definition at line 121 of file ZGPeerSettings.h.

void SetMaxNumMissingHeartbeats ( uint32  hb)
inline

Sets the number of heartbeat-periods that must go by without hearing any heartbeats from a source, before we will decide that that source has gone offline.

Default value is 4 (i.e. we will wait for four heartbeat-intervals to go by without any heartbeats from a source, before declaring a source to be offline)

Parameters
hbThe number of heartbeat intervals that will trigger an offline-state.

Definition at line 106 of file ZGPeerSettings.h.

void SetPeerAttributes ( const ConstMessageRef &  peerAttributes)
inline

Set the peer attributes that should be associated with this peer.

Default is to have no attributes.

Parameters
peerAttributesReference to a Message containing our attributes. Try to keep this small, as a zlib-compressed copy of this Message will be included in every heartbeat packet we send!

Definition at line 82 of file ZGPeerSettings.h.


The documentation for this class was generated from the following file: