Class RedisMonitorConnection
java.lang.Object
com.blackrook.redis.RedisConnectionAbstract
com.blackrook.redis.RedisMonitorConnection
- All Implemented Interfaces:
AutoCloseable
A connection to Redis that sends MONITOR to the database
and constantly fires events on reception of responses.
This connection cannot have any commands issued to it.
- Author:
- Matthew Tropiano
-
Field Summary
Fields inherited from class RedisConnectionAbstract
reader, writer -
Constructor Summary
ConstructorsConstructorDescriptionRedisMonitorConnection(RedisMonitorListener... listeners) Creates an open connection to localhost, port 6379, the default Redis port.RedisMonitorConnection(RedisInfo info, RedisMonitorListener... listeners) Creates an open connection.RedisMonitorConnection(String host, int port, RedisMonitorListener... listeners) Creates an open connection.RedisMonitorConnection(String host, int port, String password, RedisMonitorListener... listeners) Creates an open connection. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(RedisMonitorListener... listeners) AddsRedisMonitorListeners to this connection.protected voidFires an event to listeners when this connection receives a monitor event.voidremoveListeners(RedisMonitorListener... listeners) RemovesRedisSubscriptionListeners from this connection.Methods inherited from class RedisConnectionAbstract
close, disconnect, isBound, isClosed, isConnected, reconnect
-
Constructor Details
-
RedisMonitorConnection
Creates an open connection to localhost, port 6379, the default Redis port.- Parameters:
listeners- the listeners to add to this monitor connection.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.
-
RedisMonitorConnection
public RedisMonitorConnection(String host, int port, RedisMonitorListener... listeners) throws IOException Creates an open connection.- Parameters:
host- the server hostname or address.port- the server connection port.listeners- the listeners to add to this monitor connection.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.
-
RedisMonitorConnection
public RedisMonitorConnection(String host, int port, String password, RedisMonitorListener... listeners) throws IOException Creates an open connection.- Parameters:
host- the server hostname or address.port- the server connection port.password- the server database password.listeners- the listeners to add to this monitor connection.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.RedisException- if the password in the server information is incorrect.
-
RedisMonitorConnection
Creates an open connection.- Parameters:
info- theRedisInfoclass detailing a connection's parameters.listeners- the listeners to add to this monitor connection.- Throws:
IOException- if an I/O error occurs when creating the socket.UnknownHostException- if the IP address of the host could not be determined.SecurityException- if a security manager exists and doesn't allow the connection to be made.RedisException- if the password in the server information is incorrect.
-
-
Method Details
-
addListener
AddsRedisMonitorListeners to this connection. All listeners on this connection are alerted when a message is received.- Parameters:
listeners- the listeners to add.
-
removeListeners
RemovesRedisSubscriptionListeners from this connection.- Parameters:
listeners- the listeners to remove.
-
fireOnMonitorEvent
Fires an event to listeners when this connection receives a monitor event.- Parameters:
event- the event to send to the listeners.
-