public abstract class DefaultDiagnostic extends Diagnostic
Diagnostic
which stores one file per run.Modifier and Type | Class and Description |
---|---|
static class |
DefaultDiagnostic.CurrentRun
Class to store the current Run data.
|
Modifier and Type | Field and Description |
---|---|
protected int |
actualRuns |
protected String |
currentFileName |
protected static String |
LOG |
protected static Logger |
LOGGER |
protected static String |
TXT |
protected static String |
ZIP |
Constructor and Description |
---|
DefaultDiagnostic()
Creates a
DefaultDiagnostic |
DefaultDiagnostic(int initialDelay,
int period,
int runs)
Creates an instance
|
DefaultDiagnostic(int initialDelay,
int period,
int runs,
String baseName,
String outputExtension)
Creates an instance
|
Modifier and Type | Method and Description |
---|---|
void |
afterExecutionFinished(DiagnosticsContainer result)
Called when all the executions have been completed or the diagnostics session has been canceled.
|
protected void |
afterRunFinished(DiagnosticsContainer result)
This method should be execute after each run to clean the working variables.
|
void |
beforeExecutionStart(DiagnosticsContainer result)
Called before the first execution of the first run of this diagnostic.
|
protected void |
beforeRunStart(DiagnosticsContainer result,
int run)
This method should be executed before each run to prepare the working variables.
|
protected String |
buildResultFileName(int run)
Creates the full filename to write diagnostic results to
|
protected Path |
createCurrentFile(DiagnosticsContainer result,
int run)
Init the current file for output.
|
protected Path |
createRootDir(DiagnosticsContainer result)
Init the root dir for the result ensure that exists and is accessible.
|
protected BufferedOutputStream |
getCurrentOutputStream()
Create a BufferedOutputStream for the current file.
|
protected PrintWriter |
getCurrentPrintWriter()
Create a Printwriter for the current file.
|
protected DefaultDiagnostic.CurrentRun |
getCurrentRun() |
PrintWriter |
getDiagnosticLog() |
String |
getFileName()
Name used for the folder and files to be created.
|
void |
runDiagnostic(DiagnosticsContainer result,
int run)
Executes the diagnostic implemented by this
DefaultDiagnostic |
void |
runDiagnostic(PrintWriter out,
int run)
Executes the diagnostic implemented by this
DefaultDiagnostic . |
all, equals, getDescriptor, getId, getInitialDelay, getPeriod, getRuns, hashCode, setInitialDelay, setPeriod, setRuns
protected static final Logger LOGGER
protected int actualRuns
protected transient String currentFileName
protected static final String LOG
protected static final String ZIP
protected static final String TXT
public DefaultDiagnostic()
DefaultDiagnostic
public DefaultDiagnostic(int initialDelay, int period, int runs)
initialDelay
- number milliseconds to delay the first executionperiod
- period to wait between successive executions in millisecondsruns
- number of times this diagnostic should be executed on the diagnostic sessionpublic DefaultDiagnostic(int initialDelay, int period, int runs, @Nonnull String baseName, @Nonnull String outputExtension)
initialDelay
- number milliseconds to delay the first execution.period
- period to wait between successive executions in milliseconds.runs
- number of times this diagnostic should be executed on the diagnostic session.baseName
- base name for the output files.outputExtension
- extension of the main output file.public void runDiagnostic(@Nonnull PrintWriter out, int run) throws IOException
DefaultDiagnostic
. Convenient method that receives the
PrintWriter
to write to. If more flexibility is needed to generate content, override
runDiagnostic(DiagnosticsContainer result, int run)
instead.out
- OutputStream
where the diagnostic should write the resultsrun
- execution number of this callIOException
- thrown when there is a problem executing the diagnosticpublic void runDiagnostic(@Nonnull DiagnosticsContainer result, int run) throws IOException
DefaultDiagnostic
runDiagnostic
in class Diagnostic
result
- DiagnosticsContainer
where the diagnostic should write the resultsrun
- execution number of this callIOException
- thrown when there is a problem executing the diagnosticpublic void beforeExecutionStart(DiagnosticsContainer result) throws IOException
beforeExecutionStart
in class Diagnostic
result
- the DiagnosticsContainer
to store the result toIOException
- thrown when there is a problem executing the diagnosticpublic void afterExecutionFinished(@Nonnull DiagnosticsContainer result) throws IOException
afterExecutionFinished
in class Diagnostic
result
- the DiagnosticsContainer
to store the result toIOException
- thrown when there is a problem executing the diagnosticprotected String buildResultFileName(int run)
run
- - number of execution within this diagnostic sessionpublic String getFileName()
getFileName
in class Diagnostic
protected void beforeRunStart(@Nonnull DiagnosticsContainer result, int run) throws IOException
result
- DiagnosticsContainer
where the diagnostic should write the results.run
- execution number of this call.IOException
- in case of error.protected void afterRunFinished(@Nonnull DiagnosticsContainer result)
result
- DiagnosticsContainer
where the diagnostic should write the results.protected Path createRootDir(@Nonnull DiagnosticsContainer result) throws IOException
result
- container for the diagnostic results.IOException
- if it is not possible to access to the folder.protected Path createCurrentFile(@Nonnull DiagnosticsContainer result, int run) throws IOException
result
- container for the diagnostic results.run
- execution number of this call.IOException
- in case of error.protected PrintWriter getCurrentPrintWriter() throws IOException
IOException
- in case of error.protected BufferedOutputStream getCurrentOutputStream() throws IOException
IOException
- in case of error.public PrintWriter getDiagnosticLog() throws IOException
IOException
- if the Diagnostic is not initialized.protected DefaultDiagnostic.CurrentRun getCurrentRun() throws IOException
DefaultDiagnostic.CurrentRun
.IOException
- if the Current Run is not initialized.Copyright © 2016–2017. All rights reserved.