Class AgentServer
- java.lang.Object
-
- fr.dyade.aaa.agent.AgentServer
-
public final class AgentServer extends Object
TheAgentServerclass manages the global configuration of an agent server. It reads the configuration file, then it creates and configureEngine,ChannelandNetworkcomponents. This class contains the main method for AgentServer, for example to activate a server you have to run this class with two parameters: the server id. and the path of the root of persistency. You can also use a specialized main calling methods init 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
configelement, that is essentially made up ofdomains elements, and servers (servers elements):- Each domain of the configuration is described by an XML element with
attributes giving the name and the classname for
Networkimplementation (classSimpleNetworkby default). - Each server is described by an XML element with attributes giving
the id, the name (optional) and the node (the
hostnameattribute 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
networkelement with attributes giving the domain's name (domainattribute) and the communication port (portattribute). - A service can be declared on any of these servers by inserting a
serviceelement describing it.
- Each persistent server must be part of a domain (at least one), to
do this you need to define a
- Additionally, you can define property for the global configuration
or for a particular server, it depends where you define it: in the
configelement or in a server one.
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.PoolNetwork"/> <property name="D2.nbMaxCnx" value="1"/> <server id="0" name="S0" hostname="acores"> <network domain="D1" port="16300"/> <service class="fr.dyade.aaa.agent.AdminProxy" args="8090"/> <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
PoolNetworkone, 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.
- See Also:
Engine,Channel,Network,MessageQueue,Transaction
- Each domain of the configuration is described by an XML element with
attributes giving the name and the classname for
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classAgentServer.ServerStopperstatic classAgentServer.Status
-
Field Summary
Fields Modifier and Type Field Description static StringA3CMLWRP_PROPERTYName of property allowing to configure the XML wrapper used to read the server configuration.private static A3CMLConfiga3configStatic reference to the configuration.static AgentServerActivatoractivatorReference to OSGi root activator (bundle #0) if any.static StringADMIN_DOMAINstatic StringADMIN_SERVERstatic StringBACKUP_FILEName of the property defining the backup file to restore.static StringCFG_ADMINPWD_PROPERTYName of property allowing to configure the administrator password when using the default server configuration, by default it is the same that the administrator user name.static StringCFG_ADMINUID_PROPERTYName of property allowing to configure the administrator user name when using the default server configuration, by default "root".static StringCFG_CHECK_PERIOD_PROPERTYName of property allowing to configure the checking period of the server (in ms).static StringCFG_DIR_PROPERTYName of property allowing to configure the directory to search the XML server configuration.static StringCFG_EXIT_ON_SERVICE_FAILURE_PROPERTYName of the property specifying that the server should stop if any of the services can not start correctly.static StringCFG_FILE_PROPERTYName of property allowing to configure the filename of the XML server configuration.static intCFG_JMS_PORT_DFLTDefault value for JMS listening port: 16010.static StringCFG_JMS_PORT_PROPERTYName of property allowing to configure the listening port of the JMS server when using the default server configuration, by default CFG_JMS_PORT_DFLT.static intCFG_JNDI_PORT_DFLTDefault value for JNDI listening port: 16400.static StringCFG_JNDI_PORT_PROPERTYName of property allowing to configure the listening port of the JNDI server when using the default server configuration, by default CFG_JNDI_PORT_PROPERTY.static intCFG_MAX_JORAM_PORT_DFLTDefault value for maximum JMS listening port: 16100.static StringCFG_MAX_JORAM_PORT_PROPERTYName of property allowing to configure the maximum value for listening port of the JMS server when using the default server configuration with random port choice (if listening port is set to -3).static intCFG_MIN_JORAM_PORT_DFLTDefault value for minimum JMS listening port: 16000.static StringCFG_MIN_JORAM_PORT_PROPERTYName of property allowing to configure the minimum value for listening port of the JMS server when using the default server configuration with random port choice (if listening port is set to -3).static StringCFG_NAME_PROPERTY(package private) static CheckServerTaskcheckServerTaskprivate static Hashtable<String,MessageConsumer>consumersStatic references to all messages consumers initialized in this agent server (includingEngine).private static booleanDEBUGstatic StringDEFAULT_A3CMLWRPDefault value of the XML wrapper used to read server configuration, this default value implies the use of the default SaxWrapper.static StringDEFAULT_BACKUP_FILEDefault name of the backup file to restore if it exists.static StringDEFAULT_CFG_DIRDefault value of the directory to search the XML server configuration, value is null.static StringDEFAULT_CFG_FILEDefault value of the filename of the XML server configuration, value isa3servers.xml.static StringDEFAULT_CFG_NAMEstatic StringDEFAULT_SER_CFG_FILEDefault value of the filename of the serialized server configuration in the persistence directory, value isa3cmlconfig.static StringDEFAULT_USE_DEFAULT_CONFIGDefault value for the USE_DEFAULT_CONFIG property.static StringdefaultConfigDefault configuration used if no other configuration is found, by default empty.static intDFTLT_MAX_THREAD_WAIT_BEFORE_EXITstatic intENCODABLE_CLASS_ID_AREAstatic StringENDSTRING(package private) static AgentEngineengineStatic reference to the engine.static StringERRORSTRINGprivate static Loggerloggerstatic StringMAX_THREAD_WAIT_BEFFORE_EXIT_PROPERTYName of property allowing to configure the maximum duration of the wait in seconds allowing the child threads of the AgentServer to terminate during shutdown.static StringMAX_THREAD_WAIT_BEFORE_EXIT_PROPERTYstatic intMESSAGE_CLASS_IDprivate static Stringnamestatic shortNULL_IDstatic StringOKSTRINGprivate static Randomrandprivate static shortserverId(package private) static ServerLockserverLockStatic reference to the AgentServer file lockprivate static ServersHTserversStatic description of all known agent servers in ascending order.static longstartDateprivate static AgentServer.Statusstatus(package private) static ThreadGrouptgroupprivate static TimertimerTimer provided by the agent server.(package private) static TransactiontransactionStatic reference to the transactional monitor.static StringUPDATE_CONF_TX_NAMEName of the transaction object indicating that the configuration object has been updated in the transaction base.static ServerUpdateupdatecfgObject indicating that the configuration object has been updated in the transaction base (see UpdateConfTxName).static StringUSE_DEFAULT_CONFIG_PROPERTYName of property allowing to use a default configuration when no configuration file can be found.
-
Constructor Summary
Constructors Constructor Description AgentServer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddConsumer(String domain, MessageConsumer cons)static voidaddServerDesc(ServerDesc desc)private static voidconfigure()The second step of initialization.private static voidcreateConsumers(A3CMLServer root)private static ServerDesccreateServerDesc(A3CMLServer server)static Enumeration<ServerDesc>elementsServerDesc()static voidexternalBackup(String serverDataDirPath, String backupDir)Backup the transactional persistencestatic voidexternalUpdateConfFromFile(String serverConfigFilePath, String serverDataDirPath)Updates the stored configuration of an external server from a filestatic voidexternalUpdateConfFromString(String serverConfig, String serverDataDirPath)Updates the stored configuration of an external server from a Stringstatic A3CMLConfiggetAppConfig(String[] domains)Gets configuration of agent servers for a domain from the current A3CMLConfig object.static booleangetBoolean(String key)Determines the boolean value of the server property with the specified name.static booleangetBoolean(String key, boolean dflt)static longgetCommitTime()Return the total agent commit time.static A3CMLConfiggetConfFromFile(String serverConfigFilePath)Gets the AgentServer configuration from a file.static A3CMLConfiggetConfFromString(String serverConfig)Gets the AgentServer configuration from the String parameter.static A3CMLConfiggetConfig()Returns the agent server configuration.(package private) static MessageConsumergetConsumer(short sid)Gets the message consumer for the corresponding server.static MessageConsumergetConsumer(String domain)(package private) static Enumeration<MessageConsumer>getConsumers()static AgentEnginegetEngine()Returns the agent server engine.static floatgetEngineAverageLoad1()Returns the load averages for the last minute.static floatgetEngineAverageLoad15()Returns the load averages for the past 15 minutes.static floatgetEngineAverageLoad5()Returns the load averages for the past 5 minutes.static intgetEngineLoad()Returns the immediate engine load.static StringgetHostname(short sid)Get the host name of an agent server.static IntegergetInteger(String key)Determines the integer value of the server property with the specified name.static IntegergetInteger(String key, int value)Determines the integer value of the server property with the specified name.static LonggetLong(String key)Determines the integer value of the server property with the specified name.static LonggetLong(String key, long value)Determines the long value of the server property with the specified name.static StringgetName()static StringgetProperty(String key)Searches for the property with the specified key in the server property list.static StringgetProperty(String key, String value)Searches for the property with the specified key in the server property list.static longgetReactTime()Return the total agent reaction time.static ServerDescgetServerDesc(short sid)Gets the characteristics of the corresponding server.static shortgetServerId()static shortgetServerIdByName(String name)Returns the identifier of the agent server which name is specified.static StringgetServerName()(package private) static intgetServerNb()Gets the number of server known on the current server.static Enumeration<Short>getServersIds()static StringgetServiceArgs(short sid, String classname)Get the argument strings for a particular service.static StringgetServiceArgs(String hostname, String classname)Get the argument strings for a particular service running on a server identified by its host.(package private) static ServiceDesc[]getServices()Get the description of all services of the current agent server.static intgetStatus()static StringgetStatusInfo()static ThreadGroupgetThreadGroup()static TimergetTimer()Returns a shared timer provided by the agent server.static TransactiongetTransaction()Returns the agent server transaction context.static TransactiongetTransaction(String serverDataDirPath)Gets the Transaction component from an existing transactional persistence.static voidinit(short sid, String serverDataDirPath, boolean update, LoggingFactory loggerFactory)static voidinit(short sid, String path, LoggingFactory loggerFactory)Initializes this agent server.static intinit(String[] args)Parses agent server arguments, then initializes this agent server.static voidinitServerDesc(ServerDesc desc, A3CMLServer server)private static voidinitServices(A3CMLServer server, ServerDesc desc)static booleanisAgentProfiling()Returns true if the agent profiling is on.static booleanisEngineThread()static ServerLocklockAgentServer(String serverDataDirPath)Try to lock the AgentServer lock file.private static ServerLocklockAgentServer(String serverDataDirPath, boolean createDataDir)Try to lock the AgentServer lock file.static voidmain(String[] args)Main for a standard agent server.static voidregisterCheckServerListener(CheckServerListener listener)static voidregisterFactories()static voidremoveConsumer(String domain)static ServerDescremoveServerDesc(short sid)static voidreset()Cleans an AgentServer configuration in order to restart it from persistent storage.static voidreset(boolean force)static voidresetEngineAverageLoad()static voidrestoreServer(String fname)Restores the server persistence from a backup file.static voidsetAgentProfiling(boolean agentProfiling)Sets the agent profiling.static voidsetConfig(A3CMLConfig a3config)Set the agent server configuration.static voidsetConfig(A3CMLConfig a3config, boolean force)static voidsetDefaultConfig(int sid)Set default configuration for the specified server.static voidsetDefaultConfig(int sid, String host, String adminuid, String adminpwd, int joram, int jndi)Set default configuration for the specified server.static voidsetDefaultConfig(int sid, String host, String adminuid, String adminpwd, int joram, int jndi, Properties props)Set default configuration for the specified server.static voidsetDefaultConfig(String config)private static voidsetProperties(short sid)(package private) static voidshutdown()static Stringstart()Causes this AgentServer to begin its execution.static voidstop()Forces this AgentServer to stop executing.static voidstop(boolean sync)Forces this AgentServer to stop executing.static voidstop(boolean sync, long delay, boolean reset)Forces this AgentServer to stop executing.static voidunregisterCheckServerListener(CheckServerListener listener)(package private) static voidupdateConf(A3CMLConfig a3cmlConfig, String serverDataDirPath)Updates the stored configuration
-
-
-
Field Detail
-
logger
private static final Logger logger
-
DEBUG
private static final boolean DEBUG
-
NULL_ID
public static final short NULL_ID
- See Also:
- Constant Field Values
-
ADMIN_DOMAIN
public static final String ADMIN_DOMAIN
- See Also:
- Constant Field Values
-
ADMIN_SERVER
public static final String ADMIN_SERVER
- See Also:
- Constant Field Values
-
ENCODABLE_CLASS_ID_AREA
public static final int ENCODABLE_CLASS_ID_AREA
- See Also:
- Constant Field Values
-
MESSAGE_CLASS_ID
public static final int MESSAGE_CLASS_ID
- See Also:
- Constant Field Values
-
UPDATE_CONF_TX_NAME
public static final String UPDATE_CONF_TX_NAME
Name of the transaction object indicating that the configuration object has been updated in the transaction base. This makes it possible to initialize the server in a slightly different way, for example reading anew the services list. Currently we simply consider the fact that the configuration has been modified, in the future this object could contain indications on the changes to be made.- See Also:
- Constant Field Values
-
BACKUP_FILE
public static final String BACKUP_FILE
Name of the property defining the backup file to restore. By default: "backup.tbck".- See Also:
- Constant Field Values
-
DEFAULT_BACKUP_FILE
public static final String DEFAULT_BACKUP_FILE
Default name of the backup file to restore if it exists. The restore operation is only done if the transaction doesn't exist.- See Also:
- Constant Field Values
-
updatecfg
public static ServerUpdate updatecfg
Object indicating that the configuration object has been updated in the transaction base (see UpdateConfTxName).
-
defaultConfig
public static String defaultConfig
Default configuration used if no other configuration is found, by default empty.
-
CFG_ADMINUID_PROPERTY
public static final String CFG_ADMINUID_PROPERTY
Name of property allowing to configure the administrator user name when using the default server configuration, by default "root". This Configuration is automatically generated at first starting if no XML configuration file is found.Be careful, this configuration is normally used only for the initial starting of the server, the configuration is then atomically maintained in the persistence directory.
This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
CFG_ADMINPWD_PROPERTY
public static final String CFG_ADMINPWD_PROPERTY
Name of property allowing to configure the administrator password when using the default server configuration, by default it is the same that the administrator user name. This Configuration is automatically generated at first starting if no XML configuration file is found.Be careful, this configuration is normally used only for the initial starting of the server, the configuration is then atomically maintained in the persistence directory.
This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
CFG_JMS_PORT_PROPERTY
public static final String CFG_JMS_PORT_PROPERTY
Name of property allowing to configure the listening port of the JMS server when using the default server configuration, by default CFG_JMS_PORT_DFLT. This Configuration is automatically generated at first starting if no XML configuration file is found.Be careful, this configuration is normally used only for the initial starting of the server, the configuration is then atomically maintained in the persistence directory.
This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
CFG_JMS_PORT_DFLT
public static final int CFG_JMS_PORT_DFLT
Default value for JMS listening port: 16010.- See Also:
- Constant Field Values
-
CFG_MIN_JORAM_PORT_PROPERTY
public static final String CFG_MIN_JORAM_PORT_PROPERTY
Name of property allowing to configure the minimum value for listening port of the JMS server when using the default server configuration with random port choice (if listening port is set to -3). By default this values is set to CFG_MIN_JORAM_PORT_DFLT.This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
CFG_MIN_JORAM_PORT_DFLT
public static final int CFG_MIN_JORAM_PORT_DFLT
Default value for minimum JMS listening port: 16000.- See Also:
- Constant Field Values
-
CFG_MAX_JORAM_PORT_PROPERTY
public static final String CFG_MAX_JORAM_PORT_PROPERTY
Name of property allowing to configure the maximum value for listening port of the JMS server when using the default server configuration with random port choice (if listening port is set to -3). By default this values is set to CFG_MAX_JORAM_PORT_DFLT.This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
CFG_MAX_JORAM_PORT_DFLT
public static final int CFG_MAX_JORAM_PORT_DFLT
Default value for maximum JMS listening port: 16100.- See Also:
- Constant Field Values
-
CFG_JNDI_PORT_PROPERTY
public static final String CFG_JNDI_PORT_PROPERTY
Name of property allowing to configure the listening port of the JNDI server when using the default server configuration, by default CFG_JNDI_PORT_PROPERTY. This Configuration is automatically generated at first starting if no XML configuration file is found.Be careful, this configuration is normally used only for the initial starting of the server, the configuration is then atomically maintained in the persistence directory.
This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
CFG_JNDI_PORT_DFLT
public static final int CFG_JNDI_PORT_DFLT
Default value for JNDI listening port: 16400.- See Also:
- Constant Field Values
-
rand
private static Random rand
-
serverId
private static short serverId
-
activator
public static AgentServerActivator activator
Reference to OSGi root activator (bundle #0) if any. It allows to stop the OSGi container if needed using "context.getBundle(0).stop()". Note (AF): This code creates a dependency to OSGi libraries, this can be annoying in the use of methods by external tools.
-
CFG_DIR_PROPERTY
public static final String CFG_DIR_PROPERTY
Name of property allowing to configure the directory to search the XML server configuration.Be careful, the XML server configuration file is normally used only for the initial starting of the server, the configuration is then atomically maintained in the persistence directory.
This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
DEFAULT_CFG_DIR
public static final String DEFAULT_CFG_DIR
Default value of the directory to search the XML server configuration, value is null.
-
CFG_FILE_PROPERTY
public static final String CFG_FILE_PROPERTY
Name of property allowing to configure the filename of the XML server configuration.Be careful, the XML server configuration file is normally used only for the initial starting of the server, the configuration is then atomically maintained in the persistence directory.
This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
DEFAULT_CFG_FILE
public static final String DEFAULT_CFG_FILE
Default value of the filename of the XML server configuration, value isa3servers.xml.- See Also:
- Constant Field Values
-
USE_DEFAULT_CONFIG_PROPERTY
public static final String USE_DEFAULT_CONFIG_PROPERTY
Name of property allowing to use a default configuration when no configuration file can be found.- See Also:
- Constant Field Values
-
DEFAULT_USE_DEFAULT_CONFIG
public static final String DEFAULT_USE_DEFAULT_CONFIG
Default value for the USE_DEFAULT_CONFIG property.- See Also:
- Constant Field Values
-
DEFAULT_SER_CFG_FILE
public static final String DEFAULT_SER_CFG_FILE
Default value of the filename of the serialized server configuration in the persistence directory, value isa3cmlconfig.Removing this file allows to load anew the XML configuration file at the next starting of the server. Be careful, doing this can generate incoherence in the global configuration.
- See Also:
- Constant Field Values
-
CFG_NAME_PROPERTY
public static final String CFG_NAME_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_CFG_NAME
public static final String DEFAULT_CFG_NAME
- See Also:
- Constant Field Values
-
A3CMLWRP_PROPERTY
public static final String A3CMLWRP_PROPERTY
Name of property allowing to configure the XML wrapper used to read the server configuration.This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
DEFAULT_A3CMLWRP
public static final String DEFAULT_A3CMLWRP
Default value of the XML wrapper used to read server configuration, this default value implies the use of the default SaxWrapper.- See Also:
- Constant Field Values
-
CFG_CHECK_PERIOD_PROPERTY
public static final String CFG_CHECK_PERIOD_PROPERTY
Name of property allowing to configure the checking period of the server (in ms). The corresponding value is the period of time beyond which an error is thrown and the registered listeners are called. The activation period is 5 times lower, this value cannot be less than 10s.This property can be fixed either from XML configuration file or Java launching command.
- See Also:
- Constant Field Values
-
checkServerTask
static CheckServerTask checkServerTask
-
tgroup
static ThreadGroup tgroup
-
engine
static AgentEngine engine
Static reference to the engine. Used inChannel.sendToto know if the method is called from a react or no.
-
serverLock
static ServerLock serverLock
Static reference to the AgentServer file lock
-
transaction
static Transaction transaction
Static reference to the transactional monitor.
-
consumers
private static Hashtable<String,MessageConsumer> consumers
Static references to all messages consumers initialized in this agent server (includingEngine).
-
timer
private static Timer timer
Timer provided by the agent server.
-
a3config
private static A3CMLConfig a3config
Static reference to the configuration.
-
name
private static String name
-
servers
private static ServersHT servers
Static description of all known agent servers in ascending order.
-
status
private static AgentServer.Status status
-
startDate
public static final long startDate
-
CFG_EXIT_ON_SERVICE_FAILURE_PROPERTY
public static final String CFG_EXIT_ON_SERVICE_FAILURE_PROPERTY
Name of the property specifying that the server should stop if any of the services can not start correctly. By default false.This property can be fixed either from XML configuration file or Java launching command.
- See Also:
- Constant Field Values
-
MAX_THREAD_WAIT_BEFFORE_EXIT_PROPERTY
public static final String MAX_THREAD_WAIT_BEFFORE_EXIT_PROPERTY
Name of property allowing to configure the maximum duration of the wait in seconds allowing the child threads of the AgentServer to terminate during shutdown. Once this time has elapsed, the transactional persistence module is stopped and the AgentServer terminates.By Default, 120, 2 minutes.
This property can only be fixed from
javalaunching command.- See Also:
- Constant Field Values
-
MAX_THREAD_WAIT_BEFORE_EXIT_PROPERTY
public static final String MAX_THREAD_WAIT_BEFORE_EXIT_PROPERTY
- See Also:
- Constant Field Values
-
DFTLT_MAX_THREAD_WAIT_BEFORE_EXIT
public static final int DFTLT_MAX_THREAD_WAIT_BEFORE_EXIT
- See Also:
- Constant Field Values
-
OKSTRING
public static final String OKSTRING
- See Also:
- Constant Field Values
-
ERRORSTRING
public static final String ERRORSTRING
- See Also:
- Constant Field Values
-
ENDSTRING
public static final String ENDSTRING
- See Also:
- Constant Field Values
-
-
Method Detail
-
registerFactories
public static final void registerFactories()
-
setDefaultConfig
public static void setDefaultConfig(int sid)
Set default configuration for the specified server.- Parameters:
sid- the server identifier.
-
setDefaultConfig
public static void setDefaultConfig(int sid, String host, String adminuid, String adminpwd, int joram, int jndi)Set default configuration for the specified server.- Parameters:
sid- the server identifier.host- the hostname (or IP adress) hosting the severadminuid- the administration loginadminpwd- the administration passwordjoram- the JMS TCP connector portjndi- the JNDI TCP port
-
setDefaultConfig
public static void setDefaultConfig(int sid, String host, String adminuid, String adminpwd, int joram, int jndi, Properties props)Set default configuration for the specified server.- Parameters:
sid- Unique identifier of the server.host- Host name or IP address of the physical machine.adminuid- User name of the administrator.adminpwd- Password of the administrator.joram- Listen port for JMS connector. If set to 0 the listen port is first searched through the CFG_JMS_PORT_PROPERTY property, then set to default value if not defined. If less than 0..jndi- Listen port for JNDI connector. If set to 0 the listen port is first searched through the CFG_NDI_PORT_PROPERTY property, then set to default value if not defined. If less than 0 the Joram/JNDI service is not started.props- Set of properties to define in the built configuration.
-
setDefaultConfig
public static void setDefaultConfig(String config)
-
shutdown
static void shutdown()
-
registerCheckServerListener
public static void registerCheckServerListener(CheckServerListener listener)
-
unregisterCheckServerListener
public static void unregisterCheckServerListener(CheckServerListener listener)
-
getThreadGroup
public static ThreadGroup getThreadGroup()
-
getEngine
public static AgentEngine getEngine()
Returns the agent server engine.- Returns:
- the agent server engine.
-
isEngineThread
public static boolean isEngineThread()
-
resetEngineAverageLoad
public static void resetEngineAverageLoad()
-
getEngineAverageLoad1
public static float getEngineAverageLoad1()
Returns the load averages for the last minute.- Returns:
- the load averages for the last minute.
-
getEngineAverageLoad5
public static float getEngineAverageLoad5()
Returns the load averages for the past 5 minutes.- Returns:
- the load averages for the past 5 minutes.
-
getEngineAverageLoad15
public static float getEngineAverageLoad15()
Returns the load averages for the past 15 minutes.- Returns:
- the load averages for the past 15 minutes.
-
getEngineLoad
public static int getEngineLoad()
Returns the immediate engine load.- Returns:
- the immediate engine load.
-
isAgentProfiling
public static boolean isAgentProfiling()
Returns true if the agent profiling is on.- Returns:
- true if agent profiling is on.
-
setAgentProfiling
public static void setAgentProfiling(boolean agentProfiling)
Sets the agent profiling.- Parameters:
agentProfiling- true to turn on agent profiling.
-
getReactTime
public static long getReactTime()
Return the total agent reaction time.- Returns:
- the reaction time
-
getCommitTime
public static long getCommitTime()
Return the total agent commit time.- Returns:
- the commit time
-
getTransaction
public static Transaction getTransaction()
Returns the agent server transaction context.- Returns:
- agent server transaction context.
-
addConsumer
public static void addConsumer(String domain, MessageConsumer cons) throws Exception
- Throws:
Exception
-
getConsumers
static Enumeration<MessageConsumer> getConsumers()
-
getConsumer
public static MessageConsumer getConsumer(String domain) throws Exception
- Throws:
Exception
-
removeConsumer
public static void removeConsumer(String domain)
-
getTimer
public static final Timer getTimer()
Returns a shared timer provided by the agent server.- Returns:
- a shared timer provided by the agent server.
-
setConfig
public static final void setConfig(A3CMLConfig a3config) throws Exception
Set the agent server configuration. Be careful, this method cannot be called after initialization.- Parameters:
a3config- A3CMLConfig- Throws:
Exception- Server is already initialized.
-
setConfig
public static final void setConfig(A3CMLConfig a3config, boolean force) throws Exception
- Throws:
Exception
-
getConfig
public static final A3CMLConfig getConfig() throws Exception
Returns the agent server configuration.- Returns:
- agent server configuration (A3CMLConfig)
- Throws:
Exception- an error occurs.
-
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 aA3CMLConfigobject.- Parameters:
domains- list of domain's names- Returns:
- a
A3CMLConfigobject. - Throws:
Exception- an error occurs.
-
getServerId
public static final short getServerId()
-
getName
public static final String getName()
-
getServerName
public static final String getServerName()
-
getServerIdByName
public static short getServerIdByName(String name) throws Exception
Returns the identifier of the agent server which name is specified.- Parameters:
name- the name of the agent server- Returns:
- the identifier of the agent server
- Throws:
Exception- if the server name is unknown.
-
getProperty
public static String getProperty(String key)
Searches for the property with the specified key in the server property list.- Parameters:
key- the hashtable key.- Returns:
- 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.- Parameters:
key- the hashtable key.value- a default value.- Returns:
- the value with the specified key value.
-
getInteger
public static Integer getInteger(String key)
Determines the integer value of the server property with the specified name.- Parameters:
key- property name.- Returns:
- the Integer value of the property.
-
getInteger
public static Integer getInteger(String key, int value)
Determines the integer value of the server property with the specified name.- Parameters:
key- property name.value- a default value.- Returns:
- the Integer value of the property.
-
getLong
public static Long getLong(String key)
Determines the integer value of the server property with the specified name.- Parameters:
key- property name.- Returns:
- the Integer value of the property.
-
getLong
public static Long getLong(String key, long value)
Determines the long value of the server property with the specified name.- Parameters:
key- property name.value- a default value.- Returns:
- the Integer value of the property.
-
getBoolean
public static boolean getBoolean(String key)
Determines the boolean value of the server property with the specified name. The returned value is true if the property is defined and is equal, ignoring case, to the string "true". Otherwise, a false value is returned.- Parameters:
key- property name.- Returns:
- the boolean value of the property.
-
getBoolean
public static boolean getBoolean(String key, boolean dflt)
-
addServerDesc
public static void addServerDesc(ServerDesc desc) throws Exception
- Throws:
Exception
-
removeServerDesc
public static ServerDesc removeServerDesc(short sid) throws Exception
- Throws:
Exception
-
elementsServerDesc
public static Enumeration<ServerDesc> elementsServerDesc()
-
getServersIds
public static Enumeration<Short> getServersIds()
-
getServerNb
static final int getServerNb()
Gets the number of server known on the current server.- Returns:
- the number of server.
-
getServerDesc
public static final ServerDesc getServerDesc(short sid) throws UnknownServerException
Gets the characteristics of the corresponding server.- Parameters:
sid- agent server id.- Returns:
- the server's descriptor.
- Throws:
UnknownServerException- the server is not defined.
-
getConsumer
static final MessageConsumer getConsumer(short sid) throws UnknownServerException
Gets the message consumer for the corresponding server.- Parameters:
sid- agent server id.- Returns:
- the corresponding message consumer.
- Throws:
UnknownServerException- the server is not defined.
-
getHostname
public static final String getHostname(short sid) throws UnknownServerException
Get the host name of an agent server.- Parameters:
sid- agent server id- Returns:
- server host name as declared in configuration file
- Throws:
UnknownServerException- the server is not defined.
-
getServices
static final ServiceDesc[] getServices() throws UnknownServerException
Get the description of all services of the current agent server.- Returns:
- server host name as declared in configuration file
- Throws:
UnknownServerException- the server is not defined.
-
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.- Parameters:
sid- agent server idclassname- the service class name- Returns:
- the arguments as declared in configuration file
- Throws:
UnknownServerException- The specified server does not exist.UnknownServiceException- The specified service is not declared on this server.Exception- Probably there is no configuration defined.- See Also:
A3CMLConfig.getServiceArgs(short,String)
-
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.- Parameters:
hostname- hostnameclassname- the service class name- Returns:
- the arguments as declared in configuration file
- Throws:
UnknownServiceException- The specified service is not declared on this server.Exception- Probably there is no configuration defined.- See Also:
A3CMLConfig.getServiceArgs(String, String)
-
configure
private static void configure() throws ExceptionThe second step of initialization. It needs the Transaction component be up, then it initializes allAgentServerstructures from theA3CMLConfigones. In particular the servers array is initialized.- Throws:
Exception- an error occurs.
-
createConsumers
private static void createConsumers(A3CMLServer root) throws Exception
- Throws:
Exception
-
initServerDesc
public static void initServerDesc(ServerDesc desc, A3CMLServer server) throws Exception
- Throws:
Exception
-
createServerDesc
private static ServerDesc createServerDesc(A3CMLServer server) throws Exception
- Throws:
Exception
-
initServices
private static void initServices(A3CMLServer server, ServerDesc desc) throws Exception
- Throws:
Exception
-
getStatus
public static int getStatus()
-
getStatusInfo
public static String getStatusInfo()
-
init
public static int init(String[] args) throws Exception
Parses agent server arguments, then initializes this agent server. Thestartfunction is then called to start this agent server execution. Between theinitandstartcalls, agents may be created and deployed, and notifications may be sent using theChannelsendTofunction.- Parameters:
args- launching arguments, the first one is the server id and the second one the persistency directory.- Returns:
- number of arguments consumed in args
- Throws:
Exception- unspecialized exception
-
reset
public static void reset(boolean force)
-
reset
public static void reset()
Cleans an AgentServer configuration in order to restart it from persistent storage.
-
externalUpdateConfFromFile
public static void externalUpdateConfFromFile(String serverConfigFilePath, String serverDataDirPath) throws Exception
Updates the stored configuration of an external server from a file. /!\ Be careful, the server must be stopped and reseted !! It returns 0 if the configuration has been updated, -1 if there is no persistence to update. This method locks the server lock file.- Parameters:
serverConfigFilePath- pathname of file containing the XML configuration.serverDataDirPath- pathname of the persistence repository to update.- Throws:
Exception- an error occurred during update
-
externalUpdateConfFromString
public static void externalUpdateConfFromString(String serverConfig, String serverDataDirPath) throws Exception
Updates the stored configuration of an external server from a String. /!\ Be careful the server must be stopped and reseted !! It returns 0 if the configuration has been updated, -1 if there is no persistence to update. This method locks the server lock file.- Parameters:
serverConfig- the XML configuration.serverDataDirPath- pathname of the persistence repository to update.- Throws:
Exception- an error occurred during update
-
getConfFromFile
public static A3CMLConfig getConfFromFile(String serverConfigFilePath) throws Exception
Gets the AgentServer configuration from a file.- Parameters:
serverConfigFilePath- pathname of file containing the server configuration.- Returns:
- The AgentServer configuration.
- Throws:
Exception- an error occurred during configuration parsing
-
getConfFromString
public static A3CMLConfig getConfFromString(String serverConfig) throws Exception
Gets the AgentServer configuration from the String parameter.- Parameters:
serverConfig- the XML configuration.- Returns:
- The AgentServer configuration.
- Throws:
Exception- an error occurred during configuration parsing
-
updateConf
static void updateConf(A3CMLConfig a3cmlConfig, String serverDataDirPath) throws IOException
Updates the stored configuration. /!\ Be careful the server must be stopped and reseted !! /!\ Be careful, to update the configuration of an external server you need to ensures that it is stopped acquiring the lock. It returns 0 if the configuration has been updated, -1 if there is no persistence to update.- Parameters:
a3cmlConfig- the configuration up-to-date.serverDataDirPath- pathname of the persistence repository to update.- Throws:
Exception- an error occurred during updateIOException
-
externalBackup
public static void externalBackup(String serverDataDirPath, String backupDir) throws Exception
Backup the transactional persistence. /!\ Be careful the server must be stopped and reseted !! It returns 0 if the backup is done, -1 if there is an issue during backup.- Parameters:
serverDataDirPath- pathname of the persistence repository to backup.backupDir- pathname of the directory to contain the backup.- Throws:
Exception- an error occurred during backup
-
restoreServer
public static void restoreServer(String fname) throws IOException
Restores the server persistence from a backup file.- Parameters:
backupFile- The path of backup file.- Throws:
IOException- An error occurs.
-
getTransaction
public static Transaction getTransaction(String serverDataDirPath) throws IOException
Gets the Transaction component from an existing transactional persistence. If the transactional persistence is not initialized (TFC file does not exist) then the method simply return null. If an A3CMLConfig configuration is provided, the transaction component is updated prior to start the component.- Parameters:
serverDataDirPath- pathname of the persistence repository- Returns:
- The transaction component started, or null if the transaction persistence does not exist.
- Throws:
IOException- an error occurred during transaction initialization.
-
init
public static void init(short sid, String path, LoggingFactory loggerFactory) throws ExceptionInitializes this agent server.startfunction is then called to start this agent server execution. Between theinitandstartcalls, agents may be created and deployed, and notifications may be sent using theChannelsendTofunction.- Parameters:
sid- the server idpath- the persistency directory.loggerFactory- the monolog LoggerFactory;- Throws:
Exception- unspecialized exception
-
init
public static void init(short sid, String serverDataDirPath, boolean update, LoggingFactory loggerFactory) throws Exception- Parameters:
sid- the server idserverDataDirPath- the persistency directory.update- If true updates persistence from configurationloggerFactory- the monolog LoggerFactory;- Throws:
Exception- unspecialized exception
-
start
public static String start() throws Exception
Causes this AgentServer to begin its execution. This method starts allMessageConsumer(i.e. the engine and the network components).- Returns:
- status of the server.
- Throws:
Exception- an error occurs.
-
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.- Parameters:
sync- If true the stop is processed synchronously, otherwise a thread is created and the method returns.
-
stop
public static void stop(boolean sync, long delay, boolean reset)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.- Parameters:
sync- If true the stop is processed synchronously, otherwise a thread is created and the method returns.delay- if sync is false then the thread in charge of stopping the server waits this delay before initiating the stop.reset- If true the server is stopped then reseted.
-
lockAgentServer
public static ServerLock lockAgentServer(String serverDataDirPath) throws IOException
Try to lock the AgentServer lock file.- Parameters:
serverDataDirPath- pathname of the persistence repository to update.- Returns:
- The AgentServer lock (locked).
- Throws:
IOException- Error preventing AgentServer locking.
-
lockAgentServer
private static ServerLock lockAgentServer(String serverDataDirPath, boolean createDataDir) throws IOException
Try to lock the AgentServer lock file. If the data directory does not exist and createDataDir is true, try to create data directory.- Parameters:
serverDataDirPath- pathname of the persistence repository to update.createDataDir- if true, try to create data directory.- Returns:
- The AgentServer lock (locked).
- Throws:
IOException- Error preventing AgentServer locking.
-
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.
-
main
public static void main(String[] 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.- Parameters:
args- start arguments- Throws:
Exception- unspecialized exception
-
-