|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.dyade.aaa.agent.PoolNetwork.NetSession
final class PoolNetwork.NetSession
The class NetSession controls the connection with a particular server.
Each NetSession object is dedicated to the handling of the connection with a server, at a time a session can be either active (with a TCP connection and a receiver thread) or passive. Currently the number of active NetSession is limited, this number can be adjust through the nbMaxCnx property.
The message sending is handled by dynamically Sender components.
Nested Class Summary | |
---|---|
(package private) class |
PoolNetwork.NetSession.NetworkInputStream
Class used to read messages through a stream. |
(package private) class |
PoolNetwork.NetSession.NetworkOutputStream
Class used to send messages through a stream. |
Field Summary | |
---|---|
private boolean |
canStop
True if the sessions can be stopped, false otherwise. |
private long |
last
Time in milliseconds of last use of this session, this attribute is set during connection, then updated at each sending or receiving. |
(package private) long |
lastReceived
Time in milliseconds of last message received. |
private boolean |
local
True if a "local" connection is in progress, a local connection is initiated from this server to the remote one (defined by the server descriptor. |
(package private) int |
maxMessageInFlow
Maximum number of message sent and non acknowledged. |
private java.lang.String |
name
The session's name. |
(package private) int |
nbAckSent
The number of acknowledge sent since last reboot. |
(package private) int |
nbMessageReceived
The number of messages received since last reboot. |
(package private) int |
nbMessageSent
The number of messages sent since last reboot. |
(package private) PoolNetwork.NetSession.NetworkInputStream |
nis
|
(package private) PoolNetwork.NetSession.NetworkOutputStream |
nos
|
private boolean |
running
Boolean variable used to stop the daemon properly. |
(package private) PoolNetwork.Sender |
sender
Sender component needed to send messages. |
(package private) MessageSoftList |
sendList
List of all sent messages waiting for an acknowledge from the remote server. |
private ServerDesc |
server
The description of the remote server handled by this network session. |
private short |
sid
Destination server id |
private java.net.Socket |
sock
The communication socket. |
private java.lang.Thread |
thread
The thread. |
Constructor Summary | |
---|---|
PoolNetwork.NetSession(java.lang.String name,
short sid)
|
Method Summary | |
---|---|
private void |
ack(int stamp)
|
(package private) void |
close()
|
private void |
doAck(int ack)
Removes the acknowledged notification from waiting list. |
(package private) long |
getLastReceived()
Returns the time in milliseconds of last message received. |
(package private) int |
getMaxMessageInFlow()
Gets the maximum number of message sent and non acknowledged. |
java.lang.String |
getName()
Returns this session's name. |
(package private) int |
getNbAckSent()
Returns the number of acknowledge sent since last reboot. |
(package private) int |
getNbBufferingMessageToSent()
Returns the number of buffering messages to sent since last reboot. |
(package private) int |
getNbMessageReceived()
Returns the number of messages received since last reboot. |
(package private) int |
getNbMessageSent()
Returns the number of messages sent since last reboot. |
(package private) int |
getNbWaitingMessages()
Gets the number of waiting messages to send for this session. |
short |
getRemoteSID()
Returns the server identification of remote server. |
(package private) void |
init()
|
boolean |
isRunning()
Tests if the session is connected. |
(package private) boolean |
localStart()
This method is called by start(long) in order to
initiate a connection from the local server. |
(package private) boolean |
remoteStart(java.net.Socket sock,
int boot)
Its method is called by start(Socket, int)
in order to reply to a connection request from a remote server. |
void |
run()
|
(package private) void |
send()
Try to send the first message of the list to the corresponding remote server. |
(package private) void |
setMaxMessageInFlow(int maxMessageInFlow)
Sets the maximum number of message sent and non acknowledged. |
void |
shutdown()
|
(package private) void |
start(long currentTimeMillis)
Starts the session opening the connection with the remote server. |
(package private) void |
start(java.net.Socket sock,
int boot)
|
private void |
startEnd()
The session is well initialized, we can start the server thread that "listen" the connected socket. |
(package private) void |
stop()
|
java.lang.String |
toString()
|
java.lang.StringBuffer |
toString(java.lang.StringBuffer strbuf)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private short sid
private volatile boolean running
start
,
stop
private boolean canStop
private java.lang.Thread thread
private java.lang.String name
private volatile boolean local
server
descriptor.
This attribute is used to synchronize local and remote attempts to
make connections.
private ServerDesc server
private volatile java.net.Socket sock
PoolNetwork.Sender sender
int maxMessageInFlow
PoolNetwork.NetSession.NetworkInputStream nis
PoolNetwork.NetSession.NetworkOutputStream nos
MessageSoftList sendList
private long last
int nbMessageSent
int nbMessageReceived
int nbAckSent
long lastReceived
Constructor Detail |
---|
PoolNetwork.NetSession(java.lang.String name, short sid)
Method Detail |
---|
int getMaxMessageInFlow()
void setMaxMessageInFlow(int maxMessageInFlow)
maxMessageInFlow
- the maximum number of message sent and non acknowledged.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.StringBuffer toString(java.lang.StringBuffer strbuf)
void init() throws UnknownServerException
UnknownServerException
public final java.lang.String getName()
public short getRemoteSID()
public boolean isRunning()
int getNbWaitingMessages()
int getNbMessageSent()
int getNbMessageReceived()
int getNbAckSent()
long getLastReceived()
int getNbBufferingMessageToSent()
void start(long currentTimeMillis)
The protocol is synchronized in order to avoid a 'double' connection between the two servers.
currentTimeMillis
- The current time in millisecondslocalStart
void start(java.net.Socket sock, int boot)
boolean localStart()
start(long)
in order to
initiate a connection from the local server. The corresponding code
on remote server is the method remoteStart(Socket, int)
.
Its method creates the socket, initiates the network connection, and
negotiates with remote server.In order to override the protocol, we have to implements its method, with the remoteStart and the transmit methods.
boolean remoteStart(java.net.Socket sock, int boot)
start(Socket, int)
in order to reply to a connection request from a remote server.
The corresponding code on remote server is the method
localStart()
.
sock
- the connected socket
private void startEnd()
void stop()
public void shutdown()
void close()
private final void doAck(int ack) throws java.lang.Exception
ack
- The stamp of acknowledged message to remove.
java.lang.Exception
- Error during the message deletion.final void send()
private final void ack(int stamp) throws java.lang.Exception
java.lang.Exception
public void run()
run
in interface java.lang.Runnable
Runnable.run()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |