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 classNullDumper 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 Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Stringprivate Fileprivate final Stringprivate final GameInfoprivate Stringprivate intprivate Stringprivate static final Loggerprivate final WebServerOptionsprivate Stringprivate final IRunWebServerprivate Stringprivate StringFields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionRunGameInOwnJVM(IRunWebServer server, WebServerOptions options, GameInfo gi) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancreateLoggingPropertiesFromTemplate(File logPropTemplate, File logPropFile) private booleancreateServerCfgFile(File gameDir) intprivate StringgetMissingPlayers(List<String> names) private booleanlistAsString(List<String> names) booleanvoidrun()private voidprivate voidsleepFor(long millis) private voidbooleanprivate voidwaitForGameShutdown(Process p, RunGameInOwnJVM.NullDumper ndout, RunGameInOwnJVM.NullDumper nderr) private StringwaitForLine(BufferedReader in, int checkInterval) booleanwaitUntilGameStartedSuccessfully(int timeout) booleanwaitUntilReadyToAcceptClients(int timeout) Waits until socket is up, i.e.Methods inherited from class Thread
activeCount, checkAccess, clone, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, threadId, toString, yieldMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface 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:
makeRunningGamein interfaceIGameRunner
-
getHostingPort
public int getHostingPort()- Specified by:
getHostingPortin interfaceIGameRunner
-
getHostingHost
- Specified by:
getHostingHostin interfaceIGameRunner
-
getReasonStartFailed
-
tryToStart
public boolean tryToStart()- Specified by:
tryToStartin interfaceIGameRunner
-
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:IGameRunnerWaits until socket is up, i.e. game is ready to accept clients.- Specified by:
waitUntilReadyToAcceptClientsin interfaceIGameRunner
-
waitForLine
-
getMissingPlayers
-
listAsString
-
waitUntilGameStartedSuccessfully
public boolean waitUntilGameStartedSuccessfully(int timeout) - Specified by:
waitUntilGameStartedSuccessfullyin interfaceIGameRunner
-
sleepFor
private void sleepFor(long millis)
-