tman.h File Reference

Tman interface. More...

Go to the source code of this file.

Typedefs

typedef int(* tmanRankingFunction )(const void *target, const void *p1, const void *p2)
 Compare neighbors features.

Functions

int tmanInit (struct nodeID *myID, void *metadata, int metadata_size, tmanRankingFunction rfun, int gossip_peers)
 Initialise Tman.
int tmanAddNeighbour (struct nodeID *neighbour, void *metadata, int metadata_size)
 Insert a peer in the neighbourhood.
int tmanParseData (const uint8_t *buff, int len, struct nodeID **peers, int size, const void *metadata, int metadata_size)
 Pass a received packet to Tman.
int tmanChangeMetadata (struct nodeID *peer, void *metadata, int metadata_size)
 Change the metadata in tman neighborhood.
const void * tmanGetMetadata (int *metadata_size)
 Get the metadata of the neighbors.
int tmanGetNeighbourhoodSize (void)
 Get the current neighborhood size.
int tmanGivePeers (int n, struct nodeID **peers, void *metadata)
 Get the highest ranked tman peers.
int tmanGrowNeighbourhood (int n)
 Increase the neighbourhood size.
int tmanShrinkNeighbourhood (int n)
 Decrease the neighbourhood size.

Detailed Description

Tman interface.

This is the Tman interface. Tman builds a given topology according to a user provided ranking algorithm, by means of epidemic-style message exchanges with neighbor peers.


Typedef Documentation

typedef int(* tmanRankingFunction)(const void *target, const void *p1, const void *p2)

Compare neighbors features.

The functions implementing this prototype are used to compare neighbors features against a given target neighbor, in order to obtain a rank, to be used to build a given topology.

Parameters:
target pointer to data that describe the target against which the ranking has to be made.
p1 pointer to data that describe the first neighbor.
p2 pointer to data that describe the second neighbor.
Returns:
1 if p1 is to be ranked first; 2 if p2 is to be ranked first; 0 if there is a tie.

Function Documentation

int tmanAddNeighbour ( struct nodeID *  neighbour,
void *  metadata,
int  metadata_size 
)

Insert a peer in the neighbourhood.

This function can be used to add a specified neighbour to the neighbourhood.

Parameters:
neighbour the id of the peer to be added to the neighbourhood.
metadata Pointer to the array of metadata belonging to the peers to be added.
metadata_size Number of bytes of each metadata.
Returns:
0 in case of success; -1 in case of error.
int tmanChangeMetadata ( struct nodeID *  peer,
void *  metadata,
int  metadata_size 
)

Change the metadata in tman neighborhood.

This function changes the metadata associated with the current node.

Parameters:
metadata Pointer to the metadata belonging to the peer.
metadata_size Number of bytes of the metadata.
Returns:
1 if successful, -1 otherwise.
const void* tmanGetMetadata ( int *  metadata_size  ) 

Get the metadata of the neighbors.

Parameters:
metadata_size Address of the integer that will be set to the size of each metadata.
Returns:
a pointer to the array of metadata associated with the peers in the neighbourhood. NULL in case of error, or if the neighbourhood is empty.
int tmanGetNeighbourhoodSize ( void   ) 

Get the current neighborhood size.

This function returns the current number of peers in the local tman neighborhood.

Returns:
The current size of the neighborhood.
int tmanGivePeers ( int  n,
struct nodeID **  peers,
void *  metadata 
)

Get the highest ranked tman peers.

This function allows the user to retrieve the highest ranked n peers from tman cache, along with their metadata. The number of peers actually returned may be different from what is asked, depending on the current size of the cache. Notice that if the user asks for a number of peers that exceeds the current cache size, a join with the known peers set provided via tmanParseData will be triggered at the next time tmanParseData is called. This will change (and make unstable, at least for few subsequent iterations) the current known topology. Thus, it is advisable to do so only if necessary (i.e. when the user really needs more peers to communicate with).

Parameters:
n The number of peer tman is asked for.
peers Array of nodeID pointers to be filled.
metadata Pointer to the array of metadata belonging to the peers to be given.
Returns:
The number of elements in peers.
int tmanGrowNeighbourhood ( int  n  ) 

Increase the neighbourhood size.

This function can be used to increase the number of neighbours (that is, the degree of the overlay graph) by a specified amount. The actual size change will be done the next time tmanParseData is called. As currently implemented, it doubles the current size at most. If the argument is negative or a resize has already been requested, but not performed yet, no change will occur and an error code is returned.

Parameters:
n number of peers by which the neighbourhood size must be incremented.
Returns:
the new neighbourhood size in case of success; -1 in case of error.
int tmanInit ( struct nodeID *  myID,
void *  metadata,
int  metadata_size,
tmanRankingFunction  rfun,
int  gossip_peers 
)

Initialise Tman.

This function initializes tman protocol with all the mandatory parameters.

Parameters:
myID the ID of this peer.
metadata Pointer to data associated with the local peer.
metadata_size Size (number of bytes) of the metadata associated with the local peer.
rfun Ranking function to be used to order the peers in tman cache.
gossip_peers Number of peers, among those in the cache, to be gossiped in a messaged exchange.
Returns:
0 in case of success; -1 in case of error.
int tmanParseData ( const uint8_t *  buff,
int  len,
struct nodeID **  peers,
int  size,
const void *  metadata,
int  metadata_size 
)

Pass a received packet to Tman.

This function passes to Tman a packet that has been received from the network. The Topology Manager will parse such packet and run the protocol, adding or removing peers to the neighbourhood, and sending overlay management messages to other peers.

Parameters:
buff a memory buffer containing the received message.
len the size of such a memory buffer.
peers Array of nodeID pointers to be added in tman cache.
size Number of elements in peers.
metadata Pointer to the array of metadata belonging to the peers to be added.
metadata_size Number of bytes of each metadata.
Returns:
0 in case of success; -1 in case of error.
int tmanShrinkNeighbourhood ( int  n  ) 

Decrease the neighbourhood size.

This function can be used to reduce the number of neighbours (that is, the degree of the overlay graph) by a specified amount. The actual size change will be done the next time tmanParseData is called. If the argument is negative, or greater equal than the current cache size, or a resize has already been requested, but not performed yet, no change will occur and an error code is returned.

Parameters:
n number of peers by which the neighbourhood size must be decreased.
Returns:
the new neighbourhood size in case of success; -1 in case of error.
Generated on Mon Jul 12 16:16:52 2010 for GRAPES by  doxygen 1.6.3