Class RunGameInOwnJVM

java.lang.Object
java.lang.Thread
net.sf.colossus.webserver.RunGameInOwnJVM
All Implemented Interfaces:
Runnable, IGameRunner

public class RunGameInOwnJVM extends Thread implements 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
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • hostingPort

      private int hostingPort
    • hostingHost

      private String hostingHost
    • server

      private final IRunWebServer server
    • options

      private final WebServerOptions options
    • gi

      private final GameInfo gi
    • gameId

      private final String gameId
    • workFilesBaseDir

      private String workFilesBaseDir
    • template

      private String template
    • javaCommand

      private String javaCommand
    • colossusJar

      private String colossusJar
    • flagFile

      private File flagFile
    • alreadyStarted

      private boolean alreadyStarted
    • reasonStartFailed

      private String reasonStartFailed
  • Constructor Details

  • Method Details

    • makeRunningGame

      public boolean makeRunningGame()
      Specified by:
      makeRunningGame in interface IGameRunner
    • getHostingPort

      public int getHostingPort()
      Specified by:
      getHostingPort in interface IGameRunner
    • getHostingHost

      public String getHostingHost()
      Specified by:
      getHostingHost in interface IGameRunner
    • getReasonStartFailed

      public String getReasonStartFailed()
    • tryToStart

      public boolean tryToStart()
      Specified by:
      tryToStart in interface IGameRunner
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • runInOwnJVM

      private void runInOwnJVM()
    • createServerCfgFile

      private boolean createServerCfgFile(File gameDir)
    • createLoggingPropertiesFromTemplate

      private boolean createLoggingPropertiesFromTemplate(File logPropTemplate, File logPropFile)
    • 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 interface IGameRunner
    • waitForLine

      private String waitForLine(BufferedReader in, int checkInterval)
    • getMissingPlayers

      private String getMissingPlayers(List<String> names)
    • listAsString

      public String listAsString(List<String> names)
    • waitUntilGameStartedSuccessfully

      public boolean waitUntilGameStartedSuccessfully(int timeout)
      Specified by:
      waitUntilGameStartedSuccessfully in interface IGameRunner
    • sleepFor

      private void sleepFor(long millis)