public class ZMonitor
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Class and Description |
---|---|
static class |
ZMonitor.Event
Enumerates types of monitoring events.
|
private static class |
ZMonitor.MonitorActor |
static class |
ZMonitor.ProtocolCode
The code returned by handshake events, as generated by
eventHandshakeXXX . |
static class |
ZMonitor.ZEvent
High-level representation of an event.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ADD_EVENTS |
private ZAgent |
agent |
private static java.lang.String |
CLOSE |
private ZStar.Exit |
exit |
private static java.lang.String |
REMOVE_EVENTS |
private static java.lang.String |
START |
private boolean |
started |
private static java.lang.String |
VERBOSE |
Constructor and Description |
---|
ZMonitor(ZContext ctx,
ZMQ.Socket socket)
Creates a monitoring actor for the given socket.
|
Modifier and Type | Method and Description |
---|---|
ZMonitor |
add(ZMonitor.Event... events)
Adds event types to monitor.
|
void |
close()
Stops the monitoring and closes the actor.
|
void |
destroy()
Stops the monitoring and closes the actor.
|
ZMonitor.ZEvent |
nextEvent()
Gets the next event, blocking for it until available.
|
ZMonitor.ZEvent |
nextEvent(boolean wait)
Gets the next event, blocking for it until available if requested.
|
ZMonitor.ZEvent |
nextEvent(int timeout)
Gets the next event, blocking for it until available if requested.
|
ZMonitor |
remove(ZMonitor.Event... events)
Removes event types from monitor.
|
ZMonitor |
start()
Starts the monitoring.
|
ZMonitor |
verbose(boolean verbose)
Sets verbosity of the monitor.
|
private boolean started
private static final java.lang.String START
private static final java.lang.String CLOSE
private static final java.lang.String VERBOSE
private static final java.lang.String ADD_EVENTS
private static final java.lang.String REMOVE_EVENTS
private final ZAgent agent
private final ZStar.Exit exit
public ZMonitor(ZContext ctx, ZMQ.Socket socket)
ctx
- the context relative to this actor. Not null.socket
- the socket to monitor for events. Not null.public final ZMonitor start()
public final void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public final void destroy()
public final ZMonitor verbose(boolean verbose)
verbose
- true for monitor to be verbose, otherwise false.public final ZMonitor add(ZMonitor.Event... events)
events
- the types of events to monitor.public final ZMonitor remove(ZMonitor.Event... events)
events
- the types of events to stop monitoring.public final ZMonitor.ZEvent nextEvent()
public final ZMonitor.ZEvent nextEvent(boolean wait)
wait
- true to block until next event is available, false to immediately return with null if there is no event.public final ZMonitor.ZEvent nextEvent(int timeout)
timeout
- the time in milliseconds to wait for a message before returning null, -1 to block.