public class PoolNetwork extends StreamNetwork implements PoolNetworkMBean
PoolNetwork
is an implementation of StreamNetwork
class that manages multiple connection in a pool paradigm way.Modifier and Type | Class and Description |
---|---|
(package private) static class |
PoolNetwork.Boot |
(package private) class |
PoolNetwork.Dispatcher |
(package private) class |
PoolNetwork.NetSession
The class NetSession controls the connection with a particular server.
|
(package private) class |
PoolNetwork.Sender |
(package private) class |
PoolNetwork.WakeOnConnection |
(package private) class |
PoolNetwork.WatchDog |
Network.NetworkAverageLoadTask
Modifier and Type | Field and Description |
---|---|
(package private) List<PoolNetwork.NetSession> |
activeSessions
Synchronized vector of active (i.e. connected) sessions.
|
(package private) boolean |
compressedFlows
Defines if the streams between servers are compressed or not.
|
(package private) int |
defaultMaxMessageInFlow
Defines the default value for maximum number of message sent and non
acknowledged on a connection.
|
(package private) PoolNetwork.Dispatcher |
dispatcher
Daemon sending message to others servers.
|
(package private) long |
IdleTimeout
Defines in milliseconds the maximum idle period permitted before reseting
the connection.
|
static byte[] |
magic
Magic number to identify peer.
|
(package private) int |
nbMaxCnx
Defines the maximum number of concurrent connected sessions.
|
(package private) PoolNetwork.NetSession[] |
sessions
Components handling communication with other servers.
|
(package private) PoolNetwork.WakeOnConnection |
wakeOnConnection
Daemon listening for connection from other servers.
|
(package private) PoolNetwork.WatchDog |
watchDog
Daemon handling the messages for inaccessible servers.
|
backlog, CnxRetry, ConnectTimeout, inLocalAddr, outLocalAddr, outLocalPort, serverSocketFactory, socketFactory, SoLinger, SoTimeout, TcpNoDelay
ALREADY_DELIVERED, averageLoadTask, bootTSFN, DELIVER, domain, idxLS, logmon, name, nbMessageIn, nbMessageOut, port, qout, servers, serversFN, sid, WDActivationPeriod, WDNbRetryLevel1, WDNbRetryLevel2, WDRetryPeriod1, WDRetryPeriod2, WDRetryPeriod3
Constructor and Description |
---|
PoolNetwork()
Creates a new network component.
|
Modifier and Type | Method and Description |
---|---|
void |
addServer(short id)
Adds the server sid in the network configuration.
|
void |
delServer(short id)
Removes the server sid in the network configuration.
|
boolean |
getCompressedFlows()
Returns if the stream between servers are compressed or not.
|
long |
getIdleTimeout()
Returns the maximum idle period permitted before reseting the connection.
|
(package private) long |
getLastReceived(short sid)
Returns the time in milliseconds of last message received.
|
(package private) int |
getMaxMessageInFlow(short sid)
Gets the maximum number of message sent and non acknowledged.
|
private String |
getMBeanName(short sid) |
(package private) int |
getNbAckSent(short sid)
Returns the number of acknowledge sent since last reboot.
|
int |
getNbActiveSession()
Returns the number of currently connected sessions.
|
(package private) int |
getNbBufferingMessageToSent(short sid)
Returns the number of buffering messages to sent since last reboot.
|
int |
getNbMaxActiveSession()
Returns the maximum number of concurrent connected sessions.
|
(package private) int |
getNbMessageReceived(short sid)
Returns the number of messages received since last reboot.
|
(package private) int |
getNbMessageSent(short sid)
Returns the number of messages sent since last reboot.
|
int |
getNbWaitingMessages()
Gets the number of waiting messages in this engine.
|
(package private) PoolNetwork.NetSession |
getSession(short sid)
Returns the NetSession component handling the communication with the
remote server that id is passed in parameter.
|
(package private) int |
getSessionNbWaitingMessages(short sid)
Gets the number of waiting messages to send for this session.
|
void |
init(String name,
int port,
short[] servers)
Initializes a new network component.
|
boolean |
isRunning()
Tests if the network component is alive.
|
(package private) boolean |
isSessionRunning(short sid)
Tests if the session is connected.
|
(package private) int |
readAck(InputStream in) |
(package private) PoolNetwork.Boot |
readBoot(InputStream in) |
(package private) void |
readFully(InputStream is,
byte[] iobuf) |
void |
setIdleTimeout(long idleTimeout)
Sets the maximum idle period permitted before reseting the connection.
|
(package private) void |
setMaxMessageInFlow(short sid,
int maxMessageInFlow)
Sets the maximum number of message sent and non acknowledged.
|
void |
setProperties()
Set the properties of the network.
|
void |
start()
Causes this network component to begin execution.
|
void |
stop()
Forces the network component to stop executing.
|
String |
toString()
Returns a string representation of this consumer, including the
daemon's name and status.
|
void |
wakeup()
Wakes up the watch-dog thread.
|
(package private) void |
writeAck(OutputStream out) |
(package private) void |
writeBoot(OutputStream out) |
createServerSocket, createServerSocket, createSocket, createSocket, createSocket, setSocketOption
delete, deliver, getAverageLoad1, getAverageLoad15, getAverageLoad5, getBootTS, getDomainName, getName, getNbMessageReceived, getNbMessageSent, getPort, getQueue, getStamp, getWDActivationPeriod, getWDNbRetryLevel1, getWDNbRetryLevel2, getWDRetryPeriod1, getWDRetryPeriod2, getWDRetryPeriod3, index, insert, post, postAndValidate, resetServer, restore, save, setPort, setStamp, setWDActivationPeriod, setWDNbRetryLevel1, setWDNbRetryLevel2, setWDRetryPeriod1, setWDRetryPeriod2, setWDRetryPeriod3, testBootTS, validate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAverageLoad1, getAverageLoad15, getAverageLoad5, getName, getNbMessageReceived, getNbMessageSent, getWDActivationPeriod, getWDNbRetryLevel1, getWDNbRetryLevel2, getWDRetryPeriod1, getWDRetryPeriod2, getWDRetryPeriod3, setWDActivationPeriod, setWDNbRetryLevel1, setWDNbRetryLevel2, setWDRetryPeriod1, setWDRetryPeriod2, setWDRetryPeriod3
public static final byte[] magic
PoolNetwork.WakeOnConnection wakeOnConnection
PoolNetwork.NetSession[] sessions
PoolNetwork.Dispatcher dispatcher
PoolNetwork.WatchDog watchDog
List<PoolNetwork.NetSession> activeSessions
boolean compressedFlows
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.compressedFlows
global property or for a
particular network by setting \
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
int nbMaxCnx
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.nbMaxCnx
global property or for a particular
network by setting \
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
long IdleTimeout
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.IdleTimeout
global property or for a particular
network by setting \
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
int defaultMaxMessageInFlow
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
For a particular network the value can be defined finely for a the connection
with a particular remote server by setting
Theses properties can be fixed either from PoolNetwork.maxMessageInFlow
global property or for a particular
network by setting \PoolNetwork.maxMessageInFlow_N
or \java
launching
command, or in a3servers.xml
configuration file.
public boolean getCompressedFlows()
getCompressedFlows
in interface PoolNetworkMBean
public int getNbMaxActiveSession()
getNbMaxActiveSession
in interface PoolNetworkMBean
public int getNbActiveSession()
getNbActiveSession
in interface PoolNetworkMBean
public long getIdleTimeout()
getIdleTimeout
in interface PoolNetworkMBean
public void setIdleTimeout(long idleTimeout)
setIdleTimeout
in interface PoolNetworkMBean
the
- maximum idle period permitted before reseting the connection.public void init(String name, int port, short[] servers) throws Exception
Class.newInstance()
method for create
(without any parameter) the component, then we can initialize it with
this method.init
in class StreamNetwork
name
- The domain name.port
- The listen port.servers
- The list of servers directly accessible from this
network interface.Exception
Network
public void setProperties() throws Exception
setProperties
in class StreamNetwork
Exception
public void addServer(short id) throws Exception
public void delServer(short id) throws Exception
private String getMBeanName(short sid)
public void start() throws Exception
start
in interface MessageConsumer
start
in interface NetworkMBean
Exception
stop
public void wakeup()
public void stop()
stop
in interface MessageConsumer
stop
in interface NetworkMBean
start
public boolean isRunning()
isRunning
in interface MessageConsumer
isRunning
in interface NetworkMBean
MessageConsumer
is alive; false
otherwise.final PoolNetwork.NetSession getSession(short sid) throws UnknownServerException
sid
- the server id of remote server.UnknownServerException
final boolean isSessionRunning(short sid)
sid
- the server id of remote server.final int getMaxMessageInFlow(short sid)
sid
- the server id of remote server.void setMaxMessageInFlow(short sid, int maxMessageInFlow)
sid
- the server id of remote server.maxMessageInFlow
- the maximum number of message sent and non acknowledged.final int getSessionNbWaitingMessages(short sid)
sid
- the server id of remote server.final int getNbMessageSent(short sid)
sid
- the server id of remote server.final int getNbMessageReceived(short sid)
sid
- the server id of remote server.final int getNbAckSent(short sid)
sid
- the server id of remote server.final long getLastReceived(short sid)
sid
- the server id of remote server.final int getNbBufferingMessageToSent(short sid)
sid
- the server id of remote server.public int getNbWaitingMessages()
getNbWaitingMessages
in interface NetworkMBean
getNbWaitingMessages
in class Network
public String toString()
toString
in interface NetworkMBean
toString
in class Network
final void writeBoot(OutputStream out) throws IOException
IOException
final void readFully(InputStream is, byte[] iobuf) throws IOException
IOException
final PoolNetwork.Boot readBoot(InputStream in) throws IOException
IOException
final void writeAck(OutputStream out) throws IOException
IOException
final int readAck(InputStream in) throws IOException
IOException
Copyright © 2013 ScalAgent D.T.. All Rights Reserved.