Package net.spy.memcached
Class TapConnectionProvider
- java.lang.Object
-
- net.spy.memcached.compat.SpyObject
-
- net.spy.memcached.TapConnectionProvider
-
- All Implemented Interfaces:
ConnectionObserver
public class TapConnectionProvider extends SpyObject implements ConnectionObserver
A TapConnectionProvider.
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthDescriptor
authDescriptor
protected AuthThreadMonitor
authMonitor
protected MemcachedConnection
conn
protected OperationFactory
opFact
protected boolean
shuttingDown
protected TranscodeService
tcService
-
Constructor Summary
Constructors Constructor Description TapConnectionProvider(java.net.InetSocketAddress... ia)
Get a tap client operating on the specified memcached locations.TapConnectionProvider(java.util.List<java.net.InetSocketAddress> addrs)
Get a tap client operating on the specified memcached locations.TapConnectionProvider(ConnectionFactory cf, java.util.List<java.net.InetSocketAddress> addrs)
Get a tap client operating on the specified memcached locations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addObserver(ConnectionObserver obs)
Add a connection observer.void
addTapAckOp(MemcachedNode node, Operation op)
java.util.concurrent.CountDownLatch
broadcastOp(BroadcastOpFactory of)
private java.util.concurrent.CountDownLatch
broadcastOp(BroadcastOpFactory of, java.util.Collection<MemcachedNode> nodes, boolean checkShuttingDown)
void
connectionEstablished(java.net.SocketAddress sa, int reconnectCount)
A connection has just successfully been established on the given socket.void
connectionLost(java.net.SocketAddress sa)
A connection was just lost on the given socket.private MemcachedNode
findNode(java.net.SocketAddress sa)
OperationFactory
getOpFactory()
boolean
removeObserver(ConnectionObserver obs)
Remove a connection observer.void
shutdown()
Shut down immediately.boolean
shutdown(long timeout, java.util.concurrent.TimeUnit unit)
Shut down this client gracefully.boolean
waitForQueues(long timeout, java.util.concurrent.TimeUnit unit)
Wait for the queues to die down.
-
-
-
Field Detail
-
shuttingDown
protected volatile boolean shuttingDown
-
conn
protected final MemcachedConnection conn
-
opFact
protected final OperationFactory opFact
-
tcService
protected final TranscodeService tcService
-
authDescriptor
protected final AuthDescriptor authDescriptor
-
authMonitor
protected final AuthThreadMonitor authMonitor
-
-
Constructor Detail
-
TapConnectionProvider
public TapConnectionProvider(java.net.InetSocketAddress... ia) throws java.io.IOException
Get a tap client operating on the specified memcached locations.- Parameters:
ia
- the memcached locations- Throws:
java.io.IOException
- if connections cannot be established
-
TapConnectionProvider
public TapConnectionProvider(java.util.List<java.net.InetSocketAddress> addrs) throws java.io.IOException
Get a tap client operating on the specified memcached locations.- Parameters:
addrs
- the socket addrs- Throws:
java.io.IOException
- if connections cannot be established
-
TapConnectionProvider
public TapConnectionProvider(ConnectionFactory cf, java.util.List<java.net.InetSocketAddress> addrs) throws java.io.IOException
Get a tap client operating on the specified memcached locations.- Parameters:
cf
- the connection factory to configure connections for this clientaddrs
- the socket addresses- Throws:
java.io.IOException
- if connections cannot be established
-
-
Method Detail
-
addTapAckOp
public void addTapAckOp(MemcachedNode node, Operation op)
-
broadcastOp
public java.util.concurrent.CountDownLatch broadcastOp(BroadcastOpFactory of)
-
addObserver
public boolean addObserver(ConnectionObserver obs)
Add a connection observer. If connections are already established, your observer will be called with the address and -1.- Parameters:
obs
- the ConnectionObserver you wish to add- Returns:
- true if the observer was added.
-
removeObserver
public boolean removeObserver(ConnectionObserver obs)
Remove a connection observer.- Parameters:
obs
- the ConnectionObserver you wish to add- Returns:
- true if the observer existed, but no longer does
-
connectionEstablished
public void connectionEstablished(java.net.SocketAddress sa, int reconnectCount)
Description copied from interface:ConnectionObserver
A connection has just successfully been established on the given socket.- Specified by:
connectionEstablished
in interfaceConnectionObserver
- Parameters:
sa
- the address of the node whose connection was establishedreconnectCount
- the number of attempts before the connection was established
-
findNode
private MemcachedNode findNode(java.net.SocketAddress sa)
-
connectionLost
public void connectionLost(java.net.SocketAddress sa)
Description copied from interface:ConnectionObserver
A connection was just lost on the given socket.- Specified by:
connectionLost
in interfaceConnectionObserver
- Parameters:
sa
- the address of the node whose connection was lost
-
shutdown
public void shutdown()
Shut down immediately.
-
shutdown
public boolean shutdown(long timeout, java.util.concurrent.TimeUnit unit)
Shut down this client gracefully.- Parameters:
timeout
- the amount of time for shutdownunit
- the TimeUnit for the timeout- Returns:
- result of the shutdown request
-
waitForQueues
public boolean waitForQueues(long timeout, java.util.concurrent.TimeUnit unit)
Wait for the queues to die down.- Parameters:
timeout
- the amount of time time for shutdownunit
- the TimeUnit for the timeout- Returns:
- result of the request for the wait
- Throws:
java.lang.IllegalStateException
- in the rare circumstance where queue is too full to accept any more requests
-
broadcastOp
private java.util.concurrent.CountDownLatch broadcastOp(BroadcastOpFactory of, java.util.Collection<MemcachedNode> nodes, boolean checkShuttingDown)
-
getOpFactory
public OperationFactory getOpFactory()
-
-