Package net.sf.colossus.webserver
Class RunGameInOwnJVM
java.lang.Object
java.lang.Thread
net.sf.colossus.webserver.RunGameInOwnJVM
- All Implemented Interfaces:
Runnable
,IGameRunner
This class runs (starts and supervises) a Game on the Game Server
(as opposed to: on the User's PC).
It finds and reserves a port for it, starts it in a separate process
and when the process terminates, join()s it and releases the port.
If the game is run on a user's PC, the class RunGameInSameJVM will be
used.
- Author:
- Clemens Katzer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
NullDumper is a dummy reader that just consumes all the output produced by a Game's process - similar to /dev/null.Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private String
private File
private final String
private final GameInfo
private String
private int
private String
private static final Logger
private final WebServerOptions
private String
private final IRunWebServer
private String
private String
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionRunGameInOwnJVM
(IRunWebServer server, WebServerOptions options, GameInfo gi) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
createLoggingPropertiesFromTemplate
(File logPropTemplate, File logPropFile) private boolean
createServerCfgFile
(File gameDir) int
private String
getMissingPlayers
(List<String> names) private boolean
listAsString
(List<String> names) boolean
void
run()
private void
private void
sleepFor
(long millis) private void
boolean
private void
waitForGameShutdown
(Process p, RunGameInOwnJVM.NullDumper ndout, RunGameInOwnJVM.NullDumper nderr) private String
waitForLine
(BufferedReader in, int checkInterval) boolean
waitUntilGameStartedSuccessfully
(int timeout) boolean
waitUntilReadyToAcceptClients
(int timeout) Waits until socket is up, i.e.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.sf.colossus.webcommon.IGameRunner
start
-
Field Details
-
LOGGER
-
hostingPort
private int hostingPort -
hostingHost
-
server
-
options
-
gi
-
gameId
-
workFilesBaseDir
-
template
-
javaCommand
-
colossusJar
-
flagFile
-
alreadyStarted
private boolean alreadyStarted -
reasonStartFailed
-
-
Constructor Details
-
RunGameInOwnJVM
-
-
Method Details
-
makeRunningGame
public boolean makeRunningGame()- Specified by:
makeRunningGame
in interfaceIGameRunner
-
getHostingPort
public int getHostingPort()- Specified by:
getHostingPort
in interfaceIGameRunner
-
getHostingHost
- Specified by:
getHostingHost
in interfaceIGameRunner
-
getReasonStartFailed
-
tryToStart
public boolean tryToStart()- Specified by:
tryToStart
in interfaceIGameRunner
-
run
public void run() -
runInOwnJVM
private void runInOwnJVM() -
createServerCfgFile
-
createLoggingPropertiesFromTemplate
-
superviseGameStartup
private void superviseGameStartup() -
waitForGameShutdown
private void waitForGameShutdown(Process p, RunGameInOwnJVM.NullDumper ndout, RunGameInOwnJVM.NullDumper nderr) -
isSocketUp
private boolean isSocketUp() -
waitUntilReadyToAcceptClients
public boolean waitUntilReadyToAcceptClients(int timeout) Description copied from interface:IGameRunner
Waits until socket is up, i.e. game is ready to accept clients.- Specified by:
waitUntilReadyToAcceptClients
in interfaceIGameRunner
-
waitForLine
-
getMissingPlayers
-
listAsString
-
waitUntilGameStartedSuccessfully
public boolean waitUntilGameStartedSuccessfully(int timeout) - Specified by:
waitUntilGameStartedSuccessfully
in interfaceIGameRunner
-
sleepFor
private void sleepFor(long millis)
-