Class PoolNetwork
- java.lang.Object
-
- fr.dyade.aaa.agent.Network
-
- fr.dyade.aaa.agent.StreamNetwork
-
- fr.dyade.aaa.agent.PoolNetwork
-
- All Implemented Interfaces:
MessageComparator,MessageConsumer,NetworkMBean,PoolNetworkMBean
- Direct Known Subclasses:
SSLNetwork
public class PoolNetwork extends StreamNetwork implements PoolNetworkMBean
PoolNetworkis an implementation ofStreamNetworkclass that manages multiple connection in a pool paradigm way.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classPoolNetwork.Boot(package private) classPoolNetwork.Dispatcher(package private) classPoolNetwork.NetSessionThe class NetSession controls the connection with a particular server.(package private) classPoolNetwork.Sender(package private) classPoolNetwork.WakeOnConnection(package private) classPoolNetwork.WatchDog-
Nested classes/interfaces inherited from class fr.dyade.aaa.agent.Network
Network.NetworkAverageLoadTask
-
-
Field Summary
Fields Modifier and Type Field Description (package private) List<PoolNetwork.NetSession>activeSessionsSynchronized vector of active (i.e. connected) sessions.(package private) booleancompressedFlowsDefines if the streams between servers are compressed or not.(package private) intdefaultMaxMessageInFlowDefines the default value for maximum number of message sent and non acknowledged on a connection.(package private) PoolNetwork.DispatcherdispatcherDaemon sending message to others servers.(package private) longIdleTimeoutDefines in milliseconds the maximum idle period permitted before reseting the connection.private static byte[]magicMagic number to identify peer.longminIdleTimeout(package private) intnbMaxCnxDefines the maximum number of concurrent connected sessions.(package private) PoolNetwork.NetSession[]sessionsComponents handling communication with other servers.(package private) PoolNetwork.WakeOnConnectionwakeOnConnectionDaemon listening for connection from other servers.(package private) PoolNetwork.WatchDogwatchDogDaemon handling the messages for inaccessible servers.-
Fields inherited from class fr.dyade.aaa.agent.StreamNetwork
backlog, CnxRetry, ConnectTimeout, inLocalAddr, outLocalAddr, outLocalPort, serverSocketFactory, socketFactory, SoLinger, SoTimeout, TcpNoDelay
-
Fields inherited from class fr.dyade.aaa.agent.Network
ALREADY_DELIVERED, averageLoadTask, bootTSFN, DEBUG, DELIVER, domain, idxLS, logger, name, nbMessageIn, nbMessageOut, port, qout, servers, serversFN, sid, WDActivationPeriod, WDNbRetryLevel1, WDNbRetryLevel2, WDRetryPeriod1, WDRetryPeriod2, WDRetryPeriod3
-
-
Constructor Summary
Constructors Constructor Description PoolNetwork()Creates a new network component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddServer(short id)Adds the server sid in the network configuration.voiddelServer(short id)Removes the server sid in the network configuration.booleangetCompressedFlows()Returns if the stream between servers are compressed or not.longgetIdleTimeout()Returns the maximum idle period permitted before reseting the connection.(package private) longgetLastReceived(short sid)Returns the time in milliseconds of last message received.(package private) intgetMaxMessageInFlow(short sid)Gets the maximum number of message sent and non acknowledged.private StringgetMBeanName(short sid)(package private) intgetNbAckSent(short sid)Returns the number of acknowledge sent since last reboot.intgetNbActiveSession()Returns the number of currently connected sessions.(package private) intgetNbBufferingMessageToSent(short sid)Returns the number of buffering messages to sent since last reboot.intgetNbMaxActiveSession()Returns the maximum number of concurrent connected sessions.(package private) intgetNbMessageReceived(short sid)Returns the number of messages received since last reboot.(package private) intgetNbMessageSent(short sid)Returns the number of messages sent since last reboot.intgetNbWaitingMessages()Gets the number of waiting messages in this engine.(package private) PoolNetwork.NetSessiongetSession(short sid)Returns the NetSession component handling the communication with the remote server that id is passed in parameter.(package private) intgetSessionNbWaitingMessages(short sid)Gets the number of waiting messages to send for this session.voidinit(String name, int port, short[] servers)Initializes a new network component.booleanisRunning()Tests if the network component is alive.(package private) booleanisSessionRunning(short sid)Tests if the session is connected.(package private) intreadAck(InputStream in)(package private) PoolNetwork.BootreadBoot(InputStream in)(package private) voidreadFully(InputStream is, byte[] iobuf)voidsetIdleTimeout(long idleTimeout)Sets the maximum idle period permitted before reseting the connection.(package private) voidsetMaxMessageInFlow(short sid, int maxMessageInFlow)Sets the maximum number of message sent and non acknowledged.voidsetProperties()Set the properties of the network.voidstart()Causes this network component to begin execution.voidstop()Forces the network component to stop executing.StringtoString()Returns a string representation of this consumer, including the daemon's name and status.voidwakeup()Wakes up the watch-dog thread.(package private) voidwriteAck(OutputStream out)(package private) voidwriteBoot(OutputStream out)-
Methods inherited from class fr.dyade.aaa.agent.StreamNetwork
createServerSocket, createServerSocket, createSocket, createSocket, createSocket, setSocketOption
-
Methods inherited from class fr.dyade.aaa.agent.Network
channelPostAndValidate, checkActive, delete, deleteMessage, deliver, getAverageLoad1, getAverageLoad15, getAverageLoad5, getBootTS, getDomainName, getMessageDest, getMessageSource, getName, getNbMessageReceived, getNbMessageSent, getPort, getQueue, getStamp, getWDActivationPeriod, getWDNbRetryLevel1, getWDNbRetryLevel2, getWDRetryPeriod1, getWDRetryPeriod2, getWDRetryPeriod3, index, insert, isPrior, post, postAndValidate, postMessage, prepareMessage, prepareMessageWithoutStamp, resetServer, restore, save, saveChannel, setMessageSource, setPort, setStamp, setWDActivationPeriod, setWDNbRetryLevel1, setWDNbRetryLevel2, setWDRetryPeriod1, setWDRetryPeriod2, setWDRetryPeriod3, testBootTS, testRecvUpdate, validate, validateChannel
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface fr.dyade.aaa.agent.NetworkMBean
getAverageLoad1, getAverageLoad15, getAverageLoad5, getName, getNbMessageReceived, getNbMessageSent, getWDActivationPeriod, getWDNbRetryLevel1, getWDNbRetryLevel2, getWDRetryPeriod1, getWDRetryPeriod2, getWDRetryPeriod3, setWDActivationPeriod, setWDNbRetryLevel1, setWDNbRetryLevel2, setWDRetryPeriod1, setWDRetryPeriod2, setWDRetryPeriod3
-
-
-
-
Field Detail
-
magic
private static final byte[] magic
Magic number to identify peer.
-
wakeOnConnection
PoolNetwork.WakeOnConnection wakeOnConnection
Daemon listening for connection from other servers.
-
sessions
PoolNetwork.NetSession[] sessions
Components handling communication with other servers. There is a NetSession component for each server in the domain, some are 'active' (i.e connected).
-
dispatcher
PoolNetwork.Dispatcher dispatcher
Daemon sending message to others servers.
-
watchDog
PoolNetwork.WatchDog watchDog
Daemon handling the messages for inaccessible servers.
-
activeSessions
List<PoolNetwork.NetSession> activeSessions
Synchronized vector of active (i.e. connected) sessions.
-
compressedFlows
boolean compressedFlows
Defines if the streams between servers are compressed or not.Default value is false, be careful in a domain all servers must use the same definition.
This value can be adjusted for all network components by setting
PoolNetwork.compressedFlowsglobal property or for a particular network by setting<DomainName>.compressedFlowsspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
nbMaxCnx
int nbMaxCnx
Defines the maximum number of concurrent connected sessions.By default this property is set to -1 to dynamically adjust to the number of servers of the domain (excepting the current server). Setting this value needs precautions to avoid unexpected connection loss.
This value can be adjusted for all network components by setting
PoolNetwork.nbMaxCnxglobal property or for a particular network by setting<DomainName>.nbMaxCnxspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
minIdleTimeout
public final long minIdleTimeout
- See Also:
- Constant Field Values
-
IdleTimeout
long IdleTimeout
Defines in milliseconds the maximum idle period permitted before reseting the connection.The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Default value is 60000 (1 minute), value less than 1000 are unauthorized.
This value can be adjusted for all network components by setting
PoolNetwork.IdleTimeoutglobal property or for a particular network by setting<DomainName>.IdleTimeoutspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
defaultMaxMessageInFlow
int defaultMaxMessageInFlow
Defines the default value for maximum number of message sent and non acknowledged on a connection.By default this value is set to -1 and there is no flow control.
This value can be adjusted for all network components by setting the
PoolNetwork.maxMessageInFlowglobal property or for a particular network by setting<DomainName>.maxMessageInFlowspecific property.For a particular network the value can be defined finely for a the connection with a particular remote server by setting
PoolNetwork.maxMessageInFlow_Nor<DomainName>.maxMessageInFlow_N.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
-
Method Detail
-
getCompressedFlows
public boolean getCompressedFlows()
Returns if the stream between servers are compressed or not.- Specified by:
getCompressedFlowsin interfacePoolNetworkMBean- Returns:
- true if the streams between servers are compressed, false otherwise.
-
getNbMaxActiveSession
public int getNbMaxActiveSession()
Returns the maximum number of concurrent connected sessions.- Specified by:
getNbMaxActiveSessionin interfacePoolNetworkMBean- Returns:
- the number of concurrent connected sessions.
-
getNbActiveSession
public int getNbActiveSession()
Returns the number of currently connected sessions.- Specified by:
getNbActiveSessionin interfacePoolNetworkMBean- Returns:
- the number of currently connected sessions.
-
getIdleTimeout
public long getIdleTimeout()
Returns the maximum idle period permitted before reseting the connection.- Specified by:
getIdleTimeoutin interfacePoolNetworkMBean- Returns:
- the maximum idle period permitted before reseting the connection.
-
setIdleTimeout
public void setIdleTimeout(long idleTimeout)
Sets the maximum idle period permitted before reseting the connection.- Specified by:
setIdleTimeoutin interfacePoolNetworkMBean- Parameters:
idleTimeout- the maximum idle period permitted before reseting the connection.
-
init
public void init(String name, int port, short[] servers) throws Exception
Initializes a new network component. This method is used in order to easily creates and configure a Network component from a class name. So we can use theClass.newInstance()method for create (without any parameter) the component, then we can initialize it with this method.
This method initializes the logical clock for the domain.- Overrides:
initin classStreamNetwork- Parameters:
name- The domain name.port- The listen port.servers- The list of servers directly accessible from this network interface.- Throws:
Exception- an error occurs.- See Also:
Network
-
setProperties
public void setProperties() throws ExceptionSet the properties of the network. Inherited from Network class, can be extended by subclasses.- Overrides:
setPropertiesin classStreamNetwork- Throws:
Exception- an error occurs.
-
addServer
public void addServer(short id) throws ExceptionAdds the server sid in the network configuration.
-
delServer
public void delServer(short id) throws ExceptionRemoves the server sid in the network configuration.
-
getMBeanName
private String getMBeanName(short sid)
-
start
public void start() throws ExceptionCauses this network component to begin execution.- Specified by:
startin interfaceMessageConsumer- Specified by:
startin interfaceNetworkMBean- Throws:
Exception- an error occurs.- See Also:
MessageConsumer.stop()
-
wakeup
public void wakeup()
Wakes up the watch-dog thread.
-
stop
public void stop()
Forces the network component to stop executing.- Specified by:
stopin interfaceMessageConsumer- Specified by:
stopin interfaceNetworkMBean- See Also:
MessageConsumer.start()
-
isRunning
public boolean isRunning()
Tests if the network component is alive.- Specified by:
isRunningin interfaceMessageConsumer- Specified by:
isRunningin interfaceNetworkMBean- Returns:
- true if this
MessageConsumeris alive; false otherwise.
-
getSession
final PoolNetwork.NetSession getSession(short sid) throws UnknownServerException
Returns the NetSession component handling the communication with the remote server that id is passed in parameter.- Parameters:
sid- the server id of remote server.- Returns:
- the NetSession component handling the communication with the remote server.
- Throws:
UnknownServerException- the server is not defined.
-
isSessionRunning
final boolean isSessionRunning(short sid)
Tests if the session is connected.- Parameters:
sid- the server id of remote server.- Returns:
- true if this session is connected; false otherwise.
-
getMaxMessageInFlow
final int getMaxMessageInFlow(short sid)
Gets the maximum number of message sent and non acknowledged.- Parameters:
sid- the server id of remote server.- Returns:
- the maximum number of message sent and non acknowledged.
-
setMaxMessageInFlow
void setMaxMessageInFlow(short sid, int maxMessageInFlow)Sets the maximum number of message sent and non acknowledged.- Parameters:
sid- the server id of remote server.maxMessageInFlow- the maximum number of message sent and non acknowledged.
-
getSessionNbWaitingMessages
final int getSessionNbWaitingMessages(short sid)
Gets the number of waiting messages to send for this session.- Parameters:
sid- the server id of remote server.- Returns:
- the number of waiting messages.
-
getNbMessageSent
final int getNbMessageSent(short sid)
Returns the number of messages sent since last reboot.- Parameters:
sid- the server id of remote server.- Returns:
- the number of messages sent since last reboot.
-
getNbMessageReceived
final int getNbMessageReceived(short sid)
Returns the number of messages received since last reboot.- Parameters:
sid- the server id of remote server.- Returns:
- the number of messages received since last reboot.
-
getNbAckSent
final int getNbAckSent(short sid)
Returns the number of acknowledge sent since last reboot.- Parameters:
sid- the server id of remote server.- Returns:
- the number of acknowledge sent since last reboot.
-
getLastReceived
final long getLastReceived(short sid)
Returns the time in milliseconds of last message received.- Parameters:
sid- the server id of remote server.- Returns:
- the time in milliseconds of last message received.
-
getNbBufferingMessageToSent
final int getNbBufferingMessageToSent(short sid)
Returns the number of buffering messages to sent since last reboot.- Parameters:
sid- the server id of remote server.- Returns:
- the number of buffering messages to sent since last reboot.
-
getNbWaitingMessages
public int getNbWaitingMessages()
Gets the number of waiting messages in this engine.- Specified by:
getNbWaitingMessagesin interfaceNetworkMBean- Overrides:
getNbWaitingMessagesin classNetwork- Returns:
- the number of waiting messages.
-
toString
public String toString()
Returns a string representation of this consumer, including the daemon's name and status.- Specified by:
toStringin interfaceNetworkMBean- Overrides:
toStringin classNetwork- Returns:
- A string representation of this consumer.
-
writeBoot
final void writeBoot(OutputStream out) throws IOException
- Throws:
IOException
-
readFully
final void readFully(InputStream is, byte[] iobuf) throws IOException
- Throws:
IOException
-
readBoot
final PoolNetwork.Boot readBoot(InputStream in) throws IOException
- Throws:
IOException
-
writeAck
final void writeAck(OutputStream out) throws IOException
- Throws:
IOException
-
readAck
final int readAck(InputStream in) throws IOException
- Throws:
IOException
-
-