|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.mcgill.cs.postina.scribe.ScribeApplication.messageHandler
private class ScribeApplication.messageHandler
The inner class messageHandler is responsible for handling all incoming direct messages. Its main task is to provide reliability.
| Field Summary | |
|---|---|
private int |
defaultTimeout
The number of milliseconds before a message times out and is resent. |
private java.util.Hashtable<rice.p2p.commonapi.Id,java.lang.Integer> |
doomedClients
Clients who have not acknowledged a message after a certain number of attempts are suspected to be dead and put into this hashtable. |
private int |
fatalNumLostMsg
The number of messages that can be lost before a client is definitely declared dead. |
private java.util.HashSet<rice.p2p.commonapi.Id> |
killedClients
Clients who have been suspected to be dead for a certain number of times are declared dead and subsequently ignored. |
private int |
maxNumTries
This integer variable indicates the number of attempts that are made to send a message before the client is suspected to be dead. |
private LinkedHashSet<MessageID> |
receivedMessagesIDs
The list receivedMessagesIDs contains the IDs of
received messages to guarantee that each message is delivered only
once. |
private long |
sleep
This long specifies how long the thread will wait
after each round in the loop. |
| Constructor Summary | |
|---|---|
ScribeApplication.messageHandler()
The unique constructor creates all necessary lists and sets the variables to the default values defined in the property file postina.properties. |
|
| Method Summary | |
|---|---|
void |
cancelMessage(MessageID msgId)
A message that has timed out a certain number of times (specified in the properties) will not be resent anymore. |
long |
checkAcks()
This method checks if any message has timed out since the last check and takes the appropriate action. |
boolean |
clientIsAlive(rice.p2p.commonapi.Id client)
This method indicates if a given client has been declared dead in the past. |
void |
doomClient(rice.p2p.commonapi.NodeHandle nh,
rice.p2p.commonapi.Id client)
This method does the necessary handling when a client is suspected dead. |
void |
handleAck(AckMessage ack)
This method handles an incoming acknowledgment. |
void |
handleMessage(rice.p2p.commonapi.Message message)
This is the main entry method of the message handler. |
void |
handleReliable(PostinaReliableScribeTransportMessage msg)
This method actually handles a newly arrived message (sending acknowledgment etc). |
void |
killClient(rice.p2p.commonapi.NodeHandle handle,
rice.p2p.commonapi.Id client)
A client that has not acknowledged a certain number of messages and not sent any new messages is considered dead and ignored in the future. |
void |
pardonClient(rice.p2p.commonapi.Id client)
If the same message is lost several times, a client is suspected dead and finally, after a specified number of times, declared dead. This method resets the counter to 0 which is necessary when a message from this client arrives (confirming that it is still alive). |
void |
removeOldMessages(long storageTime)
The buffer containing received messages has to be cleaned from time to time. This is done by this method which removes old messages from the buffer. |
void |
resendMessage(MessageID msgId)
This method resends a message. |
void |
run()
|
void |
sendAck(PostinaReliableScribeTransportMessage msg)
This message confirms the arrival of message by sending back an acknowledgment to the originator of the message. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final int defaultTimeout
private final java.util.Hashtable<rice.p2p.commonapi.Id,java.lang.Integer> doomedClients
private final int fatalNumLostMsg
private final java.util.HashSet<rice.p2p.commonapi.Id> killedClients
private final int maxNumTries
private final LinkedHashSet<MessageID> receivedMessagesIDs
receivedMessagesIDs contains the IDs of
received messages to guarantee that each message is delivered only
once.
private long sleep
long specifies how long the thread will wait
after each round in the loop. The value is computed depending on the
next timeout.
| Constructor Detail |
|---|
public ScribeApplication.messageHandler()
postina.properties.
| Method Detail |
|---|
public void cancelMessage(MessageID msgId)
msgId - The unique identifier of the message that has to be
cancelled because it has timed out too often.public long checkAcks()
long indicating the
number of milliseconds after which the next message will time
out. The calling thread uses this value to determine for how
much time it has to sleep/wait.public boolean clientIsAlive(rice.p2p.commonapi.Id client)
client - The client of which the status has to be known.
false if the client has been declared
dead, true true otherwise.
public void doomClient(rice.p2p.commonapi.NodeHandle nh,
rice.p2p.commonapi.Id client)
nh - The nodehandle of the client.client - The unique identifier of the client that is suspected
dead.public void handleAck(AckMessage ack)
ack - The acknowledgment to handle.public void handleMessage(rice.p2p.commonapi.Message message)
message - public void handleReliable(PostinaReliableScribeTransportMessage msg)
msg - The new direct message that has to be handled.
public void killClient(rice.p2p.commonapi.NodeHandle handle,
rice.p2p.commonapi.Id client)
handle - The nodehandle of the client being declared dead. This is
used to inform listeners.client - The Id of the client being declared dead.public void pardonClient(rice.p2p.commonapi.Id client)
client - The client which has to be pardoned, i.e. which has
confirmed that it is still alive.public void removeOldMessages(long storageTime)
storageTime - This long indicates the time in
milliseconds that messages are kept in the buffer.public void resendMessage(MessageID msgId)
msgId - The unique identifier of the message that has to be
resent.public void run()
run in interface java.lang.Runnablepublic void sendAck(PostinaReliableScribeTransportMessage msg)
msg - The message of which the arrival has to be confirmed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||