|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbb.util.MemoryMonitorListenerImpl
public class MemoryMonitorListenerImpl
Simple implementation of MemoryMonitorListener
which logs most events to its own internal Logger.
The one exception is onMemoryState
, which writes the data to a separate file instead.
This class is multithread safe: every public method is synchronized.
Field Summary | |
---|---|
private int |
countState
|
private long |
instanceId
|
private static AtomicLong |
instanceIdNext
|
private Logger2 |
logger2
|
private PrintWriter |
pw
|
private static String |
separator
|
Constructor Summary | |
---|---|
MemoryMonitorListenerImpl()
|
Method Summary | |
---|---|
void |
close()
Called when the associated MemoryMonitor is being closed. |
private File |
makeFile()
|
void |
onMemoryLow(MemoryState state)
Called whenever the associated MemoryMonitor instance first detects the low memory state when previously it had detected a not low memory state. |
void |
onMemoryNotLow(MemoryState state)
Called whenever the associated MemoryMonitor instance first detects a not low memory state when previously it had detected the low memory state. |
void |
onMemoryState(MemoryState state)
Called whenever the associated MemoryMonitor instance has measured a new memory state. |
void |
onMonitoringError(Throwable t)
Called when the associated MemoryMonitor instance has detected some error while monitoring. |
void |
onMonitoringStarted()
Called when the associated MemoryMonitor instance has just started monitoring. |
void |
onMonitoringStopped()
Called when the associated MemoryMonitor instance has just stopped monitoring. |
static String |
toStringHeader(String separator)
Returns a description of the data written by onMemoryState . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String separator
private static final AtomicLong instanceIdNext
private final long instanceId
private int countState
private final PrintWriter pw
private final Logger2 logger2
Constructor Detail |
---|
public MemoryMonitorListenerImpl() throws RuntimeException
RuntimeException
Method Detail |
---|
public static String toStringHeader(String separator) throws IllegalArgumentException
onMemoryState
.
IllegalArgumentException
- if separator == null or separator.length() == 0private File makeFile()
public void onMonitoringStarted()
MemoryMonitorListener
onMonitoringStarted
in interface MemoryMonitorListener
public void onMonitoringStopped()
MemoryMonitorListener
onMonitoringStopped
in interface MemoryMonitorListener
public void onMonitoringError(Throwable t)
MemoryMonitorListener
onMonitoringError
in interface MemoryMonitorListener
t
- the Throwable which caused the errorpublic void onMemoryState(MemoryState state)
MemoryMonitorListener
onMemoryState
in interface MemoryMonitorListener
state
- the MemoryState which was just measuredpublic void onMemoryLow(MemoryState state) throws RuntimeException
MemoryMonitorListener
onMemoryLow
in interface MemoryMonitorListener
state
- the MemoryState for which low memory was just detected
RuntimeException
public void onMemoryNotLow(MemoryState state)
MemoryMonitorListener
onMemoryNotLow
in interface MemoryMonitorListener
state
- the MemoryState for which not low memory was just detectedpublic void close()
MemoryMonitorListener
close
in interface MemoryMonitorListener
close
in interface Closeable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |