net.sf.sparql.benchmarking.monitoring
Class StreamProgressListener

java.lang.Object
  extended by net.sf.sparql.benchmarking.monitoring.StreamProgressListener
All Implemented Interfaces:
ProgressListener
Direct Known Subclasses:
ConsoleErrProgressListener, ConsoleProgressListener, FileProgressListener

public class StreamProgressListener
extends Object
implements ProgressListener

A Progress Listener that prints informational messages to a PrintStream

Author:
rvesse

Constructor Summary
protected StreamProgressListener()
          Creates a Progress Listener without a stream
protected StreamProgressListener(boolean closeOnFinish)
          Creates a Progress Listener without a stream
  StreamProgressListener(OutputStream output)
          Creates a new Progress Listener for the given stream
  StreamProgressListener(OutputStream output, boolean closeOnFinish)
          Creates a new Progress Listener for the given stream
  StreamProgressListener(PrintStream output)
          Creates a new Progress Listener for the given stream
  StreamProgressListener(PrintStream output, boolean closeOnFinish)
          Creates a new Progress Listener for the given stream
 
Method Summary
<T extends Options>
void
afterOperation(Runner<T> runner, T options, Operation operation, OperationRun run)
          Invoked after each run of an operation
<T extends Options>
void
afterOperationMix(Runner<T> runner, T options, OperationMix mix, OperationMixRun run)
          Invoked after each run of an operation mix
<T extends Options>
void
beforeOperation(Runner<T> runner, T options, Operation operation)
          Invoked before each run of an operation
<T extends Options>
void
beforeOperationMix(Runner<T> runner, T options, OperationMix mix)
          Invoked before each run of an operation mix
<T extends Options>
void
finish(Runner<T> runner, T options, boolean ok)
          Invoked when test runs finish
protected  boolean hasSwitchedThreads()
           
protected  OutputStream openStream()
          Internal method called only when this class is derived from and the protected constructors which do not take a stream argument have been used
<T extends Options>
void
progress(Runner<T> runner, T options, String message)
          Invoked when an informational progress message is available
 void setForceThreadedOutput(boolean force)
          Sets whether to force threaded output i.e.
<T extends Options>
void
start(Runner<T> runner, T options)
          Invoked when test runs start
protected  void updateThread()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamProgressListener

protected StreamProgressListener(boolean closeOnFinish)
Creates a Progress Listener without a stream

Usable only by derived classes, the openStream() method will be called to open a stream at the time benchmarking starts

Parameters:
closeOnFinish - Whether the Output Stream should be closed when the listener receives the #handleFinished(boolean) call

StreamProgressListener

protected StreamProgressListener()
Creates a Progress Listener without a stream

Usable only by derived classes, the openStream() method will be called to open a stream at the time benchmarking starts


StreamProgressListener

public StreamProgressListener(PrintStream output,
                              boolean closeOnFinish)
Creates a new Progress Listener for the given stream

Parameters:
output - Output Stream
closeOnFinish - Whether the Output Stream should be closed when the listener receives the finish(Runner, Options, boolean) call

StreamProgressListener

public StreamProgressListener(PrintStream output)
Creates a new Progress Listener for the given stream

Parameters:
output - Output Stream

StreamProgressListener

public StreamProgressListener(OutputStream output)
Creates a new Progress Listener for the given stream

Parameters:
output - Output Stream

StreamProgressListener

public StreamProgressListener(OutputStream output,
                              boolean closeOnFinish)
Creates a new Progress Listener for the given stream

Parameters:
output - Output Stream
closeOnFinish - Whether the stream should be closed when the finish(Runner, Options, boolean) event is received
Method Detail

setForceThreadedOutput

public void setForceThreadedOutput(boolean force)
Sets whether to force threaded output i.e. output is prefixed with thread information to disambiguate output from different threads. The normal behaviour is that output is only threaded when the options explicitly declare a number of parallel threads > 1 but sometimes there may be many threads in use even when parallel threads is set to 1 due to the interaction of different components within the system.

Parameters:
force - True if thread disambiguated output should be forced regardless of the parallel threads declared by the Options

openStream

protected OutputStream openStream()
Internal method called only when this class is derived from and the protected constructors which do not take a stream argument have been used

Returns:
Output Stream

progress

public <T extends Options> void progress(Runner<T> runner,
                                         T options,
                                         String message)
Description copied from interface: ProgressListener
Invoked when an informational progress message is available

Specified by:
progress in interface ProgressListener
Parameters:
runner - Runner
options - Options
message - Message

hasSwitchedThreads

protected final boolean hasSwitchedThreads()

updateThread

protected void updateThread()

beforeOperation

public <T extends Options> void beforeOperation(Runner<T> runner,
                                                T options,
                                                Operation operation)
Description copied from interface: ProgressListener
Invoked before each run of an operation

Specified by:
beforeOperation in interface ProgressListener
Parameters:
runner - Runner
options - Options
operation - Operation

afterOperation

public <T extends Options> void afterOperation(Runner<T> runner,
                                               T options,
                                               Operation operation,
                                               OperationRun run)
Description copied from interface: ProgressListener
Invoked after each run of an operation

Specified by:
afterOperation in interface ProgressListener
Parameters:
runner - Runner
options - Options
operation - Operation
run - Run information

beforeOperationMix

public <T extends Options> void beforeOperationMix(Runner<T> runner,
                                                   T options,
                                                   OperationMix mix)
Description copied from interface: ProgressListener
Invoked before each run of an operation mix

Specified by:
beforeOperationMix in interface ProgressListener
Parameters:
runner - Runner
options - Options
mix - Operation Mix

afterOperationMix

public <T extends Options> void afterOperationMix(Runner<T> runner,
                                                  T options,
                                                  OperationMix mix,
                                                  OperationMixRun run)
Description copied from interface: ProgressListener
Invoked after each run of an operation mix

Specified by:
afterOperationMix in interface ProgressListener
Parameters:
runner - Runner
options - Options
mix - Operation mix
run - Mix run information

start

public <T extends Options> void start(Runner<T> runner,
                                      T options)
Description copied from interface: ProgressListener
Invoked when test runs start

Specified by:
start in interface ProgressListener
Parameters:
runner - Runner
options - Options

finish

public <T extends Options> void finish(Runner<T> runner,
                                       T options,
                                       boolean ok)
Description copied from interface: ProgressListener
Invoked when test runs finish

Specified by:
finish in interface ProgressListener
Parameters:
runner - Runner
options - Options
ok - Indicates whether running finished normally, if false then some error condition caused running to be halted


Copyright © 2014. All Rights Reserved.