edu.nps.moves.logger
Class DisLogger

java.lang.Object
  extended by edu.nps.moves.logger.DisLogger
All Implemented Interfaces:
java.lang.Runnable

public class DisLogger
extends java.lang.Object
implements java.lang.Runnable

Logs DIS packets to XML format. You can easily receive DIS packets off the wire faster than they can be logged to XML, so you need to be careful about that. With a 2 GHz core duo and OSX, on a macbook pro laptop drive, you can log roughly 1,000 packets per second.

Since we cannot hold all the PDUs in memory at once, we set up a rotating system in which packets are read into a list, then, when the list is full, the list is handed off to a separate thread for marshalling to XML. This gives us at least a chance of not dropping packets while writing to file.

The classes here and in LogReplay are intended to be used from the command line, but it should be easy to wrap a GUI around them.

the classes are configured via a properties file. this defines the multicast group to listen on, the directory to which files should be written, etc.

Version:
$Id:$
Author:
DMcG

Field Summary
static int MAX_PDU_LOGFILE_SIZE
           
static int MAX_PDU_SIZE
          Maximum PDU size.
static int READ_TIMEOUT
          How long to wait for a packet to arrive, in ms, before throwing an exception
 
Constructor Summary
DisLogger(java.util.Properties loggerProperties)
          Create a new DIS logger with the given properties object.
 
Method Summary
 boolean finishedWriting()
          We may have broken out of the netowrk read loop, but the writer task is still involved in flushing out the already captured PDUs to disk.
static void main(java.lang.String[] args)
          Entry point.
 void run()
          Run the logger.
 void setDone()
          Breaks us out of network read log loop (perhaps after READ_TIMEOUT has passed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_PDU_SIZE

public static final int MAX_PDU_SIZE
Maximum PDU size. Theoretically this can be 8K or more, but all our stuff is smaller

See Also:
Constant Field Values

MAX_PDU_LOGFILE_SIZE

public static final int MAX_PDU_LOGFILE_SIZE
See Also:
Constant Field Values

READ_TIMEOUT

public static final int READ_TIMEOUT
How long to wait for a packet to arrive, in ms, before throwing an exception

See Also:
Constant Field Values
Constructor Detail

DisLogger

public DisLogger(java.util.Properties loggerProperties)
Create a new DIS logger with the given properties object. This includes the multicast group, port, an exercise name, and the number of pdus per file

Method Detail

setDone

public void setDone()
Breaks us out of network read log loop (perhaps after READ_TIMEOUT has passed


run

public void run()
Run the logger. Create a new factory to decode IEEE format PDUs, and start reading into the buffer. When the buffer fills we do a quick-change and write the buffer to a file in another thread, so we don't drop (too many) packets.

Specified by:
run in interface java.lang.Runnable

finishedWriting

public boolean finishedWriting()
We may have broken out of the netowrk read loop, but the writer task is still involved in flushing out the already captured PDUs to disk. This gives us a test until that is done.


main

public static void main(java.lang.String[] args)
Entry point. Pass in the properties file to initialze from the command line.

Parameters:
args -