Class StreamNetwork
- java.lang.Object
-
- fr.dyade.aaa.agent.Network
-
- fr.dyade.aaa.agent.StreamNetwork
-
- All Implemented Interfaces:
MessageComparator,MessageConsumer,NetworkMBean
- Direct Known Subclasses:
HttpNetwork,NGNetwork,PoolNetwork,SimpleNetwork
public abstract class StreamNetwork extends Network
StreamNetworkis a base implementation ofNetworkclass for TCP sockets.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class fr.dyade.aaa.agent.Network
Network.NetworkAverageLoadTask
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intbacklogThe maximum queue length for incoming connection indications, default value is 5.(package private) intCnxRetryNumbers of attempt to bind the server's socket before aborting, default value is 3.(package private) intConnectTimeoutDefines in milliseconds the timeout used during socket connection.(package private) InetAddressinLocalAddrThe local address the listen ServerSocket is bound to.(package private) InetAddressoutLocalAddrThe local address the sockets are bound to.(package private) intoutLocalPortThe local port the sockets are bound to.(package private) ServerSocketFactoryserverSocketFactoryAllows to define a specific factory for ServerSocket in order to by-pass compatibility problem between JDK version.(package private) SocketFactorysocketFactoryAllows to define a specific factory for Socket in order to by-pass compatibility problem between JDK version.(package private) intSoLingerEnable SO_LINGER with the specified linger time in seconds, if the value is less than 0 then it disables SO_LINGER.(package private) intSoTimeoutEnable/disable SO_TIMEOUT with the specified timeout in milliseconds.(package private) booleanTcpNoDelayEnable/disable TCP_NODELAY (disable/enable Nagle's algorithm), default value is false.-
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 Modifier Constructor Description protectedStreamNetwork()Creates a new Network component
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) ServerSocketcreateServerSocket()This method creates and returns a server socket which uses all network interfaces on the host, and is bound to the specified port.(package private) ServerSocketcreateServerSocket(int port)This method creates and returns a server socket which uses all network interfaces on the host, and is bound to the specified port.(package private) SocketcreateSocket(ServerDesc server)This method creates and returns a socket connected to a specified server.(package private) SocketcreateSocket(SocketAddress addr)This method creates and returns a socket connected to a ServerSocket at the specified socket address.(package private) SocketcreateSocket(InetAddress addr, int port)This method creates and returns a socket connected to a ServerSocket at the specified network address and port.voidinit(String name, int port, short[] servers)Initializes a new StreamNetwork component.voidsetProperties()Set the properties of the network.(package private) voidsetSocketOption(Socket sock)Configures this socket using the socket options established for this factory.-
Methods inherited from class fr.dyade.aaa.agent.Network
addServer, channelPostAndValidate, checkActive, delete, deleteMessage, deliver, delServer, getAverageLoad1, getAverageLoad15, getAverageLoad5, getBootTS, getDomainName, getMessageDest, getMessageSource, getName, getNbMessageReceived, getNbMessageSent, getNbWaitingMessages, 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, toString, 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.MessageConsumer
isRunning, start, stop
-
Methods inherited from interface fr.dyade.aaa.agent.NetworkMBean
isRunning, start, stop
-
-
-
-
Field Detail
-
CnxRetry
int CnxRetry
Numbers of attempt to bind the server's socket before aborting, default value is 3. This value can be adjusted for all network components by settingCnxRetryglobal property or for a particular network by setting<DomainName>.CnxRetryspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
backlog
int backlog
The maximum queue length for incoming connection indications, default value is 5. This value can be adjusted for all network components by settingbacklogglobal property or for a particular network by setting<DomainName>.backlogspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
TcpNoDelay
boolean TcpNoDelay
Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm), default value is false. This value can be adjusted for all network components by settingTcpNoDelayglobal property or for a particular network by setting<DomainName>.TcpNoDelayspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
SoLinger
int SoLinger
Enable SO_LINGER with the specified linger time in seconds, if the value is less than 0 then it disables SO_LINGER. Default value is -1. This value can be adjusted for all network components by settingSoLingerglobal property or for a particular network by setting<DomainName>.SoLingerspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
SoTimeout
int SoTimeout
Enable/disable SO_TIMEOUT with the specified timeout in milliseconds. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Default value is 0. This value can be adjusted for all network components by settingSoTimeoutglobal property or for a particular network by setting<DomainName>.SoTimeoutspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
ConnectTimeout
int ConnectTimeout
Defines in milliseconds the timeout used during socket connection. The timeout must be > 0. A timeout of zero is interpreted as an infinite timeout. Default value is 0. This value can be adjusted for all network components by settingConnectTimeoutglobal property or for a particular network by setting<DomainName>.ConnectTimeoutspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
inLocalAddr
InetAddress inLocalAddr
The local address the listen ServerSocket is bound to. A null address will assign the wildcard address. Default value is null. This value can be adjusted for all network components by settingInLocalAddressglobal property or for a particular network by setting<DomainName>.InLocalAddressspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
outLocalPort
int outLocalPort
The local port the sockets are bound to. A valid port value is between 0 and 65535. A port number of zero will let the system pick up an ephemeral port in a bind operation. Default value is 0. This value can be adjusted for all network components by settingOutLocalPortglobal property or for a particular network by setting<DomainName>.OutLocalPortspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
outLocalAddr
InetAddress outLocalAddr
The local address the sockets are bound to. A null address will assign the wildcard address. Default value is null. This value can be adjusted for all network components by settingOutLocalAddressglobal property or for a particular network by setting<DomainName>.OutLocalAddressspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
serverSocketFactory
ServerSocketFactory serverSocketFactory
Allows to define a specific factory for ServerSocket in order to by-pass compatibility problem between JDK version. Currently there is two factories, The default factory for JDK since 1.4, andServerSocketFactory13for JDK prior to 1.4. This value can be adjusted for all network components by settingServerSocketFactoryglobal property or for a particular network by setting<DomainName>.ServerSocketFactoryspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
socketFactory
SocketFactory socketFactory
Allows to define a specific factory for Socket in order to by-pass compatibility problem between JDK version. Currently there is two factories, The default factory one for JDK since 1.4, and SocketFactory13 for JDK prior to 1.4. This value can be adjusted for all network components by settingSocketFactoryglobal property or for a particular network by setting<DomainName>.SocketFactoryspecific property.Theses properties can be fixed either from
javalaunching command, or ina3servers.xmlconfiguration file.
-
-
Method Detail
-
init
public void init(String name, int port, short[] servers) throws Exception
Initializes a new StreamNetwork component.
-
setProperties
public void setProperties() throws ExceptionSet the properties of the network. Inherited from Network class, can be extended by subclasses.- Overrides:
setPropertiesin classNetwork- Throws:
Exception- an error occurs.
-
createSocket
final Socket createSocket(ServerDesc server) throws IOException
This method creates and returns a socket connected to a specified server. It may be overloaded in subclass, in order to create particular subclasses of sockets.- Parameters:
server- the server descriptor.- Returns:
- a socket connected to a ServerSocket at the specified network address and port.
- Throws:
IOException- if the connection can't be established
-
createSocket
final Socket createSocket(SocketAddress addr) throws IOException
This method creates and returns a socket connected to a ServerSocket at the specified socket address. If it fails it resets the address in order to take in account dynamic DNS.- Parameters:
addr- the socket address.- Returns:
- a socket connected to a ServerSocket at the specified network address and port.
- Throws:
IOException- if the connection can't be established
-
createSocket
Socket createSocket(InetAddress addr, int port) throws IOException
This method creates and returns a socket connected to a ServerSocket at the specified network address and port. It may be overloaded in subclass, in order to use particular implementation of sockets.Due to polymorphism of both factories and sockets, different kinds of sockets can be used by the same application code. The sockets returned to the application can be subclasses of Socket, so that they can directly expose new APIs for features such as compression, security, or firewall tunneling.
- Parameters:
addr- the server address.port- the server port.- Returns:
- a socket connected to a ServerSocket at the specified network address and port.
- Throws:
IOException- if the connection can't be established
-
createServerSocket
final ServerSocket createServerSocket() throws IOException
This method creates and returns a server socket which uses all network interfaces on the host, and is bound to the specified port.- Returns:
- a server socket bound to the specified port.
- Throws:
IOException- for networking errors
-
createServerSocket
ServerSocket createServerSocket(int port) throws IOException
This method creates and returns a server socket which uses all network interfaces on the host, and is bound to the specified port. It may be overloaded in subclass, in order to create particular subclasses of server sockets.- Parameters:
port- the port to listen to.- Returns:
- a server socket bound to the specified port.
- Throws:
IOException- for networking errors
-
setSocketOption
void setSocketOption(Socket sock) throws SocketException
Configures this socket using the socket options established for this factory. It may be overloaded in subclass, in order to handle particular subclasses of sockets- Parameters:
sock- the socket.- Throws:
SocketException- for networking errors
-
-