Class CompetitionSetupService

  • All Implemented Interfaces:
    CompetitionSetup

    @Service
    public class CompetitionSetupService
    extends Object
    implements CompetitionSetup
    Manages command-line and file processing for pre-game simulation setup. A simulation can be started in one of two ways:
    • By running the process with command-line arguments as specified in PowerTacServer, or
    • by calling the preGame() method to set up the environment and allow configuration of the next game, through a web (or REST) interface.
    Author:
    John Collins
    • Constructor Detail

      • CompetitionSetupService

        public CompetitionSetupService()
        Standard constructor
    • Method Detail

      • processCmdLine

        public void processCmdLine​(String[] args)
        Processes command-line arguments, which means looking for the specified script file and processing that
      • bootSession

        public String bootSession​(String bootFilename,
                                  String configFilename,
                                  String gameId,
                                  String logfileSuffix,
                                  String seedData,
                                  String weatherData)
        Description copied from interface: CompetitionSetup
        Starts a bootstrap session with parameters. Result is null if successful, otherwise contains an error message. Parameters are:
        • bootFilename is the (required) name of an output file where the bootstrap dataset will be stored.
        • configFilename is the (optional) name of a server-configuration file; if the name contains a ":" it will be treated as a URL.
        • gameId is an (optional) game id, the default is a numerical session counter.
        • logfileSuffix is an (optional) filename suffix for the log output files; default value is "boot".
        • seedData is a state log from which random-number seeds will be extracted.
        • weatherData is the (optional) name of a file containing weather data for the simulation. It may be either XMl or a state file. A state file will be treated as a URL if it contains a ":" character.
        • configOutput is an optional filename to which the full server configuration will be dumped during the configuration process.
        Specified by:
        bootSession in interface CompetitionSetup
      • simSession

        public String simSession​(String bootData,
                                 String config,
                                 String jmsUrl,
                                 String gameId,
                                 String logfileSuffix,
                                 List<String> brokerUsernames,
                                 String seedData,
                                 String weatherData,
                                 String inputQueueName)
        Description copied from interface: CompetitionSetup
        Starts a simulation session with parameters, in a new thread. Result is null if successful, otherwise contains an error message. Parameters are:
        • bootData is the (required) name of an input file containing a bootstrap dataset for the simulation; it will be treated as a URL if it contains a ":" character.
        • config is the (optional) name of a server-configuration file; if the name contains a ":" it will be treated as a URL.
        • jmsUrl is the URL on which the server should listen for JMS connections. This is required if the server is to interact with brokers on separate machines. If given, all brokers must use this URL to contact the server.
        • gameId is an (optional) game id, the default is a numerical session counter.
        • logfileSuffix is an (optional) filename suffix for the log output files; default value is "sim".
        • brokerUsernames is a list of Strings giving the usernames of brokers who are expected to log in to the simulation before it starts. If a username is of the form string1/string2, then string1 is the broker's username, and string2 is the name of that broker's JMS input queue. If this argument is null or empty, the simulation will start without brokers.
        • seedData is the (optional) name of a file containing seed data for the simulation; it will be treated as a URL if it contains a ":" character.
        • weatherData is the (optional) name of a file containing weather data for the simulation; Either XMl or a state file A state file will be treated as a URL if it contains a ":" character.
        • inputQueueName is the name of the server's JMS input queue. If not given, then the default value of 'serverInput' will be used.
        • configOutput is an optional filename to which the full server configuration will be dumped during the configuration process.
        Specified by:
        simSession in interface CompetitionSetup
      • preGame

        public void preGame()
        Pre-game server setup - creates the basic configuration elements to make them accessible to the web-based game-setup functions. This method must be called when the server is started, and again at the completion of each simulation. The actual simulation is started with a call to competitionControlService.runOnce().
        Specified by:
        preGame in interface CompetitionSetup