Package com.blackrook.redis
Class RedisMonitorConnection
- java.lang.Object
-
- com.blackrook.redis.RedisConnectionAbstract
-
- com.blackrook.redis.RedisMonitorConnection
-
- All Implemented Interfaces:
AutoCloseable
public class RedisMonitorConnection extends RedisConnectionAbstract
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 com.blackrook.redis.RedisConnectionAbstract
reader, writer
-
-
Constructor Summary
Constructors Constructor Description RedisMonitorConnection(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(RedisMonitorListener... listeners)
AddsRedisMonitorListener
s to this connection.protected void
fireOnMonitorEvent(RedisMonitorEvent event)
Fires an event to listeners when this connection receives a monitor event.void
removeListeners(RedisMonitorListener... listeners)
RemovesRedisSubscriptionListener
s from this connection.-
Methods inherited from class com.blackrook.redis.RedisConnectionAbstract
close, disconnect, isBound, isClosed, isConnected, reconnect
-
-
-
-
Constructor Detail
-
RedisMonitorConnection
public RedisMonitorConnection(RedisMonitorListener... listeners) throws IOException
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
public RedisMonitorConnection(RedisInfo info, RedisMonitorListener... listeners) throws IOException
Creates an open connection.- Parameters:
info
- theRedisInfo
class 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 Detail
-
addListener
public void addListener(RedisMonitorListener... listeners)
AddsRedisMonitorListener
s to this connection. All listeners on this connection are alerted when a message is received.- Parameters:
listeners
- the listeners to add.
-
removeListeners
public void removeListeners(RedisMonitorListener... listeners)
RemovesRedisSubscriptionListener
s from this connection.- Parameters:
listeners
- the listeners to remove.
-
fireOnMonitorEvent
protected void fireOnMonitorEvent(RedisMonitorEvent event)
Fires an event to listeners when this connection receives a monitor event.- Parameters:
event
- the event to send to the listeners.
-
-