|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.starhope.appius.game.AppiusClaudiusCaecus
public class AppiusClaudiusCaecus
Appius Claudius Caecus is a game server application framework. Extensible using Java classes loaded from its extensive library of configurable options, Appius provides a network server for real-time data exchange.
Originally titled “Braque,” this application was developed for use with the videogame (work in progress) “Sideres.” It was designed to operate with a messaging protocol called “Cubist,” which has since been defined in terms of a simple JSON + \0 wire protocol.
Since that time, I have repurposed the game engine for use with Tootsville™ (http://www.Tootsville.com/) and set up a new series of communications supports designed to be compatible with the ActionScript 3 libraries for Smart Fox Server Pro.
The server should still be able to operate on its own with minimal changes. Most of the Tootsville-specific code has been isolated into the com.tootsville.* package, but replacement code for some methods might be needed to create a stand-alone game. Also, some default configuration values are Tootsville-oriented.
This class in general operates as both the main game thread and socket listener — in the static methods and variables — and the client-connected user thread — in the instance methods and variables. The “metronome” timer thread also runs using the static methods of this class.
Field Summary | |
---|---|
private static PreparedStatement |
blatherStatement
Prepared statement used to inject log entries into the log |
private static long |
bootTime
The time at which the server was started |
(package private) static Set<Long> |
bugsMailed
when were bugs eMailed? Don't blow up my mailbox |
private static GaiusValeriusCatullus |
catullus
WRITEME: Document this brpocock@star-hope.org |
private static Collection<RoomListener> |
defaultListeners
Default listeners are called for actions on all rooms in the world |
static int |
DELAY_MS
The delay before the first run of the NPC manager task. |
private static boolean |
doUserLoadTest
If true, the internal user system load testing should be enabled |
private static int |
highWaterUsers
The most users who have been online since the server started |
private static boolean |
isFollower
If true, this is a follower server in a cluster (not the leader) |
(package private) static SimpleDateFormat |
isoDate
The date format used for system messages. |
private static Connection |
journalDB
The connection to the journal database, used by blather |
private static Kalendor |
kalendor
the kalendor |
private static Timer |
kalendorTimer
WRITEME: Document this brpocock@star-hope.org |
private static boolean |
keepRunning
If this ever transitions to “false,” stop listening for new connections. |
private static boolean |
knowWhyJournalDBOut
If the journaling database goes offline, this variable will keep from getting a flood of bug reports. |
private static long |
lastMetronomeTick
The time at which the global metronome thread last ticked. |
(package private) static Collection<ListeningThread> |
listeningThreads
all listeners who might be active |
private static ListeningThread |
mainListeningThread
WRITEME |
(package private) static Timer |
metronome
The timer driving the global metronome. |
private static ConcurrentSkipListSet<AcceptsMetronomeTicks> |
metronomeListeners
Collection of arbitrary objects who wish to receive Metronome ticks |
(package private) static Thread |
metronomeThread
The global metronome thread. |
private static String |
motd
Message of the day |
private static Timer |
quaestorTimer
WRITEME: Document this brpocock@star-hope.org |
private static Collection<String> |
quenchedAddresses
addresses from which connections are not accepted |
private static long |
serialVersionUID
The version of the serialized form of this class. |
private static ConcurrentHashMap<String,ServerThread> |
serverThreads
All live server threads |
private static ZoneSpawner |
spawner
WRITEME: Document this brpocock@star-hope.org |
private static boolean |
started
A global boolean flag to indicate that the server has started up successfully |
private static long |
tGameStatePump
Time at which the Game State pump last ran |
private static ConcurrentHashMap<String,ThreadGroup> |
threadGroups
Thread groups, by name. |
private static long |
tStats
Time at which the server statistics were last “reportBug” mailed |
static int |
TWENTY_ONE_YEARS_MSEC
The number of milliseconds in 21 years. |
String |
versionInformation
The version information, published here for implementations to refer back to. |
Constructor Summary | |
---|---|
AppiusClaudiusCaecus()
|
Method Summary | |
---|---|
static void |
add(AcceptsMetronomeTicks listener)
Add a thread to the Metronome tick event schedule without that thread being |
static void |
add(ListeningThread listeningThread)
|
static void |
add(Zone zone)
Add a Zone to the global Zones list |
static void |
addDefaultListener(RoomListener listener)
Add a default room listener to all rooms in every zone (except limbo rooms) |
static void |
addZone(String zoneName,
Zone zone)
Deprecated. use add(Zone) |
static void |
blather(String message)
Print a debugging message at low urgency, from a random place |
static void |
blather(String user,
String room,
String address,
String message,
boolean urgent)
Write out a log message to the log file and/or database |
private static void |
blatherToJournal(String user,
String room,
String address,
String message,
boolean urgent)
Write out a log message to the database |
static void |
bugDuplex(String subject,
String message)
Write out an error message to the log file and/or mail, as appropriate |
private static Zone |
createLoginZone()
Create the $Eden special login zone. |
static Error |
fatalBug(Exception e)
The exception passed in will be reported, as per reportBug, and then re-thrown as an Error, killing the process responsible |
static Error |
fatalBug(String string)
Report a bug, and throw a fatal Error. |
static Error |
fatalBug(String string,
Throwable t)
Report a bug, and throw a fatal Error. |
private static int |
getAccurateHeadcount()
Get the accurate number of users in all zones. |
static Collection<AbstractUser> |
getAllUsers()
Get a collection of all users in all zones. |
static LinkedList<Zone> |
getAllZones()
|
static long |
getBootTime()
Get the server start time |
static GaiusValeriusCatullus |
getCatullus()
|
static Charon |
getCharon()
Get the Charon reaper thread |
static String |
getClusterLeader()
Get the hostname of the cluster leader, or this server if it is the cluster leader |
static Collection<RoomListener> |
getDefaultListeners()
Get the set of default room listeners upon all rooms in the world |
static int |
getHighWaterUsers()
Get the high-water mark count of users |
static Kalendor |
getKalendor()
|
static long |
getLastMetronomeTick()
|
static Zone |
getLoginZone()
|
static String |
getMOTD()
|
static Set<String> |
getQuenchedAddresses()
WRITEME: Document this method brpocock@star-hope.org |
(package private) static Class<? extends RunCommands> |
getRCClass()
WRITEME: Document this method brpocock@star-hope.org |
static String |
getRev()
Get the revision number of this file |
static String |
getServerHostname()
Get the hostname on which the server process is running |
static String |
getServerPorts()
|
(package private) static String |
getStackTrace(Throwable throwable,
String prefix)
Deprecated. Use BugReporter.getStackTrace(Throwable,String)
instead |
static int |
getThreadCount()
Returns the number of server threads running. |
static ThreadGroup |
getThreadGroup(String string)
WRITEME: Document this method brpocock@star-hope.org |
static Zone |
getZone(String zoneName)
Find a Zone object for a given zone name |
static ZoneSpawner |
getZoneSpawner()
WRITEME: Document this method brpocock@star-hope.org |
private static void |
installShutdownHooks()
WRITEME: Document this method brpocock@star-hope.org |
static boolean |
isFollower()
|
static boolean |
isLeader()
|
static boolean |
isZoneActive(String zoneName)
Determine whether a zone is active |
private static void |
listenForever()
Begin threads to listen on the stream and batch ports. |
static void |
logEvent(String verb,
String zoneName,
String userName,
String targetName,
HashMap<String,String> details)
Record an event to the journal |
static void |
main(String[] argv)
This is the main routine to run Appius as a stand-alone server. |
static void |
migrateAll(String otherHost,
int otherPort)
Migrate all users to another host. |
private static void |
parseArgV(String[] argv)
Parse command-line arguments (for the loosest definition of “parse”) |
static void |
quenchConnectionsFrom(InetAddress address)
WRITEME: Document this method brpocock@star-hope.org |
static void |
remove(AcceptsMetronomeTicks listener)
Remove a metronome listener |
static void |
remove(ListeningThread listeningThread)
|
static void |
remove(Zone whichZone)
Deprecated. Use TheZones.remove(AbstractZone) instead |
static void |
reportBug(String string)
Report a bug. |
static void |
reportBug(String reason,
Throwable throwable)
Report a bug to the automatic bug-tracking systems. |
static void |
reportBug(Throwable e)
|
static void |
reportClientBug(String string)
Report a bug from the client application. |
static void |
reportClientBug(String string,
Thread thread)
Report a bug from the client application. |
static void |
reportDesignBug(String string)
Report a bug regarding room layouts and such |
private static void |
reportRestartBefore()
WRITEME: Document this method brpocock@star-hope.org |
private static void |
reportRestartFinal()
WRITEME: Document this method brpocock@star-hope.org |
static void |
restart()
This should restart the server, but it doesn't work (yet) XXX |
static void |
restartMetronome()
Attempt to restart the global metronome — this probably won't work as currently implemented (?) |
private static void |
runCommands()
Run the initial "run commands" (RC) for the game in question. |
private static void |
sayGoodMorning()
Print the “good morning” banners to the logs |
private static void |
sendStatsMail(long t)
Send an eMail with server statistics, if the timer has elapsed |
static void |
setMOTD(String string)
Set the message of the day string |
static void |
shutdown()
WRITEME: Document this method brpocock@star-hope.org |
static void |
startMetronome()
Start the global metronome to ticking |
static void |
startTicking(ServerThread thread)
Register an object (usually a server thread) who wishes to begin accepting metronome ticks. |
private static void |
startUserLoadTest()
Start the parallel user load test threads |
static void |
stopMetronome()
|
static void |
stopTicking(AcceptsMetronomeTicks thread)
Stop sending metronome ticks to a particular object. |
static String |
stringify(StackTraceElement[] stackTrace)
Deprecated. Use LibMisc.stringify(StackTraceElement[])
instead |
static String |
stringify(Throwable e)
Deprecated. Use LibMisc.stringify(Throwable) instead |
static void |
tick()
The main metronome single-threaded tick |
private static void |
tickGameStatePump(long t)
Send a metronome tick to the game state pump |
private static void |
tickMetronomeListeners(long t,
long deltaT)
Tick all listeners to the Metronome |
private static void |
tickServerThreads(long t,
long deltaT,
boolean dumpUserThreads)
Tick all server threads |
static void |
traceThis()
Force a stack backtrace without an exception being thrown. |
static void |
traceThis(String string)
Force a stack backtrace without an exception being thrown. |
static void |
unquench(InetAddress address)
WRITEME: Document this method brpocock@star-hope.org |
static void |
updateHighWaterMark()
Update the high water mark, if necessary |
static void |
wallops(AbstractUser user,
String string)
Write a message to all online operators |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static PreparedStatement blatherStatement
private static final long bootTime
private static Collection<RoomListener> defaultListeners
public static final int DELAY_MS
private static boolean doUserLoadTest
private static int highWaterUsers
private static boolean isFollower
static final SimpleDateFormat isoDate
private static ListeningThread mainListeningThread
private static Timer quaestorTimer
private static Timer kalendorTimer
public final String versionInformation
private static Connection journalDB
private static boolean keepRunning
private static boolean knowWhyJournalDBOut
private static long lastMetronomeTick
static Timer metronome
private static final ConcurrentSkipListSet<AcceptsMetronomeTicks> metronomeListeners
static Thread metronomeThread
private static String motd
private static final long serialVersionUID
private static ConcurrentHashMap<String,ServerThread> serverThreads
private static boolean started
private static long tGameStatePump
private static long tStats
public static final int TWENTY_ONE_YEARS_MSEC
static Collection<ListeningThread> listeningThreads
private static Collection<String> quenchedAddresses
private static ConcurrentHashMap<String,ThreadGroup> threadGroups
static Set<Long> bugsMailed
private static final Kalendor kalendor
private static ZoneSpawner spawner
private static GaiusValeriusCatullus catullus
Constructor Detail |
---|
public AppiusClaudiusCaecus()
Method Detail |
---|
public static GaiusValeriusCatullus getCatullus()
public static String getMOTD()
public static Set<String> getQuenchedAddresses()
static Class<? extends RunCommands> getRCClass() throws NotFoundException
NotFoundException
- WRITEMEpublic static String getRev()
public static String getServerHostname()
public static String getServerPorts()
@Deprecated static String getStackTrace(Throwable throwable, String prefix)
BugReporter.getStackTrace(Throwable,String)
instead
throwable
- A Throwable
from which to extract a
stack traceprefix
- The string with which to separate lines of the
trace.
public static int getThreadCount()
public static ThreadGroup getThreadGroup(String string)
string
- WRITEME
public static Zone getZone(String zoneName)
zoneName
- The name of the zone to be found
public static ZoneSpawner getZoneSpawner()
private static void installShutdownHooks()
public static boolean isFollower()
public static boolean isLeader()
public static boolean isZoneActive(String zoneName)
zoneName
- the name of the zone
private static void listenForever()
public static void logEvent(String verb, String zoneName, String userName, String targetName, HashMap<String,String> details)
verb
- The verb describing the eventzoneName
- The zone in which it occurreduserName
- The user causing the actiontargetName
- The target of the action, if anydetails
- Additional detailspublic static void main(String[] argv) throws IOException
argv
- Any command-line arguments
IOException
- if there's an I/O exceptionpublic static void migrateAll(String otherHost, int otherPort)
Migrate all users to another host. They will attempt to connect to identical zones as the ones which are currently active.
This is a low-level function and does nothing to ensure that the given zone actually exists on the other server
otherHost
- the other host to which users should migrateotherPort
- the other host's listening port to which users
should migrateprivate static void parseArgV(String[] argv) throws NumberFormatException
argv
- Command-line arguments “vector”
NumberFormatException
- if a numerical parameter can't be
interpreted properlypublic static void quenchConnectionsFrom(InetAddress address)
address
- WRITEMEpublic static void remove(AcceptsMetronomeTicks listener)
listener
- The listener to deregisterpublic static void remove(ListeningThread listeningThread)
listeningThread
- WRITEME@Deprecated public static void remove(Zone whichZone)
TheZones.remove(AbstractZone)
instead
whichZone
- The zone to be removedpublic static void reportBug(String string)
Report a bug.
This is used to catch either ‘impossible things’ or things that are so bad that immediate programmer intervention is needed.
Bug reports should eventually be funneled into the bug-tracking system or similar automatically, and forwarded to the systems programmers via eMail and SMS.
string
- Bug reportpublic static void reportBug(String reason, Throwable throwable)
reason
- The reason this is a bug, if known.throwable
- The "impossible" exception.public static void reportBug(Throwable e)
e
- An exception to reportpublic static void reportClientBug(String string)
string
- The client application's bugpublic static void reportClientBug(String string, Thread thread)
string
- The client application's bugthread
- The associated server thread, whose information
will be prepended, if present. (null is a valid
answer, for backward compatibility)public static void reportDesignBug(String string)
string
- The client application's bugprivate static void reportRestartBefore()
private static void reportRestartFinal()
public static void restart()
public static void restartMetronome()
private static void runCommands()
private static void sayGoodMorning()
private static void sendStatsMail(long t)
t
- the current timepublic static void setMOTD(String string)
string
- new message of the daypublic static void shutdown()
public static void startMetronome()
public static void startTicking(ServerThread thread)
thread
- the thread who wants to accept ticks nowprivate static void startUserLoadTest()
public static void stopMetronome()
public static void stopTicking(AcceptsMetronomeTicks thread)
Thread
as well, also sends the
Thread
an Thread.interrupt()
. If it's an instance
of ServerThread
, it will first call the thread's
ServerThread.end()
method.
thread
- the object who doesn't want to get any more ticks@Deprecated public static String stringify(StackTraceElement[] stackTrace)
LibMisc.stringify(StackTraceElement[])
instead
stackTrace
- An array of StackTraceElements:s
@Deprecated public static String stringify(Throwable e)
LibMisc.stringify(Throwable)
instead
e
- A Throwable to be stringified into a backtrace
public static void tick()
private static void tickGameStatePump(long t)
t
- The current timeprivate static void tickMetronomeListeners(long t, long deltaT)
t
- the current time in milliseconds (at the start of the
global “tick”)deltaT
- the time since the last metronome tickprivate static void tickServerThreads(long t, long deltaT, boolean dumpUserThreads)
t
- The time at the start of the tickdeltaT
- The time since the last tickdumpUserThreads
- If true, dump out the status information
on each thread to STDOUTpublic static void traceThis()
public static void traceThis(String string)
string
- A string to be used as a label on the tracepublic static void unquench(InetAddress address)
address
- WRITEMEpublic static void updateHighWaterMark()
public static void wallops(AbstractUser user, String string)
user
- The user sending the messagestring
- The message to broadcastpublic static void add(AcceptsMetronomeTicks listener)
listener
- The listener who wishes to receive Metronome
ticks.public static void add(ListeningThread listeningThread)
listeningThread
- to be addedpublic static void add(Zone zone)
zone
- the Zone to be addedpublic static void addDefaultListener(RoomListener listener)
listener
- the new default listener to be added@Deprecated public static void addZone(String zoneName, Zone zone)
add(Zone)
zoneName
- The zone's name (ignored)zone
- The Zone objectpublic static void blather(String message)
message
- The messagepublic static void blather(String user, String room, String address, String message, boolean urgent)
user
- The user name and ID responsibleroom
- The room and zone in which the action occurredaddress
- The user's remote socket's IP address and port
numbermessage
- The event which occurredurgent
- Urgent messages are written even when debugging is
disabledprivate static void blatherToJournal(String user, String room, String address, String message, boolean urgent)
user
- The user name and ID responsibleroom
- The room and zone in which the action occurredaddress
- The user's remote socket's IP address and port
numbermessage
- The event which occurredurgent
- Urgent messages are written even when debugging is
disabledpublic static void bugDuplex(String subject, String message)
subject
- The subjectmessage
- The error messageprivate static Zone createLoginZone()
public static Error fatalBug(Exception e)
e
- An exception to report
Error
- (based upon the exception) every time. Since the
Error is also thrown, it's never actually received by
the caller, but it makes the compiler happy to write
it into a throw clause, so it realizes that the flow
will not continue.public static Error fatalBug(String string)
string
- The error to report
public static Error fatalBug(String string, Throwable t)
string
- A description of the error to reportt
- An exception to escalate to the Error
private static int getAccurateHeadcount()
public static Collection<AbstractUser> getAllUsers()
public static LinkedList<Zone> getAllZones()
public static long getBootTime()
public static Charon getCharon()
Charon
reaper thread
public static String getClusterLeader()
public static Collection<RoomListener> getDefaultListeners()
public static int getHighWaterUsers()
public static Kalendor getKalendor()
public static long getLastMetronomeTick()
public static Zone getLoginZone()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |