com.ls.lars.server
Class Lars

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.ls.lars.server.Lars
All Implemented Interfaces:
ISystemErrorLog, Runnable

public final class Lars
extends Thread
implements ISystemErrorLog

main class of the "living agents runtime system II"


to Class Specification

Introduction to LARS Platform Runlevels:

RUN_LEVEL_EMBRYONIC
initial run level
RUN_LEVEL_LARS_INSTANCE_CREATED
Reached after a Lars instance has been created in the createInstance() method without any unforeseen exceptions/errors.
RUN_LEVEL_LARS_INSTANCE_STARTED
Reached after the Lars instance has been started without any unforeseen exceptions/errors.
RUN_LEVEL_CONFIG_FILE_READ
Reached after lars has read its config file from the file system without any unforeseen exceptions/errors.
RUN_LEVEL_CONFIG_FILE_INTERPRETED
Reached after lars has interpreted its config file system without any unforeseen exceptions/errors.
RUN_LEVEL_SECURITY_MANAGER_SET
Reached after the lars security manager for the JVM has been set without any unforeseen exceptions/errors.
RUN_LEVEL_LOCAL_IP_ADDRESS_KNOWN
reached after the lars platform knows the IP address where it is running on (may be set in the lars config file and is otherwise determined by InetAddress.getLocalHost().getHostAddress()) without any unforeseen exceptions/errors.
RUN_LEVEL_MESSAGE_ROUTER_CREATED
Reached after the lars security manager for the JVM has been set without any unforeseen exceptions/errors.
RUN_LEVEL_RUNNING
Reached after agent manager has been created and started without any unforeseen exceptions/errors.
RUN_LEVEL_STOPPED
Reached, if agent manager has received a valid request to shutdown the lars platform.
RUN_LEVEL_TERMINATED
If this run level is reached, only a System.exit(int) is executed.
Note: lars run levels can only increase (e.g. it is impossible to set the run level RUN_LEVEL_RUNNING after the run level RUN_LEVEL_STOPPED has been reached).

Version:
$Revision: 1.26 $
Author:
Last modified by $Author: MFehrenbach $

Field Summary
protected static String revisionInformation
          revision information string, managed by our version control system
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
static Lars createInstance()
          Creates a new Lars object and returns it, if no Lars is yet running in this JVM.
static void executeShutdownHook()
          logs the current stack trace and all system information
 String getClassName()
          returns the name of the class
static String getEncoding()
          returns the name of the character encoding, that is currently in use (e.g.
static String getHomePlatform()
          returns the name of the local platform
static String getLocalIpAddress()
          returns the IP address of the local platform
static long getStartTime()
          returns the start time of lars (in milliseconds since 01-jan-1970)
 String getSystemInformation()
          collects all available system information (running threads, memory, inbox size of all agents, etc.)
static void logSystemInformation()
          logs all system information found by getSystemInformation()
static void main(String[] args)
          main method
 void run()
          Reads and interprets tha platform's config file, installs the security manager and creates and starts AgentManager.
 void start()
          Checks the the lars platform's current run level and starts the lars platform, if the run level is "LARS_INSTANCE_CREATED".
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

revisionInformation

protected static String revisionInformation
revision information string, managed by our version control system
Method Detail

createInstance

public static Lars createInstance()
                           throws IllegalThreadStateException
Creates a new Lars object and returns it, if no Lars is yet running in this JVM. After creating the new Lars object, the lars platform's run level is set to "LARS_INSTANCE_CREATED".
Returns:
reference to the newly created Lars object
Throws:
IllegalThreadStateException - if a Lars instance already exists

start

public void start()
Checks the the lars platform's current run level and starts the lars platform, if the run level is "LARS_INSTANCE_CREATED".
Overrides:
start in class Thread

run

public void run()
Reads and interprets tha platform's config file, installs the security manager and creates and starts AgentManager.

Note:
The Jave Virtual Machine is terminated with exit code -1, if a security manager is already set.
The Jave Virtual Machine is terminated with exit code -2, if no local IP address is configured and the local IP address cannot be determined.
The Jave Virtual Machine is terminated with exit code -3, if any unforeseen RuntimeException is caught. The Jave Virtual Machine is terminated with exit code -4, if any unforeseen Error is caught.

Overrides:
run in class Thread

getHomePlatform

public static String getHomePlatform()
returns the name of the local platform
Returns:
name of the local platform

getLocalIpAddress

public static String getLocalIpAddress()
returns the IP address of the local platform
Returns:
IP address of the local platform (null, if not initialized from lars.cfg)

getEncoding

public static String getEncoding()
returns the name of the character encoding, that is currently in use (e.g. "UnicodeBig")
Returns:
name of the character encoding

getStartTime

public static long getStartTime()
returns the start time of lars (in milliseconds since 01-jan-1970)
Returns:
time, when this lars platform started

getClassName

public String getClassName()
returns the name of the class
Specified by:
getClassName in interface ISystemErrorLog
Returns:
name of the class "Lars"

logSystemInformation

public static void logSystemInformation()
logs all system information found by getSystemInformation()

getSystemInformation

public String getSystemInformation()
collects all available system information (running threads, memory, inbox size of all agents, etc.)
Specified by:
getSystemInformation in interface ISystemErrorLog
Returns:
the system information

executeShutdownHook

public static void executeShutdownHook()
logs the current stack trace and all system information

main

public static void main(String[] args)
main method
Parameters:
args - String array containing command line parameters
 -config      (e.g. "lars.cfg")
 -loglevel       (one of the SystemLogger loglevels, e.g. "TRACE5")
 -revision   prints out the revision information and exits