public abstract class Network extends Object implements MessageConsumer, NetworkMBean
Network
abstract class provides ..Modifier and Type | Class and Description |
---|---|
(package private) class |
Network.NetworkAverageLoadTask |
Modifier and Type | Field and Description |
---|---|
protected static int |
ALREADY_DELIVERED
The message has already been delivered.
|
(package private) Network.NetworkAverageLoadTask |
averageLoadTask |
private int[] |
bootTS |
protected String |
bootTSFN
Filename for boot time stamp storage.
|
protected static int |
DELIVER
The message can be delivered.
|
protected String |
domain
The domain name.
|
protected int |
idxLS
Index of local server in status and matrix arrays.
|
protected org.objectweb.util.monolog.api.Logger |
logmon |
protected String |
name
The component's name as it appears in logging.
|
protected int |
nbMessageIn |
protected int |
nbMessageOut |
protected int |
port
The communication port.
|
protected MessageVector |
qout
The
MessageVector associated with this network component. |
protected short[] |
servers
List of id. for all servers in the domain, this list is sorted and
is used as index for internal tables.
|
protected String |
serversFN
Filename for servers storage.
|
protected short |
sid
Id. of local server.
|
private int[] |
stamp
Logical timestamp information for messages in domain, stamp[idxLS)]
for messages sent, and stamp[index(id] for messages received.
|
private byte[] |
stampbuf
Buffer used to optimize transactions.
|
(package private) long |
WDActivationPeriod
Period of time in ms between two activations of watch-dog thread,
default value is 1000L (1 second).
|
(package private) int |
WDNbRetryLevel1
Number of try at stage 1, default value is 5.
|
(package private) int |
WDNbRetryLevel2
Number of try at stage 2, default value is 30.
|
(package private) long |
WDRetryPeriod1
Period of time in ms between two connection try at stage 1, default
value is WDActivationPeriod.
|
(package private) long |
WDRetryPeriod2
Period of time in ms between two connection try at stage 2, default
value is 10000L (10 seconds).
|
(package private) long |
WDRetryPeriod3
Period of time in ms between two connection try at stage 3, default
value is 60000L (1 minute).
|
Constructor and Description |
---|
Network()
Creates a new network component.
|
Modifier and Type | Method and Description |
---|---|
void |
addServer(short id)
Adds the server sid in the network configuration.
|
protected void |
channelPostAndValidate(Message msg) |
protected void |
checkActive(ServerDesc desc) |
void |
delete()
Deletes the component, removes all persistent data.
|
protected void |
deleteMessage(Message msg) |
protected void |
deliver(Message msg)
Try to deliver the received message to the right consumer.
|
void |
delServer(short id)
Removes the server sid in the network configuration.
|
float |
getAverageLoad1()
Returns the load averages for the last minute.
|
float |
getAverageLoad15()
Returns the load averages for the past 15 minutes.
|
float |
getAverageLoad5()
Returns the load averages for the past 5 minutes.
|
(package private) int |
getBootTS() |
String |
getDomainName()
Returns the corresponding domain's name.
|
protected short |
getMessageDest(Message msg) |
protected short |
getMessageSource(Message msg) |
String |
getName()
Returns this session's name.
|
int |
getNbMessageReceived()
Returns the number of messages received since last reboot.
|
int |
getNbMessageSent()
Returns the number of messages sent since last reboot.
|
int |
getNbWaitingMessages()
Gets the number of waiting messages in this engine.
|
int |
getPort() |
MessageQueue |
getQueue()
Get this consumer's
MessageQueue . |
private int |
getSendUpdate(short to)
Computes the matrix clock of a send message.
|
protected byte[] |
getStamp() |
long |
getWDActivationPeriod()
Gets the WDActivationPeriod value.
|
int |
getWDNbRetryLevel1()
Gets the WDNbRetryLevel1 value.
|
int |
getWDNbRetryLevel2()
Gets the WDNbRetryLevel2 value.
|
long |
getWDRetryPeriod1()
Gets the WDRetryPeriod1 value.
|
long |
getWDRetryPeriod2()
Gets the WDRetryPeriod2 value.
|
long |
getWDRetryPeriod3()
Gets the WDRetryPeriod3 value.
|
protected int |
index(short id)
Returns the index in internal table of the specified server.
|
void |
init(String name,
int port,
short[] servers)
Initializes a new network component.
|
void |
insert(Message msg)
Insert a message in the
MessageQueue . |
void |
post(Message msg)
Adds a message in "ready to deliver" list.
|
void |
postAndValidate(Message msg)
Posts and validates a message.
|
protected void |
postMessage(Message msg) |
protected void |
prepareMessage(Message msg) |
protected void |
prepareMessageWithoutStamp(Message msg) |
(package private) void |
resetServer(short id,
int boot)
Reset all information related to server sid in the network configuration.
|
void |
restore()
Restores component's information from persistent storage.
|
void |
save()
Saves information to persistent storage.
|
protected void |
saveChannel() |
protected void |
setMessageSource(Message msg,
short source) |
void |
setPort(int port)
Updates the network port.
|
void |
setProperties()
Set the properties of the network.
|
protected void |
setStamp(byte[] stampbuf) |
void |
setWDActivationPeriod(long WDActivationPeriod)
Sets the WDActivationPeriod value.
|
void |
setWDNbRetryLevel1(int WDNbRetryLevel1)
Sets the WDNbRetryLevel1 value.
|
void |
setWDNbRetryLevel2(int WDNbRetryLevel2)
Sets the WDNbRetryLevel2 value.
|
void |
setWDRetryPeriod1(long WDRetryPeriod1)
Sets the WDRetryPeriod1 value.
|
void |
setWDRetryPeriod2(long WDRetryPeriod2)
Sets the WDRetryPeriod2 value.
|
void |
setWDRetryPeriod3(long WDRetryPeriod3)
Sets the WDRetryPeriod3 value.
|
(package private) void |
testBootTS(short source,
int boot) |
protected int |
testRecvUpdate(short source,
int update)
Test if a received message with the specified clock must be
delivered.
|
String |
toString()
Returns a string representation of this consumer.
|
private void |
updateStamp(int idx,
int update) |
void |
validate()
Validates all messages pushed in queue during transaction session.
|
protected void |
validateChannel() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isRunning, start, stop
isRunning, start, stop
long WDActivationPeriod
WDActivationPeriod
global property or for a particular
network by setting \.WDActivationPeriod
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
int WDNbRetryLevel1
WDNbRetryLevel1
global property or for a particular
network by setting \.WDNbRetryLevel1
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
long WDRetryPeriod1
WDRetryPeriod1
global property or for a particular
network by setting \.WDRetryPeriod1
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
Be careful, in most Network components setting this value to a value less than WDActivationPeriod is useless. In the same way, the real try period is depending of the connection timeout.
int WDNbRetryLevel2
WDNbRetryLevel2
global property or for a particular
network by setting \.WDNbRetryLevel2
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
long WDRetryPeriod2
WDRetryPeriod2
global property or for a particular
network by setting \.WDRetryPeriod2
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
Be careful, in most Network components setting this value to a value less than WDActivationPeriod is useless. In the same way, the real try period is depending of the connection timeout.
long WDRetryPeriod3
WDRetryPeriod3
global property or for a particular
network by setting \.WDRetryPeriod3
specific property.
Theses properties can be fixed either from java
launching
command, or in a3servers.xml
configuration file.
Be careful, in most Network components setting this value to a value less than WDActivationPeriod is useless. In the same way, the real try period is depending of the connection timeout.
protected int nbMessageOut
protected int nbMessageIn
protected org.objectweb.util.monolog.api.Logger logmon
protected short sid
protected int idxLS
protected short[] servers
protected transient String serversFN
private int[] stamp
private byte[] stampbuf
private int[] bootTS
protected transient String bootTSFN
protected String name
protected String domain
protected int port
protected MessageVector qout
MessageVector
associated with this network component.protected static final int DELIVER
protected static final int ALREADY_DELIVERED
Network.NetworkAverageLoadTask averageLoadTask
public Network()
Class.newInstance()
method during configuration.
The configuration of component is then done by init
method.public long getWDActivationPeriod()
getWDActivationPeriod
in interface NetworkMBean
public void setWDActivationPeriod(long WDActivationPeriod)
setWDActivationPeriod
in interface NetworkMBean
WDActivationPeriod
- the WDActivationPeriod valuepublic int getWDNbRetryLevel1()
getWDNbRetryLevel1
in interface NetworkMBean
public void setWDNbRetryLevel1(int WDNbRetryLevel1)
setWDNbRetryLevel1
in interface NetworkMBean
WDNbRetryLevel1
- the WDNbRetryLevel1 valuepublic long getWDRetryPeriod1()
getWDRetryPeriod1
in interface NetworkMBean
public void setWDRetryPeriod1(long WDRetryPeriod1)
setWDRetryPeriod1
in interface NetworkMBean
WDRetryPeriod1
- the WDRetryPeriod1 valuepublic int getWDNbRetryLevel2()
getWDNbRetryLevel2
in interface NetworkMBean
public void setWDNbRetryLevel2(int WDNbRetryLevel2)
setWDNbRetryLevel2
in interface NetworkMBean
WDNbRetryLevel2
- the WDNbRetryLevel2 valuepublic long getWDRetryPeriod2()
getWDRetryPeriod2
in interface NetworkMBean
public void setWDRetryPeriod2(long WDRetryPeriod2)
setWDRetryPeriod2
in interface NetworkMBean
WDRetryPeriod2
- the WDRetryPeriod2 valuepublic long getWDRetryPeriod3()
getWDRetryPeriod3
in interface NetworkMBean
public void setWDRetryPeriod3(long WDRetryPeriod3)
setWDRetryPeriod3
in interface NetworkMBean
WDRetryPeriod3
- the WDRetryPeriod3 valuepublic int getNbWaitingMessages()
getNbWaitingMessages
in interface NetworkMBean
public int getNbMessageSent()
getNbMessageSent
in interface NetworkMBean
public int getNbMessageReceived()
getNbMessageReceived
in interface NetworkMBean
public final String getName()
getName
in interface MessageConsumer
getName
in interface NetworkMBean
public final String getDomainName()
getDomainName
in interface MessageConsumer
public String toString()
toString
in interface NetworkMBean
toString
in class Object
public void insert(Message msg)
MessageQueue
.
This method is used during initialization to restore the component
state from persistent storage.insert
in interface MessageConsumer
msg
- the messagepublic void save() throws IOException
save
in interface MessageConsumer
IOException
public void restore() throws Exception
restore
in interface MessageConsumer
Exception
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.name
- The domain name.port
- The listen port.servers
- The list of servers directly accessible from this
network interface.Exception
public void setProperties() throws Exception
Exception
public void addServer(short id) throws Exception
id
- the unique server id.Exception
public void delServer(short id) throws Exception
id
- the unique server id.Exception
void resetServer(short id, int boot) throws IOException
id
- the unique server id.IOException
public void post(Message msg) throws Exception
post
in interface MessageConsumer
Exception
public void postAndValidate(Message msg) throws Exception
postAndValidate
in interface MessageConsumer
Exception
protected final int index(short id)
id
- the unique server id.protected final byte[] getStamp()
protected final void setStamp(byte[] stampbuf)
private void updateStamp(int idx, int update) throws IOException
IOException
protected int testRecvUpdate(short source, int update) throws IOException
DELIVER
and the matrix clock is updated. If the message has
already been delivered, the method returns ALREADY_DELIVERED
,
and if other messages are waited before this message the method returns
WAIT_TO_DELIVER
. In the last two case the matrix clock
remains unchanged.update
- The message matrix clock (list of update).DELIVER
, ALREADY_DELIVERED
,
or WAIT_TO_DELIVER
code.IOException
private int getSendUpdate(short to) throws IOException
to
- The identification of receiver.IOException
final int getBootTS()
final void testBootTS(short source, int boot) throws IOException
IOException
protected void deliver(Message msg) throws Exception
msg
- the message.Exception
public void delete() throws IllegalStateException
delete
in interface MessageConsumer
IllegalStateException
Transaction
public void validate()
validate
in interface MessageConsumer
public MessageQueue getQueue()
MessageConsumer
MessageQueue
. Use in administration and
debug tasks, should be replaced by a common attribute.getQueue
in interface MessageConsumer
MessageConsumer
's queue.public void setPort(int port)
public final int getPort()
public float getAverageLoad1()
getAverageLoad1
in interface MessageConsumer
getAverageLoad1
in interface NetworkMBean
public float getAverageLoad5()
getAverageLoad5
in interface MessageConsumer
getAverageLoad5
in interface NetworkMBean
public float getAverageLoad15()
getAverageLoad15
in interface MessageConsumer
getAverageLoad15
in interface NetworkMBean
protected void deleteMessage(Message msg)
protected short getMessageSource(Message msg)
protected void setMessageSource(Message msg, short source)
protected short getMessageDest(Message msg)
protected void checkActive(ServerDesc desc)
protected void channelPostAndValidate(Message msg) throws Exception
Exception
protected void validateChannel()
Copyright © 2018 ScalAgent D.T.. All Rights Reserved.