public class Engine
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Engine.EngineJMX |
static interface |
Engine.EngineJMXMBean |
Modifier and Type | Field and Description |
---|---|
protected static java.lang.reflect.Method |
cpuMethod |
static java.lang.String |
dumpStacksAndExitIfFileExists
Scripting should set this to the name of a file which, if
the file exists, causes the engine to dump the stacks of all
threads and exit the process
|
static int |
ExecutorThreadPoolSize
Determines the size of the scheduled thread pool.
|
static int |
MAX_NETWORK_BUF_SIZE
The maximum size of an RDP or aggregated RDP packet, and the
size at which the packet aggregator will send a packet even
if the aggregation interval has not expired
|
long |
PersistentObjectSaveIntervalMS
The current interval in millisecond between periodic saves of
modified persistent objects to the database.
|
protected static int |
processorCount |
static java.util.Properties |
properties
The Properties instance, typically read from file
$AO_HOME/bin/atavism.properties
|
Constructor and Description |
---|
Engine()
Constructor gets the properties; creates the management agent
if required; and starts the CPU time thread if required.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
createMBeanInstance()
Return JMX MBean instance object.
|
static void |
defaultDispatchMessage(Message message,
int flags,
MessageCallback callback)
The default message dispatcher.
|
static void |
dumpAllThreadStacks()
Utility method to dump all the thread stacks of the current process to the log
|
static void |
dumpAllThreadStacks(java.lang.StringBuilder stringBuilder,
boolean sortThreads)
Utility method that outputs the set of stack traces to the
stringBuilder parameter.
|
static MessageAgent |
getAgent()
Get the MessageAgent instance.
|
protected static java.lang.reflect.Method |
getCPUMethod()
Get method capable of returning process CPU usage.
|
static EnginePlugin |
getCurrentPlugin()
Get the plugin active on the current thread.
|
static Database |
getDatabase()
Get the engine's Database object
|
static java.lang.String |
getDBDriver()
Gets the JDBC driver classname string - default is MySQL driver.
|
static java.lang.String |
getDBHostname()
Gets The database host name.
|
static java.lang.String |
getDBName()
Gets the database name - default is "atavism".
|
static java.lang.String |
getDBPassword()
Gets the database password.
|
static java.lang.String |
getDBType()
Gets the database type - default is "mysql".
|
static java.lang.String |
getDBUrl()
Gets the JDBC connection string (URL).
|
static java.lang.String |
getDBUser()
Gets the database user name.
|
static java.lang.String |
getEngineHostName()
Get the engine host name
|
static EventServer |
getEventServer()
Get the EventServer object, which provides a queue of events.
|
static java.util.concurrent.ScheduledThreadPoolExecutor |
getExecutor()
Return the thread pool that can run operations some time in the future
|
static Engine |
getInstance()
Gets the Engine instance; for now, there are no callers
|
static Interpolator<?> |
getInterpolator()
Return this engine's interpolator object
|
static java.lang.Integer |
getIntProperty(java.lang.String propName)
Get the named property, coercing it to an int.
|
static java.lang.Integer |
getLoginMgrPort()
Get the port number of the login manager.
|
static java.lang.String |
getLogLevel()
Get the log level from the properties file or sys. prop, or
default to 1 (debug).
|
static javax.management.MBeanServer |
getManagementAgent()
Get the JMX top-level agent.
|
static java.lang.String |
getMessageServerHostname()
Gets the name of the msgsys domain server.
|
static java.lang.Integer |
getMessageServerPort()
Gets the msgsys domain server listener port.
|
static OIDManager |
getOIDManager()
Get the engine's OIDManager object, which hands out oids, and
records the ranges used in the database.
|
protected static java.lang.Class |
getParentInterface(java.lang.Class cl,
java.lang.String name)
Common method to get the parent interface
|
static PersistenceManager |
getPersistenceManager()
Returns the persistence manager, used to save objects into the database
at regular intervals.
|
long |
getPersistentObjectSaveIntervalMS()
Get the interval between saves of dirty objects.
|
static EnginePlugin |
getPlugin(java.lang.String name)
Get the named plugin, or return null if it's not part of this server.
|
protected static long |
getProcessCpuTime(java.lang.reflect.Method cpuMethod,
java.lang.Object mxbean)
Common method to get the process CPU time.
|
static java.util.Properties |
getProperties() |
static java.lang.String |
getProperty(java.lang.String propName)
Get the string property value for the given property name,
either from the System property of that name, or from the
properties read from the propery file.
|
static ScriptManager |
getScriptManager()
this should only be called by the engine thread
|
static int |
getStatusReportingInterval()
Getter for the status reporting interval
|
static java.lang.Integer |
getWorldMgrPort()
Get the port number of the world manager.
|
static java.lang.String |
getWorldName()
The engine should know the world name. it uses it when it creates
characters in the database.
|
static boolean |
isManagementEnabled()
Get whether management is enabled
|
static void |
main(java.lang.String[] args)
The engine main program.
|
static java.util.Map<java.lang.String,java.lang.String> |
makeMapOfString(java.lang.String str)
Make a map from the comma-separated name=value pairs
|
static java.lang.String |
makeStringFromMap(java.util.Map<java.lang.String,java.lang.String> propMap)
Make a string from the map of name/value pairs
|
static void |
printStack(java.lang.StringBuilder stringBuilder,
java.lang.StackTraceElement[] elements) |
static void |
processPostScripts(java.util.List<java.lang.String> postScripts)
Process a set of startup scripts whose file names are given by
array arg.
|
static java.util.List<java.lang.String> |
processPreScripts(java.lang.String[] args)
Process a set of startup scripts whose file names are given by array arg.
|
static void |
registerPlugin(EnginePlugin plugin)
Registers a plugin instance with the engine, and call the
plugin's activate method.
|
static EnginePlugin |
registerPlugin(java.lang.String className)
Creates the new plugin instance, and registers the plugin with
the engine, and calls the plugin's activate method.
|
static void |
registerStatusReportingPlugin(EnginePlugin plugin)
Register the plugin passed in with Engine for status reporting
with the database.
|
static void |
setBasicInterpolatorInterval(java.lang.Integer interval)
Set the time interval between periodic interpolations
|
static void |
setCurrentPlugin(EnginePlugin plugin)
Set the plugin active on the current thread.
|
static void |
setDatabase(Database db)
Set the engine's Database object
|
static void |
setDBDriver(java.lang.String driver)
Sets the JDBC driver classname string.
|
static void |
setDBHostname(java.lang.String hostname)
Sets the database host name.
|
static void |
setDBName(java.lang.String name)
Sets the database name.
|
static void |
setDBPassword(java.lang.String password)
Sets the database password.
|
static void |
setDBType(java.lang.String dbtype)
Sets the database type
|
static void |
setDBUrl(java.lang.String url)
Sets the JDBC connection string (URL).
|
static void |
setDBUser(java.lang.String username)
Sets the database user name.
|
static void |
setInterpolator(Interpolator<?> interpolator)
Set this engine's interpolator object
|
static void |
setLogLevel(java.lang.String level)
Set the log level.
|
static void |
setMessageServerHostname(java.lang.String host)
Sets the name of the msgsys domain server.
|
static void |
setMessageServerPort(java.lang.Integer port)
Set the msgsys domain server listener port.
|
static void |
setOIDManager(OIDManager o)
Set the engine's OIDManager object.
|
void |
setPersistentObjectSaveIntervalMS(long interval)
Set the interval between saves of dirty objects.
|
static void |
setProperty(java.lang.String propName,
java.lang.String propValue)
Set the string property value for the given property name, both in
the System property as well as the encached Properties map.
|
static void |
setStatusReportingInterval(int statusReportingInterval)
Setter for the status reporting interval
|
static void |
setWorldMgrPort(java.lang.Integer port)
Sets the port number of the world manager.
|
static void |
setWorldName(java.lang.String worldName)
Set the world name to be used by the engine.
|
protected static java.lang.reflect.Method cpuMethod
protected static int processorCount
public static java.util.Properties properties
public static int ExecutorThreadPoolSize
public static int MAX_NETWORK_BUF_SIZE
public static java.lang.String dumpStacksAndExitIfFileExists
public long PersistentObjectSaveIntervalMS
public Engine()
public static Engine getInstance()
public static void dumpAllThreadStacks()
public static void dumpAllThreadStacks(java.lang.StringBuilder stringBuilder, boolean sortThreads)
stringBuilder
- the buffer to which the stack traces will be appendedsortThreads
- true if the thread stack traces should be ordered based
on the thread namespublic static void printStack(java.lang.StringBuilder stringBuilder, java.lang.StackTraceElement[] elements)
public static EventServer getEventServer()
public static java.util.concurrent.ScheduledThreadPoolExecutor getExecutor()
public static Interpolator<?> getInterpolator()
public static void setInterpolator(Interpolator<?> interpolator)
interpolator
- The interpolator object to associate with
this Engine.public static void setBasicInterpolatorInterval(java.lang.Integer interval)
interval
- The time interval in milliseconds between
interpolations.public static ScriptManager getScriptManager()
public static Database getDatabase()
public static void setDatabase(Database db)
db
- The Database instance to associate with the Engine.public static OIDManager getOIDManager()
public static void setOIDManager(OIDManager o)
o
- The OIDManager object to associate with this Engine.public static PersistenceManager getPersistenceManager()
public static void main(java.lang.String[] args)
args
- The command-line arguments.public static java.util.List<java.lang.String> processPreScripts(java.lang.String[] args)
args
- The command-line args passed in from the main program.public static void processPostScripts(java.util.List<java.lang.String> postScripts)
postScripts
- A list of the scripts to be run after the
Engine object is initialized.public long getPersistentObjectSaveIntervalMS()
public void setPersistentObjectSaveIntervalMS(long interval)
interval
- Milliseconds between saves in the PersistenceManager.public static EnginePlugin registerPlugin(java.lang.String className)
className
- The class name of the plugin.public static void registerPlugin(EnginePlugin plugin)
plugin
- The engine plugin instance to be registeredpublic static EnginePlugin getPlugin(java.lang.String name)
name
- The name of the plugin to returnpublic static EnginePlugin getCurrentPlugin()
public static void setCurrentPlugin(EnginePlugin plugin)
public static java.lang.String getEngineHostName()
public static java.lang.String getDBDriver()
public static void setDBDriver(java.lang.String driver)
driver
- The JDBC driver classname string.public static java.lang.String getDBType()
public static void setDBType(java.lang.String dbtype)
dbtype
- The database type.public static void setDBUrl(java.lang.String url)
url
- The JDBC connection string.public static java.lang.String getDBUrl()
public static java.lang.String getDBUser()
public static void setDBUser(java.lang.String username)
username
- The database user name.public static java.lang.String getDBPassword()
public static void setDBPassword(java.lang.String password)
password
- The database password.public static java.lang.String getDBHostname()
public static void setDBHostname(java.lang.String hostname)
hostname
- The database host name.public static java.lang.String getDBName()
public static void setDBName(java.lang.String name)
name
- The database name.public static java.lang.String getMessageServerHostname()
public static void setMessageServerHostname(java.lang.String host)
host
- The name of the msgsys domain server.public static java.lang.Integer getMessageServerPort()
public static void setMessageServerPort(java.lang.Integer port)
port
- The msgsys domain server listener port.public static void setWorldMgrPort(java.lang.Integer port)
port
- The port number of the world manager.public static java.lang.Integer getWorldMgrPort()
public static java.lang.Integer getLoginMgrPort()
public static int getStatusReportingInterval()
public static void setStatusReportingInterval(int statusReportingInterval)
statusReportingInterval
- The number of milliseconds between iterations of the
status reporting thread.public static java.util.Properties getProperties()
public static java.lang.String getProperty(java.lang.String propName)
propName
- The name of the property whose value should be
returned.public static void setProperty(java.lang.String propName, java.lang.String propValue)
propName
- The name of the property whose value should be
set.propValue
- The value to associate with the propName.public static java.lang.Integer getIntProperty(java.lang.String propName)
propName
- The property name.getProperty(java.lang.String)
public static java.lang.String getWorldName()
public static void setWorldName(java.lang.String worldName)
worldName
- The value to associate with property
"atavism.worldname".public static java.lang.String getLogLevel()
public static void setLogLevel(java.lang.String level)
level
- The new log level value.public static boolean isManagementEnabled()
public static MessageAgent getAgent()
public static java.util.Map<java.lang.String,java.lang.String> makeMapOfString(java.lang.String str)
str
- The string containing the comma-separated name=value pairspublic static java.lang.String makeStringFromMap(java.util.Map<java.lang.String,java.lang.String> propMap)
propMap
- The map of name/value pairspublic static void defaultDispatchMessage(Message message, int flags, MessageCallback callback)
message
- The message to be dispatched.flags
- The message flags.callback
- The MessageCallback instance to run when
the message is dequeued.public static void registerStatusReportingPlugin(EnginePlugin plugin)
plugin
- An EnginPlugin instance.protected static java.lang.reflect.Method getCPUMethod()
protected static long getProcessCpuTime(java.lang.reflect.Method cpuMethod, java.lang.Object mxbean)
cpuMethod
- A Method object that returns the process CPU time.mxbean
- The JavaBean used to get the CPU time.protected static java.lang.Class getParentInterface(java.lang.Class cl, java.lang.String name)
cl
- The class whose parent interface is requested.name
- The name of the interface.protected java.lang.Object createMBeanInstance()
public static javax.management.MBeanServer getManagementAgent()