C# Class TransportService.PeerQueueElement

This class represent an abstraction of the peer from the point of view of a requestor. It is used inside a PeerQueue. The class internally stores a channel used to communicate with other peer. It is useful to avoid opening and closing the channel. This class is strictly coupled with PeerQueue.
Show file Open project: zencoders/sambatyon Class Usage Examples

Public Methods

Method Description
GetChunk ( ChunkRequest chkrq ) : void

Method used to require a chunk to the peer represented by the inner channel.

PeerQueueElement ( ) : System

Default constructor of the class.

PeerQueueElement ( string peerAddress, float peerScore, AutoResetEvent &peerQueueNotEmpty ) : System

Constructor of the class that effectively valorize its attributes.

Reset ( ) : void

Method actively used to reset a peer putting it in free state. If the peer have a timer active the timer is disabled.

TimedPeerBlock ( int millis ) : void

Method used to block the peer (avoid to request again) for a certain number of milliseconds as passed by argument. For the time indicated the peer is put in the BUSY state; after that time the peer is resettled in FREE state.

Private Methods

Method Description
timerHandler ( object source, EventArgs e ) : void

Method called by the timer to automatically call the Reset method. Each time this method is called the peer score is augmented by one.

Method Details

GetChunk() public method

Method used to require a chunk to the peer represented by the inner channel.
public GetChunk ( ChunkRequest chkrq ) : void
chkrq TransportService.Messages.ChunkRequest ChunkRequest object containing informations about the resource.
return void

PeerQueueElement() public method

Default constructor of the class.
public PeerQueueElement ( ) : System
return System

PeerQueueElement() public method

Constructor of the class that effectively valorize its attributes.
public PeerQueueElement ( string peerAddress, float peerScore, AutoResetEvent &peerQueueNotEmpty ) : System
peerAddress string URI address of the peer
peerScore float Score of the peer (the less it is the better is the peer
peerQueueNotEmpty System.Threading.AutoResetEvent /// AutoResetEvent used to communicate to the Peer Queue that the queue is not empty. ///
return System

Reset() public method

Method actively used to reset a peer putting it in free state. If the peer have a timer active the timer is disabled.
public Reset ( ) : void
return void

TimedPeerBlock() public method

Method used to block the peer (avoid to request again) for a certain number of milliseconds as passed by argument. For the time indicated the peer is put in the BUSY state; after that time the peer is resettled in FREE state.
public TimedPeerBlock ( int millis ) : void
millis int time used to block the peer.
return void