Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344336

Summary: Headless mode not flushing CSV logger
Product: [Technology] STEM Reporter: Matthew Davis <mattadav>
Component: SimulationAssignee: Matthew Davis <mattadav>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: 1.2.0   
Hardware: All   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Matthew Davis CLA 2011-04-29 14:43:20 EDT
Per report on newsgroup:

http://www.eclipse.org/forums/index.php?t=rview&goto=667489&th=208356#msg_667489

Headless mode does not properly flush output to the logger.

Investigating...
Comment 1 Matthew Davis CLA 2011-04-29 14:43:51 EDT
Assigning to myself
Comment 2 Matthew Davis CLA 2011-04-29 15:51:11 EDT
Problem identified.

STEM uses a 10 MB write buffer on the loggers, as in many situations the CSV logger is out biggest bottleneck.  There is no forced flushes while a simulation runs, it only flushes when the buffer fills up (which happens in 10 MB blocks).

The problem with headless vs. GUI is simple.  The two modes use different log wrappers that listen to simulation events.  The GUI mode flushes the buffers on simulation pause and simulation stop.  Headless mode only flushes (and closes the writer) on simulation stop.  

When a simulation completes its sequence, it enters into the PAUSED state.  In GUI, this is fine, as it flushes the output then.  For headless mode, it's not fine, because Java exits immediately after all jobs finish and never sends a STOP event.

So, there are two bugs here:

1.  Headless mode needs to send a STOP event to all simulations when they complete (which is OK, because they will never be used again for that instance).
2.  The CustomCSVLogger (which headless mode uses) should flush the buffers on PAUSE.

A third bug deals more generally with the headless mode, as there's no way to STOP a simulation.  If you forcefully exit (control-c or kill) the JVM before a simulation finishes (which is possible on unbounded sims), there is potential (likely) data loss in the logs.  Will examine this one more in depth.
Comment 3 Matthew Davis CLA 2011-04-29 16:27:31 EDT
Fix committed to trunk at revision 1694.  Merged to 1.2.0 branch at 1695.