The
AgentServer
class manages the global configuration
of an agent server. It reads the configuration file, then it creates
and configure
Engine
,
Channel
,
Network
s
.
This class contains the main method for AgentServer, for example to
acivate a server you have to run this class with two parameters: the
server id. and the path of the root of persistancy. You can also use
a specialized main calling methods initi and start.
To start the agents server an XML configuration file describing the
architecture of the agent platform is needed. By default, this file is
the a3servers.xml file and it should be located inside the running
directory where the server is launched. Each server must use the same
configuration file.
The configuration file contains a
config
element, that
is essentially made up of
domain
s elements, and servers
(
server
s elements):
- Each domain of the configuration is described by an XML element with
attributes giving the name and the classname for
Network
implementation (class SingleCnxNetwork
by default).
- Each server is described by an XML element with attributes giving
the id, the name (optional) and the node (the
hostname
attribute describes the name or the IP address of this node)
- Each persistent server must be part of a domain (at least one), to
do this you need to define a
network
element with attributes
giving the domain's name (domain
attribute) and the
communication port (port
attribute).
- A service can be declared on any of these servers by inserting a
service
element describing it.
Additonnaly, you can define property for the global configuration
or for a particular server, it depends where you define it: in the
config
element or in a server one.
Each server that is part of two domains is named a "router", be careful,
it should have only one route between two domains. If it is not true the
configuration failed.
A simple example of a3servers.xml follows:
<?xml version="1.0"?>
<!DOCTYPE config SYSTEM "a3config.dtd">
<config>
<domain name="D1"/>
<domain name="D2" class="fr.dyade.aaa.agent.PoolCnxNetwork"/>
<property name="D2.nbMaxCnx" value="1"\>
<server id="0" name="S0" hostname="acores">
<network domain="D1" port="16300"/>
<service class=\"fr.dyade.aaa.ns.NameService\" args=\"\"/>
<property name="A3DEBUG_PROXY" value="true"\>
</server>
<server id="2" name="S2" hostname="bermudes">
<network domain="D1" port="16310"/>
<network domain="D2" port="16312"/>
</server>
<server id="3" name="S3" hostname="baleares">
<network domain="D2" port="16320"/>
</server>
</config>
This file described a 2 domains configuration D1 and D2, D1 with default
network protocol and D2 with the PoolCnxNetwork
one, and 4
servers:
- The first server (id 0 and name "S0") is hosted by acores, it is
in domain D1, and listen on port 16300. It defines a service and a
property.
- The second server (id 2) is hosted by bermudes and it is the router
between D1 and D2.
- The last server is a persistent one, it is hosted on baleares and it
runs in domain D2.
At the beginning of the file, there is a global property that defines
the maximum number of connection handled by each server of domain D2.
A3CMLWRP_PROPERTY
public static final String A3CMLWRP_PROPERTY
ADMIN_DOMAIN
public static final String ADMIN_DOMAIN
ADMIN_SERVER
public static final String ADMIN_SERVER
CFG_DIR_PROPERTY
public static final String CFG_DIR_PROPERTY
CFG_FILE_PROPERTY
public static final String CFG_FILE_PROPERTY
CFG_NAME_PROPERTY
public static final String CFG_NAME_PROPERTY
DEFAULT_A3CMLWRP
public static final String DEFAULT_A3CMLWRP
DEFAULT_CFG_DIR
public static final String DEFAULT_CFG_DIR
DEFAULT_CFG_FILE
public static final String DEFAULT_CFG_FILE
DEFAULT_CFG_NAME
public static final String DEFAULT_CFG_NAME
DEFAULT_SER_CFG_FILE
public static final String DEFAULT_SER_CFG_FILE
ENDSTRING
public static final String ENDSTRING
ERRORSTRING
public static final String ERRORSTRING
NULL_ID
public static final short NULL_ID
- -1
OKSTRING
public static final String OKSTRING
elementsServerDesc
public static Enumeration elementsServerDesc()
throws Exception
getAppConfig
public static A3CMLConfig getAppConfig(String[] domains)
throws Exception
Gets configuration of agent servers for a domain from the current
A3CMLConfig object. This method fills the object graph configuration
in a A3CMLConfig
object.
domains
- list of domain's names
- a
A3CMLConfig
object.
getConfig
public static final A3CMLConfig getConfig()
throws Exception
Returns the agent server configuration.
- agent server configuration (A3CMLConfig)
getEngine
public static fr.dyade.aaa.agent.Engine getEngine()
getHostname
public static final String getHostname(short sid)
throws UnknownServerException
Get the host name of an agent server.
- server host name as declared in configuration file
getInteger
public static Integer getInteger(String key)
Determines the integer value of the server property with the
specified name.
key
- property name.
- the Integer value of the property.
java.lang.Integer.getInteger
getInteger
public static Integer getInteger(String key,
int value)
Determines the integer value of the server property with the
specified name.
key
- property name.value
- a default value.
- the Integer value of the property.
java.lang.Integer.getInteger
getName
public static final String getName()
getProperty
public static String getProperty(String key)
Searches for the property with the specified key in the server property
list.
key
- the hashtable key.
- the value with the specified key value.
getProperty
public static String getProperty(String key,
String value)
Searches for the property with the specified key in the server property
list.
key
- the hashtable key.value
- a default value.
- the value with the specified key value.
getServerId
public static final short getServerId()
getServerIdByName
public static short getServerIdByName(String name)
throws Exception
Returns the identifier of the agent server which name is specified.
name
- the name of the agent server
- the identifier of the agent server
getServersIds
public static Enumeration getServersIds()
getServiceArgs
public static final String getServiceArgs(String hostname,
String classname)
throws Exception
Get the argument strings for a particular service running on a server
identified by its host.
The information provides from the A3 configuration file, so it's
only available if this file contains service's informations for all
nodes.
hostname
- hostnameclassname
- the service class name
- the arguments as declared in configuration file
A3CMLConfig.getServiceArgs(String,String)
getServiceArgs
public static final String getServiceArgs(short sid,
String classname)
throws Exception
Get the argument strings for a particular service.
The information provides from the A3 configuration file, so it's
only available if this file contains service's informations for all
nodes.
classname
- the service class name
- the arguments as declared in configuration file
A3CMLConfig.getServiceArgs(short,String)
getStatus
public static int getStatus()
getStatusInfo
public static String getStatusInfo()
getThreadGroup
public static ThreadGroup getThreadGroup()
getTransaction
public static Transaction getTransaction()
Returns the agent server transaction context.
init
public static int init(args[] )
throws Exception
Parses agent server arguments, then initializes this agent server. The
start
function is then called to start this agent server
execution. Between the init
and start calls,
agents may be created and deployed, and notifications may be sent using
the Channel
sendTo
function.
- number of arguments consumed in args
init
public static void init(short sid,
String path,
LoggerFactory loggerFactory)
throws Exception
Initializes this agent server.
start
function is then called to start this agent server
execution. Between the init
and start calls,
agents may be created and deployed, and notifications may be sent using
the Channel
sendTo
function.
sid
- the server idpath
- the persistency directory.loggerFactory
- the monolog LoggerFactory;
main
public static void main(args[] )
throws Exception
Main for a standard agent server.
The start arguments include in first position the identifier of the
agent server to start, and in second position the directory name where
the agent server stores its persistent data.
setConfig
public static final void setConfig(A3CMLConfig a3config)
throws Exception
Set the agent server configuration. Be careful, this method cannot
be called after initialization.
a3config
- A3CMLConfig
start
public static String start()
throws Exception
Causes this AgentServer to begin its execution. This method starts all
MessageConsumer
(i.e. the engine and the network components).
stop
public static void stop()
Forces this AgentServer to stop executing. This method stops all
consumers and services. Be careful, the stop process is now synchronous
and wait for all server's thread to terminate ; If this method is called
from a server's thread it should result a dead-lock.
stop
public static void stop(boolean sync)
Forces this AgentServer to stop executing. This method stops all
consumers and services. Be careful, if you specify a synchronous
process, this method wait for all server's thread to terminate; so
if this method is called from a server's thread it should result a
dead-lock.
sync
- If true the stop is precessed synchronous, otherwise
a thread is created and the method returns.