public class DefaultRecorderStrategy extends AbstractRecorderStrategy
| Modifier and Type | Class and Description |
|---|---|
private static class |
DefaultRecorderStrategy.RecorderElementEntryComparator
Implements a comparator for recorder element mappings (for output).
|
private static class |
DefaultRecorderStrategy.ThreadDataMapElementComparator
Implements a comparator for thread data entries (for output).
|
| Modifier and Type | Field and Description |
|---|---|
static boolean |
ENABLE_DEBUG
Defines whether debugging output should be enabled.
|
private RecorderElement |
excluded
Stores the pseudo recording element for the blocking monitoring overhead,
i.e. exclusion of monitoring.
|
private ResultFormatter |
formatter
Stores the formatter for output formatting.
|
private boolean |
formatterConfigured
Stores if the formatter was configured.
|
private ProcessData.Measurements |
jvmNotificationInstance
Internal singleton instance passed to the plugin event mechanism
in case of new JVM measurement information.
|
private java.io.OutputStream |
logStream
Stores the output log stream.
|
private RecorderElement |
programRecord
Stores the recording element for the program itself, i.e. all unassigned
recordings.
|
private ProcessData.Measurements |
systemNotificationInstance
Internal singleton instance passed to the plugin event mechanism
in case of new system measurement information.
|
private LongHashMap<ThreadData> |
threads
Stores the relation among thread id and information collected on
running threads.
|
private HashMap<java.lang.String,TimerInfo> |
timers
Stores information about the timers.
|
REGISTER_END, REGISTER_FORCE| Constructor and Description |
|---|
DefaultRecorderStrategy(ResultFormatter formatter)
Creates the recorder strategy.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
assignAllTo(java.lang.String recId,
boolean enter,
long now,
ThreadsInfo threadInfo)
Notifies that the following values (if not further calls
to this method or other recording ids occur) should be assigned
to the given
recId. |
protected RecorderElement |
assignByStackTrace(java.lang.String recId,
java.lang.String caller,
long threadId,
boolean exclude,
long instanceId)
Retrieves the recorder element to be used for recording based on the
given recorder identification and the thread identification.
|
void |
clearTemporaryData()
Notify that temporary data e.g. from instrumentation shall be cleared.
|
private void |
configureFormatter()
Configures the formatter for output based on the data in
Configuration and stores an output file instance in
logStream. |
void |
endSystem()
Called as the last event from the monitored program.
|
boolean |
enter(java.lang.String recId,
long now,
ThreadsInfo threadInfo,
boolean exclude)
Notifies the recorder about a method being called.
|
void |
enterConfiguration(java.lang.String ids)
Notify the recorder that a new variability configuration might have
been entered.
|
boolean |
exit(java.lang.String recId,
long now,
ThreadsInfo threadInfo,
boolean exclude)
Notifies the recorder about a method being called.
|
boolean |
finishRecording(long now,
long threadId,
LongLongHashMap curCpuTimes)
Notifies this strategy that recording should be stopped (second stage
of stopping the recorder).
|
private ThreadData |
getThread(long id,
long ticks,
long now)
Returns or registers a thread to
threads if not
registered before. |
private void |
log(RecorderElement elt,
RecorderElement cElt,
DebugState state,
java.lang.Object value,
ResourceType rType)
Debugging helper method.
|
void |
memoryAllocated(java.lang.String recId,
long threadId,
long id,
long size)
Notifies the recorder about an object allocated to memory.
|
void |
memoryFreedByRecId(java.lang.String recId,
long size)
Notifies the recorder about an object freed from memory.
|
void |
notifyProgramRecordCreation()
Notify the listeners about the program record creation (if not done
implicitly before).
|
void |
notifyTimer(java.lang.String id,
TimerState state,
long now,
long threadId)
Notifies about a timer event.
|
void |
notifyValueChange(java.lang.String id,
ValueType type,
java.lang.Object value)
Notifies about a changing attribute value.
|
boolean |
printCurrentState(ProcessData pData)
Prints the current (aggregated) state to the output formatter.
|
private static void |
printNonRecorderStackElement(boolean firstOnly)
Prints the stack trace elements for which the code is not located in
the recorder packages.
|
boolean |
printStatistics(ProcessData pData)
Emits the values collected so far.
|
void |
readIo(java.lang.String recId,
java.lang.String caller,
long threadId,
int bytes,
StreamType type)
Notifies the recorder about an amount of bytes read from some I/O
channel.
|
void |
register(long threadId,
long newId,
long threadTicks,
long now)
Registers a thread id with a recording id.
|
void |
startRecording(long now,
long threadId,
long threadTicks)
Notifies this strategy that recording should be start.
|
boolean |
stopTimeRecording(long now,
ThreadsInfo threadInfo)
Notifies this strategy that time recording should be stopped (first
stage of stopping the recorder).
|
void |
writeIo(java.lang.String recId,
java.lang.String caller,
long threadId,
int bytes,
StreamType type)
Notifies the recorder about an amount of bytes written to some I/O
channel.
|
enableVariabilityDetection, getRecorderElement, getRecorderElements, getRecorderId, getStorage, getVariabilitySeparatorChar, isVariabilityDetectionEnabled, registerForRecordingpublic static final boolean ENABLE_DEBUG
private RecorderElement programRecord
private RecorderElement excluded
private final LongHashMap<ThreadData> threads
private final HashMap<java.lang.String,TimerInfo> timers
private ResultFormatter formatter
private java.io.OutputStream logStream
private boolean formatterConfigured
private ProcessData.Measurements systemNotificationInstance
private ProcessData.Measurements jvmNotificationInstance
public DefaultRecorderStrategy(ResultFormatter formatter)
formatter - the formatter for printing the resultspublic boolean stopTimeRecording(long now,
ThreadsInfo threadInfo)
now - the current time in nano secondsthreadInfo - the information on the current thread and its timingtrue if the threadsInfo object should be released
to the pool, false if it should not be releasedpublic boolean finishRecording(long now,
long threadId,
LongLongHashMap curCpuTimes)
now - the current time in nano secondsthreadId - the id of the current threadcurCpuTimes - the current thread tickstrue if the curCpuTime object should be released
to the pool, false if it should not be releasedpublic void startRecording(long now,
long threadId,
long threadTicks)
now - the current time in nano secondsthreadId - the thread id of the executing (main) threadthreadTicks - the thread ticks for threadIdprivate void configureFormatter()
Configuration and stores an output file instance in
logStream.public boolean printStatistics(ProcessData pData)
pData - process datatrue if the data object should be released
to the pool, false if it should not be releasedpublic void endSystem()
finishRecording(long, long, de.uni_hildesheim.sse.monitoring.runtime.utils.LongLongHashMap) and optionally
printStatistics(de.uni_hildesheim.sse.monitoring.runtime.recordingStrategies.ProcessData). This method closes logStream if it
was opened before.public boolean enter(java.lang.String recId,
long now,
ThreadsInfo threadInfo,
boolean exclude)
recId - a unique identification where to assign this event tonow - the current system time in nano secondsthreadInfo - timing information on the currently running threadexclude - exclude from monitoringtrue if the threadsInfo object should be released
to the pool, false if it should not be releasedpublic boolean assignAllTo(java.lang.String recId,
boolean enter,
long now,
ThreadsInfo threadInfo)
recId.recId - the recording id (may be also the variability prefix)enter - true if this is a method enter event,
false elsenow - the current system timethreadInfo - information on the current threadtrue if the threadsInfo object should be released
to the pool, false if it should not be releasedpublic boolean exit(java.lang.String recId,
long now,
ThreadsInfo threadInfo,
boolean exclude)
recId - a unique identification where to assign this event tonow - the current time in nano secondsthreadInfo - timing information on the currently running threadexclude - exclude from monitoringtrue if the threadsInfo object should be released
to the pool, false if it should not be releasedpublic void register(long threadId,
long newId,
long threadTicks,
long now)
threadId - the thread id to be recordednewId - RecorderStrategy.REGISTER_FORCE the thread specified by
threadId and threadTicks is registered
with the recorderRecorderStrategy.REGISTER_END the thread specified by
threadId and threadTicks is marked as
terminated in the recorderthreadTicks - the ticks of threadIdnow - the current time in nano secondsprivate ThreadData getThread(long id, long ticks, long now)
threads if not
registered before.id - the Java thread idticks - the current thread ticksnow - the current system time in nanosecondspublic void memoryAllocated(java.lang.String recId,
long threadId,
long id,
long size)
recId - a unique identification where to assign this event tothreadId - the identification of the current threadid - the unique identification of the object being allocated (may be
0 to avoid recording of uninstrumented classes)size - the affected amount of bytes in memorypublic void memoryFreedByRecId(java.lang.String recId,
long size)
Object cannot be instrumented).recId - a unique identification where to assign this event tosize - the affected amount of bytes in memoryprivate void log(RecorderElement elt, RecorderElement cElt, DebugState state, java.lang.Object value, ResourceType rType)
elt - the recorder element for the component / group
(must not be null)cElt - the configuration recorder element (may be null)state - the debug state to be checked for this log (don't check
if null)value - the value to be printedrType - the type of the accounted resourcepublic void readIo(java.lang.String recId,
java.lang.String caller,
long threadId,
int bytes,
StreamType type)
recId - a unique identification where to assign this event tocaller - optional class name of the calling classthreadId - the identification of the current threadbytes - the number of bytestype - the type of the channelpublic void writeIo(java.lang.String recId,
java.lang.String caller,
long threadId,
int bytes,
StreamType type)
recId - a unique identification where to assign this event tocaller - optional class name of the calling classthreadId - the identification of the current threadbytes - the number of bytestype - the type of the channelpublic void enterConfiguration(java.lang.String ids)
ids - an optional (list of) group identificationprotected RecorderElement assignByStackTrace(java.lang.String recId, java.lang.String caller, long threadId, boolean exclude, long instanceId)
recId - the recorder elementcaller - optional class name of the calling classthreadId - the thread identificationexclude - force exclusion from monitoringinstanceId - the instance identifier (may be 0 for disabled)public boolean printCurrentState(ProcessData pData)
pData - additional information collected for system and JVM process (may be null)true if the threadsInfo object should be released
to the pool, false if it should not be releasedpublic void notifyTimer(java.lang.String id,
TimerState state,
long now,
long threadId)
id - the timer identification (may overlap with recorder ids)state - the new timer statenow - the current system time in millisecondsthreadId - the id of the currently executing thread, may be
negative if it should be ignoredpublic void notifyValueChange(java.lang.String id,
ValueType type,
java.lang.Object value)
id - the identification of the attribute (may overlap with
recorder ids)type - the type of the valuevalue - the new value (after changing)public void notifyProgramRecordCreation()
private static void printNonRecorderStackElement(boolean firstOnly)
firstOnly - print the first occurrence outside only, else the entire
stack outsidepublic void clearTemporaryData()