Class LogtoolCore


  • @Service
    public class LogtoolCore
    extends Object
    Given command-line arguments, reads a state log, re-creates and updates objects, calls message handlers in specified Analyzers. State log can be a .state file produced by a simulation session, with or without the initial metadata block, and classnames can be abbreviated or not. Also, the file can be embedded in an archive (a tar file) and can be compressed. So a typical use is to pass it the URL for a compressed log from a tournament. A state log can also be a source of weather and/or random-seed data for controlling variability in an experiment design. To serve that purpose, it can be useful to just get the input stream using getLogStream(String source). When reading a state log, it can be useful to filter the classes that are processed. To restrict processing to specific classes, call includeClassname(String classname) for each class to be processed.
    Author:
    John Collins
    • Constructor Detail

      • LogtoolCore

        public LogtoolCore()
        Default constructor
    • Method Detail

      • setPerTimeslotPause

        public void setPerTimeslotPause​(int msec)
        Sets the per-timeslot pause value, used by Visualizer
      • includeClassname

        public void includeClassname​(String classname)
        Adds the given classname to the list of IncludesOnly classes in the DomainObjectReader. If this list is non-empty, then only the specified classes will be included in the state log scan. Note that the SimEnd type is always included.
      • processCmdLine

        public String processCmdLine​(String[] args)
        Processes a command line, providing a state-log file from the local filesystem, or a remote URL.
      • recycleRepos

        public void recycleRepos()
      • resetDOR

        public void resetDOR​(boolean instantiate)
        Resets the DomainObjectReader, removing filtering criteria. If scanning a state log twice in a single session, it is almost certainly necessary to call this before each scan. For example, an experiment may specify the same state log for both RandomSeeds and for Weather data, in which case two separate scans will be necessary. If instantiate is false, then the reader will not instantiate objects or set the time in the current running environment. This is needed if the purpose of reading a log is to extract weather or random-seed data in an experiment environment.
      • readStateLog

        public String readStateLog​(String source,
                                   Analyzer... tools)
        Reads the given state-log source using the DomainObjectReader. Specify the state-log as a local filename or a remote URL, or pass "-" or null to read from standard-input.
      • getLogStream

        public BufferedReader getLogStream​(String source)
        Opens the state log file, uncompressing it and extracting it from an archive as needed. Before returning, the schema (if any) is read and applied to the DomainObjectReader and the stream is positioned just past the schema block
      • readStateLog

        public String readStateLog​(InputStream stream,
                                   Analyzer... tools)
        Reads a state log that may be compressed and/or archived
      • readStateLog

        public String readStateLog​(BufferedReader in,
                                   Analyzer... tools)
        Reads state-log from given input stream using the DomainObjectReader.
      • interrupt

        public void interrupt()
      • getObjectReader

        public ObjectReader getObjectReader​(String location)
        Returns an incremental ObjectReader instances positioned at the start of content in a state log. Before getting it, reset the DOR by calling resetDOR(), and set the filter criteria by calling includeClassname() or excludeClassname().