Class AgentServer


  • public final class AgentServer
    extends Object
    The AgentServer class manages the global configuration of an agent server. It reads the configuration file, then it creates and configure Engine, Channel and Network components. 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 config element, that is essentially made up of domains 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 Network implementation (class SimpleNetwork 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.
    • Additionally, 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.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 PoolNetwork 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.
    See Also:
    Engine, Channel, Network, MessageQueue, Transaction
    • Field Detail

      • logger

        private static final Logger logger
      • DEBUG

        private static final boolean DEBUG
      • ENCODABLE_CLASS_ID_AREA

        public static final int ENCODABLE_CLASS_ID_AREA
        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 java launching 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 java launching 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 java launching 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 java launching 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 java launching 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 java launching 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 java launching 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 java launching 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 is a3servers.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 is a3cmlconfig.

        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
      • 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 java launching 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
      • engine

        static AgentEngine engine
        Static reference to the engine. Used in Channel.sendTo to 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 (including Engine).
      • 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.
      • 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 java launching 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
    • Constructor Detail

      • AgentServer

        public AgentServer()
    • 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 sever
        adminuid - the administration login
        adminpwd - the administration password
        joram - the JMS TCP connector port
        jndi - 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.
      • 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.
      • 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 a A3CMLConfig object.
        Parameters:
        domains - list of domain's names
        Returns:
        a A3CMLConfig object.
        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)
      • 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.
      • 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 id
        classname - 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 - hostname
        classname - 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 Exception
        The second step of initialization. It needs the Transaction component be up, then it initializes all AgentServer structures from the A3CMLConfig ones. In particular the servers array is initialized.
        Throws:
        Exception - an error occurs.
      • setProperties

        private static void setProperties​(short sid)
                                   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. 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.
        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 update
        IOException
      • 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 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.
        Parameters:
        sid - the server id
        path - 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 id
        serverDataDirPath - the persistency directory.
        update - If true updates persistence from configuration
        loggerFactory - the monolog LoggerFactory;
        Throws:
        Exception - unspecialized exception
      • 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).
        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