net.spy.memcached
Class TapClient

java.lang.Object
  extended by net.spy.memcached.TapClient

public class TapClient
extends Object


Constructor Summary
TapClient(InetSocketAddress... ia)
          Creates a TapClient against the specified servers.
TapClient(List<InetSocketAddress> addrs)
          Creates a TapClient against the specified servers.
TapClient(List<URI> baseList, String bucketName, String usr, String pwd)
          Creates a cluster aware TapClient This type of TapClient will TAP all servers in the specified cluster and will react to changes in the number of cluster nodes.
 
Method Summary
 long getMessagesRead()
          The number of messages read by all of the tap streams created with this client.
 ResponseMessage getNextMessage()
          Gets the next tap message from the queue of received tap messages.
 ResponseMessage getNextMessage(long time, TimeUnit timeunit)
          Gets the next tap message from the queue of received tap messages.
 boolean hasMoreMessages()
          Decides whether the client has received tap messages or will receive more messages in the future.
 void shutdown()
          Shuts down all tap streams that are currently running.
 Operation tapBackfill(String id, int runTime, TimeUnit timeunit)
          Specifies a tap stream that will send all key-value mutations that take place in the future.
 Operation tapBackfill(String id, long date, int runTime, TimeUnit timeunit)
          Specifies a tap stream that will send all key-value mutations that took place after a specific date.
 Operation tapCustom(String id, RequestMessage message)
          Allows the user to specify a custom tap message.
 Operation tapDump(String id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TapClient

public TapClient(InetSocketAddress... ia)
Creates a TapClient against the specified servers. This type of TapClient will TAP the specified servers, but will not be able to react to changes in the number of cluster nodes. Using the constructor which bootstraps itself from the cluster REST interface is preferred.

Parameters:
ia - the addresses of each node in the cluster.

TapClient

public TapClient(List<InetSocketAddress> addrs)
Creates a TapClient against the specified servers. This type of TapClient will TAP the specified servers, but will not be able to react to changes in the number of cluster nodes. Using the constructor which bootstraps itself from the cluster REST interface is preferred.

Parameters:
addrs - a list of addresses containing each node in the cluster.

TapClient

public TapClient(List<URI> baseList,
                 String bucketName,
                 String usr,
                 String pwd)
Creates a cluster aware TapClient This type of TapClient will TAP all servers in the specified cluster and will react to changes in the number of cluster nodes.

Parameters:
baseList - a list of servers to get the cluster configuration from.
bucketName - the name of the bucket to tap.
usr - the buckets username.
pwd - the buckets password.
Method Detail

getNextMessage

public ResponseMessage getNextMessage()
Gets the next tap message from the queue of received tap messages.

Returns:
The tap message at the head of the queue or null if the queue is empty for more than one second.

getNextMessage

public ResponseMessage getNextMessage(long time,
                                      TimeUnit timeunit)
Gets the next tap message from the queue of received tap messages.

Parameters:
time - the amount of time to wait for a message.
timeunit - the unit of time to use.
Returns:
The tap message at the head of the queue or null if the queue is empty for the given amount of time.

hasMoreMessages

public boolean hasMoreMessages()
Decides whether the client has received tap messages or will receive more messages in the future.

Returns:
true if the client has tap responses or expects to have responses in the future. False otherwise.

tapCustom

public Operation tapCustom(String id,
                           RequestMessage message)
                    throws ConfigurationException,
                           IOException
Allows the user to specify a custom tap message.

Parameters:
id - the named tap id that can be used to resume a disconnected tap stream
message - the custom tap message that will be used to initiate the tap stream.
Returns:
the operation that controls the tap stream.
Throws:
ConfigurationException - a bad configuration was recieved from the Membase cluster.
IOException - if there are errors connecting to the cluster.

tapBackfill

public Operation tapBackfill(String id,
                             int runTime,
                             TimeUnit timeunit)
                      throws IOException,
                             ConfigurationException
Specifies a tap stream that will send all key-value mutations that take place in the future.

Parameters:
id - the named tap id that can be used to resume a disconnected tap stream
runTime - the amount of time to do backfill for. Set to 0 for infinite backfill.
timeunit - the unit of time for the runtime parameter.
Returns:
the operation that controls the tap stream.
Throws:
ConfigurationException - a bad configuration was recieved from the Membase cluster.
IOException - If there are errors connecting to the cluster.

tapBackfill

public Operation tapBackfill(String id,
                             long date,
                             int runTime,
                             TimeUnit timeunit)
                      throws IOException,
                             ConfigurationException
Specifies a tap stream that will send all key-value mutations that took place after a specific date.

Parameters:
id - the named tap id that can be used to resume a disconnected tap stream
date - the date to begin sending key mutations from. Specify -1 to send all future key-value mutations.
runTime - the amount of time to do backfill for. Set to 0 for infinite backfill.
timeunit - the unit of time for the runtime parameter.
Returns:
the operation that controls the tap stream.
Throws:
ConfigurationException - a bad configuration was recieved from the Membase cluster.
IOException - If there are errors connecting to the cluster.

tapDump

public Operation tapDump(String id)
                  throws IOException,
                         ConfigurationException
Throws:
IOException
ConfigurationException

shutdown

public void shutdown()
Shuts down all tap streams that are currently running.


getMessagesRead

public long getMessagesRead()
The number of messages read by all of the tap streams created with this client. This will include a count of all tap response types.

Returns:
The number of messages read