public class PcpMonitorBridge extends java.lang.Object implements MonitoringView
Monitorable
s in the current system and a PCP
monitor agent. The bridge works by persisting any changes to a Monitorable into a section of
memory that is also mapped into the PCP monitor agents address space.
NOTE: This class is not thread safe, it is expected that clients interacting with the
start/stop nature of this class do this with their own thread safety, or use QuiescentRegistryListener
as that'll manage it nicely for you..QuiescentRegistryListener
Modifier and Type | Class and Description |
---|---|
private class |
PcpMonitorBridge.PcpMonitorBridgeMonitor
Responsible for adding any Monitorables that change to the queue of Monitorables that are
pending update.
|
Modifier and Type | Field and Description |
---|---|
private static TextSource |
DEFAULT_LONG_TEXT_SOURCE |
private static TextSource |
DEFAULT_SHORT_TEXT_SOURCE |
private static org.slf4j.Logger |
LOG |
private TextSource |
longTextSource |
private MetricNameMapper |
mapper |
private Monitor |
monitor |
private java.util.concurrent.ArrayBlockingQueue<Monitorable<?>> |
monitorablesPendingUpdate |
private PcpWriter |
pcpWriter |
private static java.util.Map<ValueSemantics,Semantics> |
SEMANTICS_MAP |
private TextSource |
shortTextSource |
private boolean |
started |
static int |
UPDATE_QUEUE_SIZE |
Constructor and Description |
---|
PcpMonitorBridge(PcpWriter writer) |
PcpMonitorBridge(PcpWriter writer,
MetricNameMapper mapper,
TextSource shortTextSource,
TextSource longTextSource) |
Modifier and Type | Method and Description |
---|---|
private Semantics |
convertToPcpSemantics(ValueSemantics semantics) |
boolean |
hasUpdatesPending() |
boolean |
isRunning() |
void |
startMonitoring(java.util.Collection<Monitorable<?>> monitorables)
Instructs the view to begin its work using the set of Monitorable instances
as the basis for whatever it is this 'view' wants to do with it (say, start externalising
the state of the metrics to an external file).
|
void |
stopMonitoring(java.util.Collection<Monitorable<?>> monitorables)
Stops monitoring updates on the Monitorables in the provided registry, any
updates to any of the monitorables passed in will no longer be tracked by this View
|
private void |
writeUpdate(Monitorable<?> monitorable) |
private static final org.slf4j.Logger LOG
private static final TextSource DEFAULT_SHORT_TEXT_SOURCE
private static final TextSource DEFAULT_LONG_TEXT_SOURCE
public static final int UPDATE_QUEUE_SIZE
private static final java.util.Map<ValueSemantics,Semantics> SEMANTICS_MAP
private final java.util.concurrent.ArrayBlockingQueue<Monitorable<?>> monitorablesPendingUpdate
private final Monitor monitor
private final MetricNameMapper mapper
private final TextSource shortTextSource
private final TextSource longTextSource
private volatile PcpWriter pcpWriter
private volatile boolean started
public PcpMonitorBridge(PcpWriter writer)
public PcpMonitorBridge(PcpWriter writer, MetricNameMapper mapper, TextSource shortTextSource, TextSource longTextSource)
public void stopMonitoring(java.util.Collection<Monitorable<?>> monitorables)
MonitoringView
stopMonitoring
in interface MonitoringView
monitorables
- the Collection of metrics to stop monitoringpublic boolean isRunning()
isRunning
in interface MonitoringView
MonitoringView.startMonitoring(java.util.Collection)
()}public boolean hasUpdatesPending()
public void startMonitoring(java.util.Collection<Monitorable<?>> monitorables)
MonitoringView
MonitoringView.stopMonitoring(java.util.Collection)
before recalling startMonitoring.startMonitoring
in interface MonitoringView
monitorables
- the Collection of metrics to start monitoringprivate Semantics convertToPcpSemantics(ValueSemantics semantics)
private void writeUpdate(Monitorable<?> monitorable)