net.spy.memcached
Class CouchbaseClient

java.lang.Object
  extended by net.spy.memcached.compat.SpyObject
      extended by net.spy.memcached.MemcachedClient
          extended by net.spy.memcached.MembaseClient
              extended by net.spy.memcached.CouchbaseClient
All Implemented Interfaces:
ConnectionObserver, CouchbaseClientIF, MembaseClientIF, MemcachedClientIF, Reconfigurable

public class CouchbaseClient
extends MembaseClient
implements CouchbaseClientIF


Field Summary
static String MODE_PREFIX
           
 
Fields inherited from class net.spy.memcached.MembaseClient
reconfiguring
 
Fields inherited from class net.spy.memcached.MemcachedClient
authDescriptor, authMonitor, connFactory, mconn, operationTimeout, opFact, shuttingDown, tcService, transcoder
 
Fields inherited from interface net.spy.memcached.MemcachedClientIF
MAX_KEY_LENGTH
 
Constructor Summary
CouchbaseClient(List<URI> baseList, String bucketName, String pwd)
           
CouchbaseClient(List<URI> baseList, String bucketName, String usr, String pwd)
           
 
Method Summary
 void addOp(HttpOperation op)
          Adds an operation to the queue where it waits to be sent to Couchbase.
 HttpFuture<View> asyncGetView(String designDocumentName, String viewName)
          Gets a view contained in a design document from the cluster.
 HttpFuture<List<View>> asyncGetViews(String designDocumentName)
          Gets a future with a list of views for a given design document from the cluster.
 View getView(String designDocumentName, String viewName)
          Gets a view contained in a design document from the cluster.
 List<View> getViews(String designDocumentName)
          Gets a list of views for a given design document from the cluster.
 ViewFuture query(View view, Query query)
          Queries a Couchbase view by calling its map function.
 HttpFuture<ViewResponseNoDocs> queryAndExcludeDocs(View view, Query query)
          Queries a Couchbase view by calling it's map function.
 HttpFuture<ViewResponseReduced> queryAndReduce(View view, Query query)
          Queries a Couchbase view by calling it's map function and then the views reduce function.
 void reconfigure(Bucket bucket)
          This function is called when there is a topology change in the cluster.
 void shutdown()
          Shuts down the client immediately.
 boolean shutdown(long duration, TimeUnit units)
          Shut down this client gracefully.
 
Methods inherited from class net.spy.memcached.MembaseClient
asyncGetAndLock, asyncGetAndLock, getAndLock, getAndLock
 
Methods inherited from class net.spy.memcached.MemcachedClient
add, add, addObserver, append, append, asyncCAS, asyncCAS, asyncCAS, asyncDecr, asyncGet, asyncGet, asyncGetAndTouch, asyncGetAndTouch, asyncGetBulk, asyncGetBulk, asyncGetBulk, asyncGetBulk, asyncGetBulk, asyncGets, asyncGets, asyncIncr, cas, cas, cas, connectionEstablished, connectionLost, decr, decr, decr, delete, delete, flush, flush, get, get, getAndTouch, getAndTouch, getAvailableServers, getBulk, getBulk, getBulk, getBulk, getNodeLocator, gets, gets, getStats, getStats, getTranscoder, getUnavailableServers, getVersions, incr, incr, incr, listSaslMechanisms, prepend, prepend, removeObserver, replace, replace, set, set, touch, touch, waitForQueues
 
Methods inherited from class net.spy.memcached.compat.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.spy.memcached.MemcachedClientIF
add, add, addObserver, append, append, asyncCAS, asyncCAS, asyncDecr, asyncGet, asyncGet, asyncGetAndTouch, asyncGetAndTouch, asyncGetBulk, asyncGetBulk, asyncGetBulk, asyncGetBulk, asyncGetBulk, asyncGets, asyncGets, asyncIncr, cas, cas, decr, decr, decr, delete, flush, flush, get, get, getAndTouch, getAndTouch, getAvailableServers, getBulk, getBulk, getBulk, getBulk, getNodeLocator, gets, gets, getStats, getStats, getTranscoder, getUnavailableServers, getVersions, incr, incr, incr, listSaslMechanisms, prepend, prepend, removeObserver, replace, replace, set, set, touch, touch, waitForQueues
 

Field Detail

MODE_PREFIX

public static final String MODE_PREFIX
Constructor Detail

CouchbaseClient

public CouchbaseClient(List<URI> baseList,
                       String bucketName,
                       String pwd)
                throws IOException,
                       ConfigurationException
Throws:
IOException
ConfigurationException

CouchbaseClient

public CouchbaseClient(List<URI> baseList,
                       String bucketName,
                       String usr,
                       String pwd)
                throws IOException,
                       ConfigurationException
Throws:
IOException
ConfigurationException
Method Detail

asyncGetView

public HttpFuture<View> asyncGetView(String designDocumentName,
                                     String viewName)
Gets a view contained in a design document from the cluster.

Specified by:
asyncGetView in interface CouchbaseClientIF
Parameters:
designDocumentName - the name of the design document.
viewName - the name of the view to get.
Returns:
a View object from the cluster.
Throws:
InterruptedException - if the operation is interrupted while in flight
ExecutionException - if an error occurs during execution

asyncGetViews

public HttpFuture<List<View>> asyncGetViews(String designDocumentName)
Gets a future with a list of views for a given design document from the cluster.

Specified by:
asyncGetViews in interface CouchbaseClientIF
Parameters:
designDocumentName - the name of the design document.
Returns:
a future containing a List of View objects from the cluster.

getView

public View getView(String designDocumentName,
                    String viewName)
Gets a view contained in a design document from the cluster.

Parameters:
designDocumentName - the name of the design document.
viewName - the name of the view to get.
Returns:
a View object from the cluster.

getViews

public List<View> getViews(String designDocumentName)
Gets a list of views for a given design document from the cluster.

Parameters:
designDocumentName - the name of the design document.
Returns:
a list of View objects from the cluster.

query

public ViewFuture query(View view,
                        Query query)
Queries a Couchbase view by calling its map function. This type of query will return the view result along with all of the documents for each row in the query.

Specified by:
query in interface CouchbaseClientIF
Parameters:
view - the view to run the query against.
query - the type of query to run against the view.
Returns:
a Future containing the results of the query.

queryAndExcludeDocs

public HttpFuture<ViewResponseNoDocs> queryAndExcludeDocs(View view,
                                                          Query query)
Queries a Couchbase view by calling it's map function. This type of query will return the view result but will not get the documents associated with each row of the query.

Specified by:
queryAndExcludeDocs in interface CouchbaseClientIF
Parameters:
view - the view to run the query against.
query - the type of query to run against the view.
Returns:
a Future containing the results of the query.

queryAndReduce

public HttpFuture<ViewResponseReduced> queryAndReduce(View view,
                                                      Query query)
Queries a Couchbase view by calling it's map function and then the views reduce function.

Specified by:
queryAndReduce in interface CouchbaseClientIF
Parameters:
view - the view to run the query against.
query - the type of query to run against the view.
Returns:
a Future containing the results of the query.

addOp

public void addOp(HttpOperation op)
Adds an operation to the queue where it waits to be sent to Couchbase. This function is for internal use only.


reconfigure

public void reconfigure(Bucket bucket)
This function is called when there is a topology change in the cluster. This function is intended for internal use only.

Specified by:
reconfigure in interface Reconfigurable
Overrides:
reconfigure in class MembaseClient
Parameters:
bucket - updated vbucket configuration

shutdown

public void shutdown()
Shuts down the client immediately.

Specified by:
shutdown in interface MemcachedClientIF
Overrides:
shutdown in class MemcachedClient

shutdown

public boolean shutdown(long duration,
                        TimeUnit units)
Shut down this client gracefully.

Specified by:
shutdown in interface MemcachedClientIF
Overrides:
shutdown in class MembaseClient
Parameters:
duration - the amount of time time for shutdown
units - the TimeUnit for the timeout
Returns:
result of the shutdown request